OdooWiki OCA HUB

Variable quantity in contract recurrent invoicing

contract_variable_quantity folder_open OCA/contract open_in_new
Contract Management License: AGPL-3

With this module, you will be able to define in recurring contracts some lines with variable quantity according to a provided formula.

auto_awesome What this module does

AI-generated from the code · Odoo 19.0

Lets you set contract lines to invoice a quantity calculated by a formula instead of a fixed number, and optionally skip lines whose computed quantity is zero.

This module extends recurring contracts so that each contract line can be either a fixed quantity or a variable quantity.

  • On contract lines and contract template lines you get a "Qty. type" choice (Fixed quantity / Variable quantity). When you pick Variable quantity, the normal quantity field is hidden and a "Qty. formula" field appears instead.
  • Formulas are managed in a new screen, "Formulas (quantity)", found under the Contracts configuration menu. Each formula has a name and a Python code block that must store the quantity to invoice in a variable called 'result'. The code can use the current user, context, the contract line, the contract and the invoice being created.
  • When a recurring invoice is generated, the quantity of a variable line is computed by running its formula for the invoicing period; fixed lines keep their usual quantity.
  • On the contract header there is a "Skip Zero Qty Lines" option. If checked, contract lines whose computed quantity is zero do not create an invoice line at all.
  • Formulas are validated when saved: invalid code or code that does not produce a 'result' raises an error.

It touches contract.contract, contract.line, contract.template.line and adds the new contract.line.qty.formula model. Only accounting managers can create or change formulas; accounting users can read them.

Depends on

Menus it adds

menu_contract_quantity_formula
Models and fields (4)
  • contract.line · extends an existing model
  • contract.contract · extends an existing modelskip_zero_qty (Skip Zero Qty Lines)
  • contract.template.line · extends an existing modelqty_type (Qty. type), qty_formula_id (Qty. formula)
  • contract.line.qty.formula · new modelcode, name

Text generated by AI (DeepSeek) from reading the Odoo 19.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 8 confirmed, 1 with no information of 9 versions.

terminal Installation and usage

OCA documentation · Odoo 19.0
  • Go to Invoicing \> Configuration \> Contracts \> Formulas (quantity).
  • Define any formula based on Python code that stores at some moment a float/integer value of the quantity to invoice in the variable 'result'. You can use these variables to compute your formula:
  • env: Environment variable for getting other models.
  • context: Current context dictionary.
  • user: Current user.
  • line: Contract recurring invoice line that triggers this formula.
  • contract: Contract whose line belongs to.
  • invoice: Invoice (header) being created.

To use this module, you need to:

  • Go to Invoicing \> Customers \> Customers Contracts and select or create a new contract.
  • Check Generate recurring invoices automatically.
  • Add a new recurring invoicing line.
  • Select "Variable quantity" in column "Qty. type".
  • Select one of the possible formulas to use (previously created).

No verified information in OCA: Installation.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.