TIP: You can type at any time to perform a new search.
Product Average Price From Invoices
product_average_price_invoice · OCA/account-invoicing
- Repository
- OCA/account-invoicing · module folder · Try on Runboat
- Module version
- 1.0.0
- Category
- Account
- Folder size
- 0.08 MB
- License
- AGPL-3
- Application
- No
- Auto-installable
- No
- Website
- https://github.com/OCA/account-invoicing
- Last tracking update
- 2026-07-31 04:54:02
- Authors
- Tecnativa, Odoo Community Association (OCA)
- Maintainers
- Tecnativa, Odoo Community Association (OCA)
- Committers
- OCA-git-bot, oca-ci, eduezerouali-tecnativa
- Odoo dependencies
- Python dependencies
- None
- System dependencies
- None
- Required by
- None
- Description
This module computes, from posted invoices, two average prices and stores them on product templates and product variants: - **Average Purchase Price (APP)**, from vendor bills. - **Average Sale Price (ASP)**, from customer invoices. Each one is a weighted average: the untaxed subtotal of the invoice lines divided by the invoiced quantity. Taxes and added costs (landed costs, for instance) are excluded, and so are refunds, as a returned quantity is not a price the product was traded at. Both prices are company dependent: every company gets its own figures, computed from its own invoices and with its own window settings, so each one sees the prices it traded at. Instead of a fixed period, an expanding window is used: the last 30 days are checked first and, while no invoiced quantity is found, the window is widened 30 days at a time up to 360 days. The first window with data wins, and the range it covers is stored next to the price, so the figure is always readable in context. Both the step size and the maximum number of steps are configurable. Templates and variants are computed independently: a template averages the invoices of all its variants over a single window, a variant averages only its own. Because of that, they may end up using different periods. Values are stored, not computed on the fly. They are refreshed by a daily scheduled action, and on demand from the product form, where the journal items behind each price can also be opened.
Code Analysis ⓘ
Views touched (3)
| XML ID | Name | Model | Type | Status |
|---|---|---|---|---|
product_template_form_view |
product.template.form.average.price.invoice | product.template | form | Inherits product.product_template_form_view |
product_variant_easy_edit_view |
product.product.form.average.price.invoice | product.product | form | Inherits product.product_variant_easy_edit_view |
res_config_settings_view_form |
res.config.settings.form.average.price.invoice | res.config.settings | form | Inherits account.res_config_settings_view_form |
HTTP endpoints (0)
No HTTP endpoints found for this module.
Models touched (5)
New fields (8)
-
avg_purchase_priceFloatcompany_dependent=Truecopy=Falsedigits='Product Price'help='Average purchase unit price calculated from posted vendor bills, without taxes or added costs. A template averages all its variants.'string='APP' -
avg_purchase_price_date_fromDatecompany_dependent=True -
avg_purchase_price_date_toDatecompany_dependent=True -
avg_purchase_price_periodCharcompute='_compute_avg_price_periods'help='Date range the stored avg_purchase_price was computed for.' -
avg_sale_priceFloatcompany_dependent=Truecopy=Falsedigits='Product Price'help='Average sale unit price calculated from posted customer invoices, without taxes or added costs. A template averages all its variants.'string='ASP' -
avg_sale_price_date_fromDatecompany_dependent=True -
avg_sale_price_date_toDatecompany_dependent=True -
avg_sale_price_periodCharcompute='_compute_avg_price_periods'help='Date range the stored avg_sale_price was computed for.'
-
action_update_avg_purchase_price(self)Refresh only the stored avg_purchase_price on demand. -
action_update_avg_sale_price(self)Refresh only the stored avg_sale_price on demand. -
action_view_avg_purchase_price_move_lines(self) -
action_view_avg_sale_price_move_lines(self)
New fields (0)
No new fields.
Public methods (0)No public methods.
New fields (0)
No new fields.
Public methods (0)No public methods.
New fields (2)
-
avg_price_max_stepsIntegerdefault=12help='Maximum number of steps the window is widened (step size x this number is the furthest the computation looks back) before giving up.'string='Average Price Max Steps' -
avg_price_step_daysIntegerdefault=30help='Size in days of each step of the expanding window used to compute the average purchase (APP) and sale (ASP) prices from invoices.'string='Average Price Step (days)'
No public methods.
New fields (2)
-
avg_price_max_stepsIntegerreadonly=Falserelated='company_id.avg_price_max_steps' -
avg_price_step_daysIntegerreadonly=Falserelated='company_id.avg_price_step_days'
No public methods.