Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Odoo Community Assistance Request: Critical Payroll Failure: Odoo 19 Payroll: Custom Rules Not Executing

Naroči se

Get notified when there's activity on this post

This question has been flagged
1 Odgovori
197 Prikazi
Avatar
Carlton Passley

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

ItemStatus / ValueNotes
Odoo Version19.0 (Odoo.sh Enterprise)


Module Namecp_jamaican_payroll


Failing Elementhr.salary.rule computation


Payslip OutputBasic 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?
0
Avatar
Opusti
Carlton Passley
Avtor

Thank you that was very helpful, matter resolve.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,


Odoo 19 no longer uses the old salary structure XML IDs found in earlier versions, such as hr_payroll.structure_employee or hr_payroll.basic_structure. These IDs simply do not exist in this version, which is why your module fails to load them and your salary rules never attach to a valid structure. As a result, the payslip has no active rules, and the rule context never includes a contract object—leading to errors like “NameError: contract is not defined” and a net salary equal to the gross salary.

In Odoo 19, the correct base structure is hr_payroll.structure_base, and the employee structure type is hr_payroll.structure_type_employee. Your custom Jamaican payroll rules must be linked to this new base structure, and your module should extend it through inheritance. Once the rules are properly attached to the Odoo 19 payroll structure hierarchy, the system will correctly pass the contract object to rule evaluation and execute all deductions (PAYE, NHT, NIS) normally.

The solution involves updating your XML to reference the new structure IDs, attaching your rules to structure_base, and extending that structure to include all Jamaican rules. After that, setting the proper default structure type ensures contracts and payslips use the updated structure correctly, resolving both the loading issue and the rule execution failure.

Hope it helps

1
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now