feat: update res_partner_rule domain force to support multi-company employee access
This commit is contained in:
parent
842c6bcbdf
commit
8ab0089659
BIN
__pycache__/__manifest__.cpython-312.pyc
Normal file
BIN
__pycache__/__manifest__.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
@ -67,6 +67,16 @@ class HrEmployee(models.Model):
|
|||||||
domain = replace_company_leaf(domain)
|
domain = replace_company_leaf(domain)
|
||||||
return super()._search(domain, offset=offset, limit=limit, order=order, **kwargs)
|
return super()._search(domain, offset=offset, limit=limit, order=order, **kwargs)
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _register_hook(self):
|
||||||
|
super()._register_hook()
|
||||||
|
rule = self.env.ref('base.res_partner_rule', raise_if_not_found=False)
|
||||||
|
if rule:
|
||||||
|
new_domain = "['|', '|', '|', ('partner_share', '=', False), ('company_id', 'parent_of', company_ids), ('company_id', '=', False), ('employee_ids.company_ids', 'in', company_ids)]"
|
||||||
|
if rule.domain_force != new_domain:
|
||||||
|
rule.sudo().write({'domain_force': new_domain})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class HrEmployeePublic(models.Model):
|
class HrEmployeePublic(models.Model):
|
||||||
_inherit = 'hr.employee.public'
|
_inherit = 'hr.employee.public'
|
||||||
|
|||||||
@ -7,5 +7,9 @@
|
|||||||
<field name="global" eval="True"/>
|
<field name="global" eval="True"/>
|
||||||
<field name="domain_force">['|', ('company_ids', 'in', company_ids), '&', ('company_ids', '=', False), ('company_id', 'in', company_ids)]</field>
|
<field name="domain_force">['|', ('company_ids', 'in', company_ids), '&', ('company_ids', '=', False), ('company_id', 'in', company_ids)]</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="base.res_partner_rule" model="ir.rule">
|
||||||
|
<field name="domain_force">['|', '|', '|', ('partner_share', '=', False), ('company_id', 'parent_of', company_ids), ('company_id', '=', False), ('employee_ids.company_ids', 'in', company_ids)]</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user