Skip to content
Health
60/100
fair
  • Security25/25
    No findings
  • Activity25/25
    Last human commit 3 months ago
  • Required by5/25
    0 modules depend on it
  • Maturity5/25
    In 1 Odoo series since 17.0

Heuristic over the facts below, not an audit · How it's computed

Security findings
Grave / minor (static analysis)
Required by
0
Modules depending on it
External deps
0 pip · 0 bin
Python packages / system binaries
License
AGPL-3
No conflicts with its dependencies
Folder size
0.09 MB
Module directory on disk
Code analysis 0 migration notes 5 models 3 views 0 HTTP endpoints

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.

Dependencies

Odoo dependencies
Python dependencies
None
System dependencies
None
Required by
None

Code analysis

Extracted from the source by best-effort static analysis (no code is executed); details may be incomplete.

Views touched 3

XML IDNameModelTypeStatus
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_price Float
    company_dependent=True copy=False digits='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_from Date
    company_dependent=True
  • avg_purchase_price_date_to Date
    company_dependent=True
  • avg_purchase_price_period Char
    compute='_compute_avg_price_periods' help='Date range the stored avg_purchase_price was computed for.'
  • avg_sale_price Float
    company_dependent=True copy=False digits='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_from Date
    company_dependent=True
  • avg_sale_price_date_to Date
    company_dependent=True
  • avg_sale_price_period Char
    compute='_compute_avg_price_periods' help='Date range the stored avg_sale_price was computed for.'
Public methods (4)
  • 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_steps Integer
    default=12 help='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_days Integer
    default=30 help='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)'
Public methods (0)

No public methods.

New fields (2)
  • avg_price_max_steps Integer
    readonly=False related='company_id.avg_price_max_steps'
  • avg_price_step_days Integer
    readonly=False related='company_id.avg_price_step_days'
Public methods (0)

No public methods.