feat: update res_company_rule_employee to allow branch users to access parent company records

This commit is contained in:
Suherdy Yacob 2026-05-19 18:45:26 +07:00
parent babcb8af37
commit 2885b49a37

View File

@ -82,6 +82,17 @@ class HrEmployee(models.Model):
if rule_public.domain_force != new_domain_public: if rule_public.domain_force != new_domain_public:
rule_public.sudo().write({'domain_force': new_domain_public}) rule_public.sudo().write({'domain_force': new_domain_public})
# Allow branch users to read the parent company (OT) record.
# This is needed because POS payment methods and journals reference
# the parent company via Many2one fields (parent_company_id).
# Standard rule: [('id','in', company_ids)]
# New rule: also include parent companies (child_of reverses to include parents)
rule_company = self.env.ref('base.res_company_rule_employee', raise_if_not_found=False)
if rule_company:
new_domain_company = "['|', ('id', 'in', company_ids), ('id', 'parent_of', company_ids)]"
if rule_company.domain_force != new_domain_company:
rule_company.sudo().write({'domain_force': new_domain_company})
class HrEmployeePublic(models.Model): class HrEmployeePublic(models.Model):