Invoice Tax Documentation¶
Overview¶
The Invoice Tax module (account.invoice.tax) stores computed tax amounts for invoices, broken down by tax component. Each record represents one tax component's contribution to the invoice total, enabling detailed tax reporting, compliance tracking, and accurate GL postings for each tax type.
Model Information¶
Model Name: account.invoice.tax
Display Name: Invoice Tax
Name Field: None (no specific display field)
Key Fields: None (auto-increment ID)
Features¶
- ✅ Tax component breakdown
- ✅ Base and tax amount tracking
- ✅ Tax number/date for compliance
- ✅ Cascade delete with parent invoice
- ✅ Supports multi-component tax rates
Key Fields Reference¶
Core Fields¶
| Field | Type | Required | Description |
|---|---|---|---|
invoice_id |
Many2One | ✅ | Parent invoice (cascade delete) |
tax_comp_id |
Many2One | ✅ | Tax component from tax rate |
base_amount |
Decimal | ✅ | Amount before tax (taxable base) |
tax_amount |
Decimal | ✅ | Computed tax amount |
tax_no |
Char | ❌ | Tax invoice/receipt number |
tax_date |
Date | ❌ | Tax invoice/receipt date |
Field Details¶
tax_comp_id: - Links to specific component of tax rate - E.g., "SST" component of "VAT 7%" rate - Enables component-level reporting
base_amount: - Taxable amount before applying tax - Sum of all line amounts subject to this tax - Used for tax rate verification
tax_amount:
- Calculated tax for this component
- Formula: base_amount * component_rate / 100
- Can be negative for WHT
tax_no & tax_date: - For tax compliance and auditing - Tax receipt/invoice reference - Used in tax returns
API Methods¶
1. Create Invoice Tax¶
Method: create(vals, context)
Creates tax record (typically done automatically by invoice).
Example:
tax_id = get_model("account.invoice.tax").create({
"invoice_id": invoice_id,
"tax_comp_id": vat_component_id,
"base_amount": 1000.00,
"tax_amount": 70.00,
"tax_no": "TX-2025-001",
"tax_date": "2025-01-15"
})
Common Use Cases¶
Use Case 1: View Invoice Tax Breakdown¶
# Get all tax components for invoice
taxes = get_model("account.invoice.tax").search_browse([
["invoice_id", "=", invoice_id]
])
print("Invoice Tax Breakdown:")
for tax in taxes:
print(f" {tax.tax_comp_id.name}")
print(f" Base: ${tax.base_amount:,.2f}")
print(f" Tax: ${tax.tax_amount:,.2f}")
print(f" Rate: {tax.tax_comp_id.rate}%")
Use Case 2: Tax Report¶
# Generate tax summary report
from datetime import date
start_date = "2025-01-01"
end_date = "2025-01-31"
taxes = get_model("account.invoice.tax").search_browse([
["invoice_id.date", ">=", start_date],
["invoice_id.date", "<=", end_date],
["invoice_id.state", "=", "paid"]
])
# Group by component
summary = {}
for tax in taxes:
comp_name = tax.tax_comp_id.name
if comp_name not in summary:
summary[comp_name] = {"base": 0, "tax": 0, "count": 0}
summary[comp_name]["base"] += tax.base_amount
summary[comp_name]["tax"] += tax.tax_amount
summary[comp_name]["count"] += 1
print("TAX SUMMARY REPORT")
print(f"Period: {start_date} to {end_date}")
print("=" * 60)
for comp_name, totals in summary.items():
print(f"\n{comp_name}:")
print(f" Invoices: {totals['count']}")
print(f" Taxable Base: ${totals['base']:,.2f}")
print(f" Tax Collected: ${totals['tax']:,.2f}")
Best Practices¶
1. Let Invoice Calculate Taxes¶
# Good: Invoice automatically creates tax records
invoice_id = get_model("account.invoice").create({...})
get_model("account.invoice").post([invoice_id]) # Calculates taxes
# Avoid: Manually creating tax records
# (Invoice handles this automatically)
2. Use for Tax Reporting¶
Related Models¶
| Model | Relationship | Description |
|---|---|---|
account.invoice |
Many2One | Parent invoice |
account.tax.component |
Many2One | Tax component |
account.tax.rate |
Indirect | Tax rate (via component) |
Version History¶
Last Updated: 2025-12-16 Model Version: account_invoice_tax.py Framework: Netforce
This documentation is generated for developer onboarding and reference purposes.