refactor: revert res_partner_rule to standard domain to prevent AccessError and update module author
This commit is contained in:
parent
2c1870f076
commit
e5998791e9
@ -7,7 +7,7 @@
|
|||||||
This module overrides the standard Odoo restriction of one company per employee.
|
This module overrides the standard Odoo restriction of one company per employee.
|
||||||
It allows an employee to be associated with multiple branch companies.
|
It allows an employee to be associated with multiple branch companies.
|
||||||
""",
|
""",
|
||||||
'author': 'Antigravity',
|
'author': 'Suherdy Yacob',
|
||||||
'depends': ['hr', 'pos_hr', 'hr_attendance'],
|
'depends': ['hr', 'pos_hr', 'hr_attendance'],
|
||||||
'data': [
|
'data': [
|
||||||
'security/hr_security.xml',
|
'security/hr_security.xml',
|
||||||
|
|||||||
Binary file not shown.
@ -72,9 +72,12 @@ class HrEmployee(models.Model):
|
|||||||
super()._register_hook()
|
super()._register_hook()
|
||||||
rule = self.env.ref('base.res_partner_rule', raise_if_not_found=False)
|
rule = self.env.ref('base.res_partner_rule', raise_if_not_found=False)
|
||||||
if rule:
|
if rule:
|
||||||
new_domain = "['|', '|', '|', ('partner_share', '=', False), ('company_id', 'parent_of', company_ids), ('company_id', '=', False), ('employee_ids.company_ids', 'in', company_ids)]"
|
# Revert res_partner_rule to standard Odoo 19 domain.
|
||||||
if rule.domain_force != new_domain:
|
# The custom override traversed `employee_ids` (hr.employee relation), which throws AccessError
|
||||||
rule.sudo().write({'domain_force': new_domain})
|
# for portal/public/new/guest users who do not have access to the hr.employee model.
|
||||||
|
original_domain = "['|', '|', ('partner_share', '=', False), ('company_id', 'parent_of', company_ids), ('company_id', '=', False)]"
|
||||||
|
if rule.domain_force != original_domain:
|
||||||
|
rule.sudo().write({'domain_force': original_domain})
|
||||||
|
|
||||||
rule_public = self.env.ref('hr.hr_employee_public_comp_rule', raise_if_not_found=False)
|
rule_public = self.env.ref('hr.hr_employee_public_comp_rule', raise_if_not_found=False)
|
||||||
if rule_public:
|
if rule_public:
|
||||||
|
|||||||
@ -14,9 +14,5 @@
|
|||||||
<field name="global" eval="True"/>
|
<field name="global" eval="True"/>
|
||||||
<field name="domain_force">['|', '|', '|', '|', ('company_ids', 'in', company_ids), ('company_id', 'in', company_ids + [False]), ('parent_id.user_id', '=', user.id), ('id', '=', user.employee_id.parent_id.id), ('user_id', '=', user.id)]</field>
|
<field name="domain_force">['|', '|', '|', '|', ('company_ids', 'in', company_ids), ('company_id', 'in', company_ids + [False]), ('parent_id.user_id', '=', user.id), ('id', '=', user.employee_id.parent_id.id), ('user_id', '=', user.id)]</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