Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Umělá inteligence
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textil
    • Kov
    • Nábytek
    • Jídlo
    • Pivovar
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • Podpora IT & hardware
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Procházet všechna odvětví
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Služby pro partnery
    • Registrujte svou účetní firmu
    • Referral Program
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Configure PAYE tax in Salary Structure - Payroll App

Odebírat

Get notified when there's activity on this post

This question has been flagged
pythonpayrollstructuresalary_rule
3 Odpovědi
1442 Zobrazení
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
Zrušit
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
Nejlepší odpověď

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
Zrušit
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
Nejlepší odpověď

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
Zrušit
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 Nejlepší odpověď
version: Odoo 19.0+e (Enterprise Edition)


Taxable Salary (code = GROSS) is Salary Rule

python code

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

0
Avatar
Zrušit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Payroll > Salary_rule > Python condition
python payroll condition salary_rule
Avatar
1
zář 17
7875
Attendance allownce
payroll salary_rule
Avatar
0
led 20
4346
Payroll Module
python payroll
Avatar
0
pro 17
4713
Compute Salary Rule from other Rules
payroll payslip salary_rule
Avatar
Avatar
Avatar
Avatar
4
zář 25
8357
How can I call a function from a salary rule of type python code? Vyřešeno
python calculation salary_rule
Avatar
Avatar
2
pro 24
14239
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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