POS Account Tax Python
Calculate complex taxes for point of sale using Python in Odoo. Support diverse tax types, flexible tax rules, and accurate calculation.
Overview
POS Account Tax Python module extends Odoo POS tax calculation capabilities by using Python to handle complex tax rules.
Support calculation of VAT, sales tax, import tax, excise tax, and local taxes according to each country's regulations.
Automatically apply tax rules based on product, customer, location, and other business conditions.
Key Features
Key points
• Multi-level taxes - Support nested taxes, tax on tax, compound taxes
• Python tax rules - Write custom tax logic using Python
• Local taxes - Apply different taxes by state/city
• Product-based taxes - Different tax rates for each product group
• Conditional exemptions - Auto-exempt taxes for eligible customers/products
• Smart tax rounding - Round according to legal requirements
• Detailed tax reports - Aggregate taxes by type, period, location
• Accounting integration - Automatically record taxes in accounting books
Target Users
Key points
• Accountants - Manage taxes, prepare tax reports, ensure compliance
• Store managers - Ensure accurate tax calculation at checkout
• Cashiers - Apply taxes automatically when selling
• Finance managers - Monitor tax obligations and planning
How to Use
Steps
1. Go to Accounting → Configuration → Taxes
2. Create or edit tax type to apply for POS
3. Select "Tax Computation" as "Python Code"
4. Write Python code to calculate tax in "Python Code" field
5. Use variable: result = price_unit * quantity * 0.1 (example 10% tax)
6. Apply tax to product: Product → Taxes → Customer Taxes
7. Test tax calculation in POS by creating test order
8. View tax details in invoice and reports
Scenario 1: 10% VAT for regular goods
Retail store needs to apply 10% VAT for most products.
Create "VAT 10%" tax with Python code: result = price_unit * quantity * 0.10, apply to corresponding product groups.
Scenario 2: Tax exemption for essential products
Products like rice, salt, sugar are tax-exempt by regulation.
Create "VAT 0%" tax with Python code: result = 0, apply to essential product groups.
Scenario 3: Excise tax for alcohol
Alcohol is subject to 65% excise tax plus 10% VAT.
Create compound tax with Python: result = price_unit * quantity * 0.65 + (price_unit * quantity * 1.65) * 0.10.
Scenario 4: Different local taxes
Store chain has branches in multiple states with different local taxes.
Write Python code to check store address and apply corresponding tax rate.
Scenario 5: Tax rounding per regulation
Regulation requires rounding tax to nearest 100.
Use Python: result = round(price_unit * quantity * 0.10 / 100) * 100.
Available Python Variables
Key points
• price_unit - Product unit price before tax
• quantity - Product quantity
• product - Product object (access product.categ_id, product.name, etc.)
• partner - Customer object (access partner.country_id, partner.vat, etc.)
• company - Company object (access company.country_id, etc.)
• result - Result variable, assign calculated tax value
Python Code Examples
Key points
• Fixed 10% tax: result = price_unit * quantity * 0.10
• Threshold-based tax: result = price_unit * quantity * (0.15 if price_unit > 1000000 else 0.10)
• VAT customer exemption: result = 0 if partner.vat else price_unit * quantity * 0.10
• Category-based tax: result = price_unit * quantity * (0.05 if product.categ_id.name == "Food" else 0.10)
• Rounding: result = round(price_unit * quantity * 0.10, 2)
Tips for Effective Use
Key points
• Test Python code thoroughly - Check with various cases before applying
• Write comments in code - Explain logic for easier maintenance
• Use clear conditions - Avoid complex logic that's hard to understand
• Handle errors - Add try/except to avoid crashes during tax calculation
• Log for debugging - Use _logger.info() to track tax calculation process
• Refer to Odoo docs - See full list of available variables and methods
System Requirements
Key points
• Point of Sale module installed
• Accounting module installed
• POS Account Tax Python module activated
• Basic Python knowledge to write tax logic
• Admin rights to configure taxes in Odoo
Troubleshooting: Tax not calculated
Key points
• Check tax is applied to product
• View Python error logs in Odoo
• Check Python code syntax
• Ensure result variable is assigned
• Restart Odoo after code changes
Troubleshooting: Tax calculated incorrectly
Key points
• Check Python code logic step by step
• Print variable values for debugging
• Compare with manual calculation
• Review if/else conditions
• Verify tax regulations are correct
Business Benefits
Key points
• 100% compliance with complex tax regulations
• 90% reduction in manual tax calculation errors
• Flexible to change tax rules per new regulations
• Fully automate tax calculation process
• Save time training staff on taxes
• Reduce legal risks and tax penalties