← Back to team overview

openerp-community team mailing list archive

Re: Different roles within different companies

 

Ian,

This is an very interesting question, and you may have two separate issues:
(1) Record Rules: Limit record access to the User's companies 
(2) ACLs: Set what Users can do on each company

As for (1), Record Rules are assigned to Groups - to every user in the group - not individual Users.
That's why it's a bad idea to have fixed ID numbers in rules.
You could:
* add a link from User to Employee (done here: https://code.launchpad.net/~akretion-team/openobject-addons/trunk-simple-user-to-employee-updated/+merge/114191)
* create record rules based on the Employee's Company. Something like:
    [('company_id','in', [e.company_id.id for e in user.employee_ids])]
* for large companies, you could do something similar using Departments instead of Companies.

Issue (2) is more difficult. There's no way to have Manager role in a company and Employee role in another.
The only "standard" way to do it that I can see is to create a distinct user for each company.
If your user works for companies 05 and 24, he would have users jsmith05 and jsmith24.
This is far from good, but might be a quick solution.
Doing it properly requiers a well thought hack on users\permissions modules.

Regards
Daniel Reis
SECURITAS Portugal

> Date: Fri, 13 Jul 2012 16:02:20 +1200
> From: ian@xxxxxxxxxxxxxx
> To: openerp-community@xxxxxxxxxxxxxxxxxxx
> Subject: Re: [Openerp-community] Different roles within different companies
> 
> Yeah, that is what I'm trying to do.  But not having a lot of luck
> formulating the rules.
> 
> I'd have thought that something like this would do the job ..
> 
> [('company_id','=',[6])]
> 
> But that doesn't seem to be doing it .. unless I have another rule
> somewhere that working against me.
> 
> 
> On Fri, July 13, 2012 11:43 am, Eric Caudal wrote:
> > Create a rule that allow specifically one company and associate one
> > group on it?
> > Eric CAUDAL
> > openerp
> >
> >
> > *Eric CAUDAL*, Elico Corp, Shanghai.
> > eric.caudal@xxxxxxxxxxxxxx  <mailto:eric.caudal@xxxxxxxxxxxxxx>
> > Cell: + 86 186 2136 1670. Skype: elico.corp
> > *Premium Certified Training Partner - OpenERP Ready Partner.*
> >
> >
> > Premium CTP
> > http://www.openerp.net.cn
> >
> > On 07/13/2012 05:15 AM, Ian Beardslee wrote:
> >> Hi all,
> >>
> >> I'm trying to find a way to define what people can do in OpenERP
> >> if they have different roles in different companies within the same
> >> multi-company install of OpenERP 6.1
> >>
> >> As an example, someone has two allowed companies. They are a Director
> >> of one, but not the other ('standard employee').
> >>
> >> Looking at how I can use the user's default company filter, combined
> >> with the 'Rule definition (domain filter)' and some additional groups.
> >> But not having much luck coming to grips with creating the right domain
> >> filter.
> >>
> >> What is the 'best' way to do this?
> >>
> >> Cheers,
> >> Ian
> >>

 		 	   		  

References