Odoo Help

Welcome!

This community 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.

0

Permissions issue

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

Hi,

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?

Thanks

EDIT:

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

1

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
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).

Ivan
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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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