Why not showing custom module in odoo - odoo

I have developed new module but facing problem.
Installing custom module on server, without access rights on menus and views, my module works properly.
But when i install module with access rights , just blank page appear instead of list of installed module.
Actual screen:
Blank screen:
Access right:
Security:

One of the thing that i learned when i was learning security in odoo:
if you are getting a blank page that's mean that you did not give you user the needed groups is base.group_user Witch is employee group. because backend is for employee of the company you need to give the user this group in order to see the backend. here is a picture of my screen when i logged ing using the administrator but i removed manually the base.group_user :
so if you are creating a new groups for your new user you need to give it at least base.roup_user
in code example stock_security model :
<record id="group_stock_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="base.module_category_warehouse_management"/>
<field name="implied_ids" eval="[(4, ref('base.group_user')), (4, ref('stock.group_locations'))]"/>
</record>
Here they are defining a new group Named user that include base.group_user
so my question is are you connecting with administrator or a new user
now i have two question :
are you connecting using Administrator or a new user with new groups?
if you are using administrator is the screen i blank page like the one in the picture or you have the menu apps and setting but you don't have your costum menus?
EDITS :
if the menu is not shown to user then the user don't have acces
rights to the model you need to gave the read acces to the group
ir.model.access.csv
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
// in this example all user can read record of model : model.name because you didn't specify the group
"unic_xml_id_for_every_record","name what ever you want","model_model_name",,1,0,0,0
// in this example only user belong to group some_group_xmlid can read record of model.name
"unic_xml_id_for_every_record","name what ever you want","model_model_name","some_group_xmlid",1,0,0,0
// user belong to group some_group_xmlid can read and create records of model.name
"unic_xml_id_for_every_record","name what ever you want","model_model_name","some_group_xmlid",1,0,1,0
exmple
ir.model.access.csv
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"mode_name_id_1","model_name all","model_model_name",,1,0,0,0
"mode_name_id_2","model_name create_acces","model_model_name","some_group_xmlid",1,0,1,0

Could you just show our what you JS console showing?

