Odoo Help


Permissions issue

Aitor Bouzas
on 1/21/15, 5:13 AM 489 views


I've made a workflow that automatically assigns a partner to a corresponding company through the partner's ZIP.

My companies are something like these:

- Central

---- Company 1
---- Company 2

When I create a new partner with an user from Company 1 but that has to be assigned to Company 2, it gives me an error because user from Company 1 has no permissions with Company 2... I still wanna keep that user from Company 1 can't see Company 2 partners, but I want this automatic assigment working...

Any workaround?



Is it possible that a record rule can be applied globally but not to some groups?




| 5 3 6
Jakarta, Indonesia
On 1/21/15, 5:31 AM

Answer 1: I wouldn't do it using workflow.  What you can do is to inherit the create and/or write method of res.partner, capture the change of zip there, and assign company_id based on your rule.  You can use SUPERUSER_ID (from openerp import SUPERUSER_ID and used it very sparingly) to overcome all record rules.

Answer 2: Yes, if you leave the group blank in a record rule, it will apply globally.

Answer 1 seems a good one. Can you help me on how to override? I already have inherited the class, but I don't know how to exactly override a function, do I need to call "super" so the method works like the parent method plus my functionality?

Aitor Bouzas
on 1/21/15, 5:43 AM

You just need to re-define the method in the inherit class. Yes, it is better that you call super to get the proper return value. Say that you want to inherit create method, below the inherit class add the following: def create(self, cr, uid, vals, context=None): # Then add your logic here before calling super res = super(inherit_class, self).create(cr, uid, vals, context=context) # You can add further logic here after the super call return res. If the formatting of comment screw it up, you basically need to redefine the method, add your logic, call super, add further logic, then return the return of super (or something else if you really know what you want to return).

on 1/21/15, 6:40 AM

Done! Thank you so much! I had to return a different value from the original super return value. Simply because user can't watch the partner if it belongs to another company. Thank you so much

Aitor Bouzas
on 1/21/15, 7:04 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/21/15, 5:13 AM
Seen: 489 times
Last updated: 3/16/15, 8:10 AM