Invoice Line Documentation¶
Overview¶
The Invoice Line module (account.invoice.line) represents individual line items on customer and supplier invoices. Each line captures product/service details, quantities, pricing, discounts, taxes, and accounting allocations. Lines are the detailed breakdown of invoice amounts and drive GL postings, tax calculations, and inventory movements.
Model Information¶
Model Name: account.invoice.line
Display Name: Invoice Line
Name Field: description
Key Fields: None (auto-increment ID)
Default Sort Order: sequence_no, id
Features¶
- ✅ Product and service line items
- ✅ Quantity and pricing with multiple UOMs
- ✅ Percentage and amount discounts
- ✅ Fee/charge calculations
- ✅ Tax calculation per line
- ✅ Tracking category support (2 levels)
- ✅ Related document links (sales orders, purchase orders)
- ✅ Cascade delete with parent invoice
- ✅ Automatic amount calculation
Key Fields Reference¶
Core Line Fields¶
| Field | Type | Required | Description |
|---|---|---|---|
invoice_id |
Many2One | ✅ | Parent invoice (cascade delete) |
sequence_no |
Integer | ❌ | Line item number |
product_id |
Many2One | ❌ | Product/service |
description |
Text | ✅ | Line description |
qty |
Decimal | ❌ | Quantity |
uom_id |
Many2One | ❌ | Unit of measure |
unit_price |
Decimal(6) | ❌ | Price per unit |
amount |
Decimal | ✅ | Line total amount |
Discount Fields¶
| Field | Type | Description |
|---|---|---|
discount |
Decimal | Discount percentage |
discount_amount |
Decimal | Fixed discount amount |
fee_charge_percentage |
Decimal | Fee/charge percentage |
fee_charge_amount |
Decimal | Fixed fee/charge amount |
Accounting Fields¶
| Field | Type | Description |
|---|---|---|
account_id |
Many2One | GL account for posting |
tax_id |
Many2One | Tax rate |
track_id |
Many2One | Tracking category (Track-1) |
track2_id |
Many2One | Tracking category (Track-2) |
Computed Tax Fields¶
| Field | Type | Description |
|---|---|---|
amount_tax |
Decimal | Tax amount |
amount_incl_tax |
Decimal | Amount including tax |
amount_excl_tax |
Decimal | Amount excluding tax |
Related Document Fields¶
| Field | Type | Description |
|---|---|---|
sale_id |
Many2One | Related sales order |
purchase_id |
Many2One | Related purchase order |
related_id |
Reference | Generic related document |
API Methods¶
1. Create Invoice Line¶
Method: create(vals, context)
Creates line and automatically calculates amounts.
Example:
line_id = get_model("account.invoice.line").create({
"invoice_id": invoice_id,
"product_id": product_id,
"description": "Professional Services",
"qty": 10,
"unit_price": 150.00,
"tax_id": vat_rate_id,
"account_id": revenue_account_id,
"amount": 1500.00 # Calculated automatically if not provided
})
2. Update Amounts¶
Method: update_amounts(ids, context={})
Recalculates line amounts based on qty, price, discounts, and fees.
Formula:
amount = qty * unit_price
amount -= (amount * discount / 100) # Percentage discount
amount -= discount_amount # Fixed discount
amount += (amount * fee_charge_percentage / 100) # Percentage fee
amount += fee_charge_amount # Fixed fee
Example:
3. Get Tax Amount (Computed)¶
Method: get_tax_amount(ids, context={})
Calculates tax amounts based on line amount and invoice tax type.
Returns:
Common Use Cases¶
Use Case 1: Create Simple Invoice Line¶
# Product line with tax
get_model("account.invoice.line").create({
"invoice_id": invoice_id,
"product_id": product_id,
"description": "Widget Model X",
"qty": 5,
"uom_id": unit_id,
"unit_price": 100.00,
"tax_id": vat_7_id,
"account_id": sales_account_id
})
# Amount automatically calculated: 5 * 100 = 500
Use Case 2: Line with Discounts¶
# Line with percentage and amount discount
get_model("account.invoice.line").create({
"invoice_id": invoice_id,
"description": "Bulk Order Special",
"qty": 100,
"unit_price": 50.00,
"discount": 10, # 10% off
"discount_amount": 200, # Additional $200 off
"tax_id": vat_id,
"account_id": sales_account_id
})
# Calculation:
# Base: 100 * 50 = 5000
# 10% discount: -500
# Amount discount: -200
# Final: 4300
Use Case 3: Service Line with Tracking¶
# Service line with department tracking
get_model("account.invoice.line").create({
"invoice_id": invoice_id,
"description": "Consulting - Marketing Campaign",
"qty": 40, # Hours
"unit_price": 150.00,
"tax_id": vat_id,
"account_id": consulting_revenue_id,
"track_id": marketing_dept_id, # Department
"track2_id": project_id # Project
})
Best Practices¶
1. Always Provide Description¶
# Good: Clear description
"description": "Widget Model X - Blue, 10kg"
# Insufficient: Unclear
"description": "Item"
2. Use Product Defaults¶
# Let product populate defaults
product = get_model("product").browse([product_id])[0]
line_vals = {
"invoice_id": invoice_id,
"product_id": product_id,
"description": product.name,
"unit_price": product.sale_price if is_sale else product.purchase_price,
"account_id": product.sale_account_id.id if is_sale else product.purchase_account_id.id,
"tax_id": product.sale_tax_id.id if is_sale else product.purchase_tax_id.id,
"uom_id": product.uom_id.id,
"qty": 1
}
3. Set Correct Accounts¶
# Sales invoice
"account_id": revenue_account_id
# Purchase invoice
"account_id": expense_account_id
# Asset purchase
"account_id": asset_account_id
Related Models¶
| Model | Relationship | Description |
|---|---|---|
account.invoice |
Many2One | Parent invoice |
product |
Many2One | Product/service |
account.account |
Many2One | GL account |
account.tax.rate |
Many2One | Tax rate |
sale.order |
Many2One | Related sales order |
purchase.order |
Many2One | Related purchase order |
Version History¶
Last Updated: 2025-12-16 Model Version: account_invoice_line.py Framework: Netforce
This documentation is generated for developer onboarding and reference purposes.