Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Artificial Intelligence
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Property Management
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Configure PAYE tax in Salary Structure - Payroll App

Subscriure's

Get notified when there's activity on this post

This question has been flagged
pythonpayrollstructuresalary_rule
3 Respostes
1408 Vistes
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
Descartar
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
Descartar
Patrick MANDENGUE
Autor

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
Autor

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
Descartar
Patrick MANDENGUE
Autor

- 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
Autor 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
Descartar
Enjoying the discussion? Don't just read, join in!

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

Registrar-se
Related Posts Respostes Vistes Activitat
Payroll > Salary_rule > Python condition
python payroll condition salary_rule
Avatar
1
de set. 17
7816
Attendance allownce
payroll salary_rule
Avatar
0
de gen. 20
4310
Payroll Module
python payroll
Avatar
0
de des. 17
4669
Compute Salary Rule from other Rules
payroll payslip salary_rule
Avatar
Avatar
Avatar
Avatar
4
de set. 25
8309
How can I call a function from a salary rule of type python code? Solved
python calculation salary_rule
Avatar
Avatar
2
de des. 24
14190
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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