HI All,
I have spent most of the day on this issue and would be great to get some help.
Basically I am wanting to filter the records for a new module based on the person being in a particular group.
First Attempt: Tried to filter on users who belong to a particular group and was unable to find online any logic that would do this. I am basically trying to use a DOMAIN that does something like the following:
<field name="domain">[('employee_recruitment.group_hr_manager','in',context.get('uid').groups)]</field>
Full record shown below:
<record model="ir.actions.act_window" id="recruitment_request_act">
<field name="name">Recruitment Request</field>
<field name="res_model">recruitment.request</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('employee_recruitment.group_hr_manager','in',context.get('uid').groups)]</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a recruitment request.
</p>
</field>
</record>
Method Two:
Created a dynamic variable to calculate whether the current user has approver rights or not and then reference that field within the domain as follows:
Add following Variable:
is_approver = fields.Boolean('Is Approver', compute='_get_is_approver', track_visibility='onchange')
Add function:
@api.one
def _get_is_approver(self):
approver_group = self.env.ref('employee_recruitment.group_hr_manager')
users = approver_group.users
for user in users:
if user.id == self._uid:
self.is_approver = True
return
self.is_approver = False
Add domain to record:
<field name="domain">[("is_approver_store","=",True)]</field>
Neither method works and assume that calculated fields do not work within the domain?
Any thoughts on how I might be able to achieve this?
Thanks,
Damien
hope your are looking this: http://learnopenerp.blogspot.com/2020/01/odoo-server-action.html