Problem Summary
We have successfully installed a custom Jamaican Payroll module (cp_jamaican_payroll) on Odoo 19.0 (Odoo.sh Enterprise), but the payslip calculation fails because the custom rules are not running, despite numerous fixes.
The final issue is a database execution problem where the core system fails to see the necessary links, resulting in a Net Salary = Gross Salary output.
1. Environment and Final Status
| Item | Status / Value | Notes |
| Odoo Version | 19.0 (Odoo.sh Enterprise) | |
| Module Name | cp_jamaican_payroll | |
| Failing Element | hr.salary.rule computation | |
| Payslip Output | Basic Salary ($200k) = Net Salary ($200k) | Rules are not being executed. |
2. Technical Symptoms and Code Failures
All code logic for the Jamaican deductions (PAYE, NHT, NIS) has been verified and is correct. The failure is a structural database issue.
A. The Core Error (Prevents Calculation)
When the payslip is computed, the rules fail because the context variable for the contract is not passed correctly:
NameError: name 'contract' is not defined
B. The Structural Problem (Prevents Module Load)
The attempt to fix the NameError by inserting the struct_id into the XML failed repeatedly, proving that the External ID is incorrect or corrupted in the database:
ValueError: External ID not found in the system: hr_payroll.structure_employee
This occurred across multiple attempts, including variations like hr_payroll.basic_structure.
C. The Code Solution Attempted
To fix both issues, we deleted the custom structure definition and instead tried to override the default "Regular Pay" structure using its default ID (hr_payroll.structure_employee) and the rules' XML IDs (jm_salary_rule_nht_employee, etc.).
Final Configuration (Code is Clean):
XML
<record id="jm_salary_rule_nht_employee" model="hr.salary.rule">
<field name="struct_id" ref="hr_payroll.structure_employee"/>
<field name="condition_python">result = employee.contract_id and employee.contract_id.wage > 0</field>
</record>
<record id="hr_payroll_structure_employee" model="hr.payroll.structure">
<field name="rule_ids" eval="[
(4, ref('jm_salary_rule_nht_employee')),
(4, ref('jm_salary_rule_nis_employee')),
... (etc.) ...
]"/>
</record>
What is the definitive, working XML ID for the base Employee Salary Structure in Odoo 19, or is there a required inheritance missing in the module's Python that prevents the contract object from loading?
Thank you that was very helpful, matter resolve.