diff --git a/addons/mcs_payroll_localization/hooks.py b/addons/mcs_payroll_localization/hooks.py index c32ff67..65df1f8 100644 --- a/addons/mcs_payroll_localization/hooks.py +++ b/addons/mcs_payroll_localization/hooks.py @@ -51,23 +51,16 @@ class PayrollSetup: def _ensure_base_structure(self, company, categories): base = self.Structure.search([("code", "=", "BASE"), ("company_id", "=", company.id)], limit=1) + values = { + "name": "Base Payroll Structure", + "code": "BASE", + "company_id": company.id, + "rule_ids": [(6, 0, [])], + } if not base: - base = self.Structure.create({ - "name": "Base Payroll Structure", - "code": "BASE", - "company_id": company.id, - "rule_ids": [(6, 0, [ - self._rule(company, "Base Basic Salary", "BASE_BASIC", 10, categories["BASIC"], """ -result = contract.wage -""").id, - self._rule(company, "Base Gross", "BASE_GROSS", 100, categories["GROSS"], """ -result = categories.BASIC + categories.ALW -""").id, - self._rule(company, "Base Net Salary", "BASE_NET", 300, categories["NET"], """ -result = categories.BASIC + categories.ALW + categories.DED -""").id, - ])], - }) + base = self.Structure.create(values) + else: + base.write(values) return base def _rule(self, company, name, code, sequence, category, python, register=False): @@ -127,7 +120,7 @@ result = contract.wage * 0.50 result = contract.wage * 0.20 """), self._rule(company, "Special Allowance", "ALLOW", 30, categories["ALW"], """ -result = contract.wage - categories.BASIC - categories.ALW +result = contract.wage * 0.30 """), self._rule(company, "Gross", "GROSS", 100, categories["GROSS"], """ result = categories.BASIC + categories.ALW