Skip to Content
Menu
This question has been flagged
4 Replies
3412 Views

Company A -> Company B (Parent->Child)

User A and User B have access to both companies and milti companies selected.

User A can create and confirm quotation on either of companies.

User B can create quotation on Company B and gets Access Denied error while confirming.

Access Denied by record rules for operation: read, uid: 8, model: res.company

Avatar
Discard

Hi @Dipak Shah instead of comment can you post as a answer.

Hello Pinakin Nayi,

It's done !!.

Thanks.

Best Answer

Hey Ramashish,

This is probable because of the record rule (security reason) that child company can't access / confirm few things of parent company.

for that default record rule is also created which causing a issue to you.

You can check it by moving ,

Settings > Technical > Security > Record rules > And search for the sale order record rule

Now,Record rule contained word like "multi-company" is responsible for the same.

So Possible solutions are >

1) Try to alter the domain (['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]) used in record rule.

2) And Better and easy solutions is wherever its getting issue technically add 'sudo' (superuser) keyword in your method to bypass the record rule

for ex :

> line.mapped('so_line').sudo()._compute_analytic()

> name = self.env[self.res_model].sudo().browse(self.res_id).name_get()

for your ref :

\https://www.odoo.com/documentation/10.0/reference/orm.html#odoo.models.Model.sudo

Hope this will help you !

Thanks.

Avatar
Discard
Author Best Answer

As I could not understand much on security rules, I tried a different path to solve this issue.

Sales->Sales->Customers->Edit->Remove Company from Contact (header) and Sales & Purchases tab. ie customer is not attached to any specific company.

This resolved the issue.

Avatar
Discard

Hey Ramashish,

Thanks for it But don't you think this is temp.solution .

- By removing company will cause problems in many analysis/accounting reports at the end.

- So humble request you to do the needful its a permanent solutions (security rules).

Many Thanks.

Author

Thank you for giving heads up let me look in to security rules again need more time to understand how to it gets implemented and first of all how to search specific security rule that is affecting.

Author

After checking the security rule for sale order multi company it states that either company_id can be null OR if it exists it should be child of the (logged in) user's company id.

So for the below 2 reasons further investigation may be required to substantiate why removing company (from customer) will (or may?) cause problems in many analysis/accounting reports at the end.

1. Company field is not mandatory in customer

2. Even the security rule for sale order multi company allows company_id to be null.