if you want your user to see a menu that show view of model.test and let us suppose that your used_id is test_user
and your group xml group_xml_id:
add the group to your user :
<!--
this will add the group to the existing groups if you want
to replace them [(6,0,[ref('group_xml_id'),]]
-->
<record id="test_user" model="res.users">
...
...
<field name="groups" eval="[(4, ref('group_xml_id')]"/>
</record>
add access role to users of group_xml_id:
"user_test_full_acces","USER TEST FULL ACCES","model_model_test","group_xml_id",1,1,1,1
if you want the menu to be seen only by the user belong to group group_xml_id:
<menu ....... groups="module_name.group_xml_id"/>
thouse are the roles that you need to respect in order to see the menu.
this query will show if your user have the wanted groups if you don't find the group
then you are doing something wrong you should check __manifest__ may be you forget to
put the xml file.
select p.name, g.name from res_users u
INNER JOIN res_partner p on u.partner_id = p.id
inner join res_groups_users_rel r on u.id = r.uid
INNER JOIN res_groups g on r.gid = g.id
order by p.name

Related

Odoo 16 Can't access another company

everyone! First of all, thanks in advance.
I've searched everywhere for a solution for my problem. Even when copying from the source code, it doesn't solve it.
I'm doing the Advanced B: ACL and Record Rules tutorial
When completing the sub-chapter on multi-company security, I can't do it.
My user can't get access to my new company
The problems I've encountered so far are:
The new company isn't in company_ids
When changing the Default Company and allowed companies, if:
The company is the new company
The only allowed company is the new company
Then, I get the error: Access Error: Access to unauthorized or invalid companies.
I don't know why my new company is invalid
I'm trying to access another company's records
This is my rule:
<record id="estate_private_companies_properties" model="ir.rule">
<field name="name">Privacy Plan Multi-Company</field>
<field name="model_id" ref="model_estate_property"/>
<field name="global" eval="True"/>
<field name="domain_force">[
('company_id', 'in', company_ids)
]</field>
</record>
EDIT:
Sorry for the confusion. I know the xml is not the problem
The problem is that my company is unauthorized or invalid and it doesn't show up in my company_ids
What the xml does is filter so you can only access the estate properties that are assigned to the currently active company (or companies). So it hasn't any effect on creating a company or making a company accessible.
If this is not the problem, please rephrase your question.
Make sure the user you test with has access to the company.
Login as the admin user
go to settings
Users & companies -> Users
select your user
in the user form you see a new field "Allowed Companies" which is only visible once you added a new company.
Make sure the new company is in this many2many list
login as your user

how to make condition to a specific groups

I want to add a condition to one group access to no open and no create_edit just for normal people, but when I use the code below the admin have no access to edit I give to him all access right to file security
<field name="name" domain="[('person_id', '=', person_id), ]"
options='{"no_open":True,"no_create_edit": True}' readonly="1"
/>
No way to get it done without Odoo core extension to provide that features or by overriding the method fields_view_get to dynamically change the view definition based on the user groups.

Odoo logged user data dont update for a login user

Please I need help with some custom rules configurations in Odoo 11.
Currently I'm doing a rule that allow an user only access to a certains product categories, for that I have a Many2many field which specify those categories:
product_category_ids = fields.Many2many('product.category')
Here is the rule that only allows access to that categories:
<record model="ir.rule" id="product_template_category_users">
<field name="name">product.template.category.users</field>
<field name="model_id" ref="product.model_product_template"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_unlink" eval="True"/>
<field name="perm_create" eval="True"/>
<field name="domain_force">[('categ_id', 'child_of', user.product_category_ids.ids)]</field>
</record>
The rule works fine, but I have this problem:
Login with user "A" who has that rule
Login in another sesion with user "B" and update user "A"
adding a new category to categories field
Return with user "A" and the rule doesn't show the new category added, also reload page doesn't work.
The changes only apply in "A" user when I change the current company or reload the Odoo Service.
I think that it has to be something with the user storing data when the user login, maybe is some way to update that data and allow the rule to read it from "user". I need that the changes doing to users apply in real time to that connected users without have to change the current company or reload the Odoo service.
Thanks for helping.
This is strange that it should work, but only after changing current company or restarting the Odoo server.
Can you try your modifications on a blank database and/or a new database with demo data loaded? If possible, it would be good to test this on an entirely different server to see if the problem might lay there.
Perhaps you can also try modifying your force_domain like this:
['|', ('categ_id', 'in', user.product_category_ids.ids), ('categ_id', 'child_of', user.product_category_ids.ids)]
If anyone has the same problem, I solve it using this funcion every time i made a change in the product categories field of user
self.env['ir.rule'].clear_cache()
That code clear the cache of rules so the rules apply the new domain.
Add self.env['ir.rule'].clear_cache() into create() and write() method of your model.

How to take out 'contact' values from a 'Many2one' field in Odoo?

Any Many2one field which is either linked to hr.employee or res.users shows values Home addresses or contacts in the Many2one drop down tool. Anyone has a suggestion on how to stop this ?
You can use domain filter to avoid unwanted results.
For Eg:- In sale order we only see customers although its related object is res.patner, Its because of domain filter( please see the code )
<field name="partner_id" on_change="onchange_partner_id(partner_id, context)" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}'/>
Here domain filter is " domain="[('customer','=',True)]" "
ie. records with only customer field is True is shown
From your comments:- If you want to see system users only then user res.users instead of res.partner. Like:-
'user_id' : fields.many2one('res.users', 'User')
Hope this helps.

OpenERP, error while creating a view filter

Im having problems with creating a filter on stock.picking object. Just recently i build a simple "privilege relay" - in each stock location you can define "Assigned User Group", thanks to that users that are in particular group can or cannot confirm moves for or out of the location.
Stock.picking:location_id -> assigned_user_group -> users
Now I would like to create a filter (later to be set default) on stock picking tree view that will show only the moves which locations (source location and destination location; i use them in stock.picking object) can be managed by a viewing user.
By far I wrote a filter that looks like that:
<record id="view_picking_internal_search_pl" model="ir.ui.view">
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_internal_search"/>
<field name="arch" type="xml">
<filter icon="terp-dialog-close" name="done" string="Done" domain="[('state','=','done')]" help="Pickings already processed" position="after">
<filter icon="terp-check" name="locgroup" string="Location Group" domain="[('user_id','in',[user.id for user in location_id.user_group.users])]" context="{'group_by':'date'}"/>
</filter>
</field>
</record>
I also added field location_id to the tree view.
But Im still getting an error (after choosing the filter) that even google doesnt know anything about:
TypeError: results.group_by is undefined
My questions are:
By looking on domain in filter field - what am i doing wrong?
Is something like that even possible?
I will gladly welcome any help.
Firstly, i think your domain is not correct, it could have been :
[('user_group.users.id', '=', uid)]
(because the first element of the tuple is a field on the model; and uid is a special value supplied in search views)
Next, This error :
TypeError: results.group_by is undefined
Seems to be a Javascript Error (coming from openerp-web interface), it often throws error like that when it receives unexpected values (when we make a mistake defining a view for example).
can you tell us if using the domain above solved your problem ?
NB: does your field user_group is a required field ? If not, i think the domain above won't display picking where user_group is not set, if you want to display picking where user_group is not set too, you can set a domain like that:
['|',('user_group.users.id', '=', uid), ('user_group','=',False)]
Regards