Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Artificial Intelligence
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Property Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Configure PAYE tax in Salary Structure - Payroll App

Subscribe

Get notified when there's activity on this post

This question has been flagged
pythonpayrollstructuresalary_rule
3 Replies
1366 Views
Avatar
Patrick MANDENGUE

Hi Fam,

I am configuring payroll for my company, but I have a "small" issue with the setup for the PAYE Tax in the salary structure. the calculation for PAYE is defined by the Gross Salary as such:


def calculate_paye('GROSS'):
    """
    Calculate PAYE (Pay As You Earn) tax based on gross salary.
    :param gross: float or int - gross salary amount
    :return: float - calculated PAYE
    """
    if ['GROSS'].amount <= 490:
        return 0.0  # No tax for salaries <= 490
    else:
        return -25.0  # Flat tax amount (example)


Can someone help me to fix this as I keep getting an error:

Wrong python code defined for: - Employee: Ireana Gomesh - 

Version: False - 

Payslip: Salary Slip - Ireana Gomesh - February 2026 - 

Salary rule: PAYE Tax (PAYE) - 

Error: invalid syntax (, line 1)

0
Avatar
Discard
Sujata

Try this instead:
result = 0.0
# Access GROSS using its code
gross = payslip.get_rule_value('GROSS')
if gross <= 490:
result = 0.0 # No tax for salaries <= 490
else:
result = -25.0 # Flat tax amount

Alternative (if above doesn't work):
result = 0.0
# Direct calculation using same formula as GROSS
gross = categories.BASIC + categories.ALW
if gross <= 490:
result = 0.0
else:
result = -25.0

Also verify:
1. Your GROSS rule code field is exactly GROSS (case-sensitive)
2. PAYE rule sequence number is higher than GROSS rule
3. Both rules are in the same salary structure

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,


Try the following code,


# Get Gross Salary from salary categories

gross = categories.GROSS or 0.0


# PAYE calculation

if gross <= 490:

    result = 0.0

else:

    result = -25.0


Hope it helps


0
Avatar
Discard
Patrick MANDENGUE
Author

when Conditions based on: Always true

Computation
# Get Gross Salary from salary categories
gross = categories.GROSS or 0.0
# PAYE calculation
if gross <= 490:
result = 0.0
else:
result = -25.0

Feeback: Error: AttributeError("'DefaultDictPayroll' object has no attribute 'GROSS'") while evaluating
'# Get Gross Salary from salary categories\r\ngross = categories.GROSS or 0.0\r\n\r\n# PAYE calculation\r\nif gross <= 490:\r\n result = 0.0\r\nelse:\r\n result = -25.0'

When the conditions are based on python Expression
result = 'BASIC' in inputs
result = 'ALW' in inputs

Computation
# Direct calculation using same formula as GROSS
gross = categories.BASIC + categories.ALW # Access the GROSS salary rule
if gross <= 490:
result = 0.0 # No tax for salaries <= 490
else:
result = -25.0 # Flat tax amount

There is no Error, but PAYE Tax doesn't appear when we compute sheet in the Employee payslip (Strange)

Patrick MANDENGUE
Author

please do you have a whatsapp number?

Avatar
Sujata
Best Answer

Hi Patrick,

Thanks for the details! Since GROSS is a salary rule (not a category), here's the code that can help:

result = 0.0
gross = rules.GROSS.amount  # Access the GROSS salary rule
if gross <= 490:
    result = 0.0  # No tax for salaries <= 490
else:
    result = -25.0  # Flat tax amount

Changes Required:

  • Use rules.GROSS.amount to get the value from your GROSS salary rule
  • Assign to result variable (required in Odoo)
  • Remove the function definition (def) as Odoo automatically wraps your code in a function context

Important: Make sure your PAYE rule has a higher sequence number than the GROSS rule so it calculates after GROSS is computed.

0
Avatar
Discard
Patrick MANDENGUE
Author

- Error: AttributeError("'DefaultDictPayroll' object has no attribute 'GROSS'") while evaluating
'result = 0.0\r\ngross = rules.GROSS.amount # Access the GROSS salary rule\r\nif gross <= 490:\r\n result = 0.0 # No tax for salaries <= 490\r\nelse:\r\n result = -25.0 # Flat tax amount'

Avatar
Patrick MANDENGUE
Author Best Answer
version: Odoo 19.0+e (Enterprise Edition)


Taxable Salary (code = GROSS) is Salary Rule

python code

result = categories['BASIC'] + categories['ALW'] 

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
Payroll > Salary_rule > Python condition
python payroll condition salary_rule
Avatar
1
Sep 17
7734
Attendance allownce
payroll salary_rule
Avatar
0
Jan 20
4262
Payroll Module
python payroll
Avatar
0
Dec 17
4605
Compute Salary Rule from other Rules
payroll payslip salary_rule
Avatar
Avatar
Avatar
Avatar
4
Sep 25
8272
How can I call a function from a salary rule of type python code? Solved
python calculation salary_rule
Avatar
Avatar
2
Dec 24
14123
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 Svenska ภาษาไทย 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