Stock Analytic Rule

stock_analytic_rule
REPOSITORY
REPOSITORYOCA/account-analytic
GIT
GIThttps://github.com/OCA/account-analytic.git
GIT FOLDER
GIT FOLDERhttps://github.com/OCA/account-analytic/tree/17.0/stock_analytic_rule
VERSION
VERSION 1.0.0
CATEGORY
CATEGORYWarehouse Management
LICENSE
LICENSEAGPL-3
APPLICATION
APPLICATIONNo
AUTO-INSTALLABLE
AUTO-INSTALLABLENo
AUTHORS
AUTHORSOdoo Community Association (OCA), APSL-Nagarro, Bernat Obrador
MAINTAINERS
MAINTAINERSOdoo Community Association (OCA), APSL-Nagarro, Bernat Obrador
COMMITTERS
COMMITTERSWeblate, OCA-git-bot, oca-ci, bobrador
WEBSITE
WEBSITEhttps://github.com/OCA/account-analytic
LAST TRACKING UPDATE
LAST TRACKING UPDATE2026-07-06 19:20:06
ODOO DEPENDENCIES
ODOO DEPENDENCIES odoo/odoo:
    - stock
    - product
    - base
    - mail
    - base_setup
    - web
    - bus
    - web_tour
    - uom
    - barcodes_gs1_nomenclature
    - barcodes
    - digest
    - portal
    - web_editor
    - http_routing
    - auth_signup
    - resource
    - account
    - onboarding
    - analytic
PYTHON DEPENDENCIES
PYTHON DEPENDENCIES Not have
SYSTEM DEPENDENCIES
SYSTEM DEPENDENCIES Not have
DESCRIPTION
DESCRIPTION
This module extends the stock and analytic accounting capabilities by automatically creating analytic lines from stock based on configurable rules.

Key features:

- Define stock movement rules by source and destination locations.
- Compute analytic line amounts using either:
  - Product list price.
  - Category-based formula: `(avg_price * (avg_weight * qty)) + ((avg_weight * qty) * supplement)`
- Support for positive and negative analytic distributions.
- Handles partial distributions and multi-account combinations.
- Supports return pickings and reversal analytic lines.
- Fully compatible with analytic plans and multidimensional analytic accounting.

The module is useful for organizations needing precise analytic accounting for inventory movements, such as manufacturing, logistics, or services.

Code Analysis

Views touched (5)
XML IDNameModelTypeStatus
product_category_form_inherit product.category.form.inherit product.category xpath Inherits product.product_category_form_view
view_account_analytic_line_form_inherit view.account.analytic.line.form.inherit account.analytic.line xpath Inherits analytic.view_account_analytic_line_form
view_stock_analytic_rule_form stock.analytic.rule.form stock.analytic.rule form New
view_stock_analytic_rule_search stock.analytic.rule.search stock.analytic.rule search New
view_stock_analytic_rule_tree stock.analytic.rule.tree stock.analytic.rule tree New
Models touched (4)

New fields (1)
  • stock_move_id Many2one → stock.move
    ondelete='cascade' string='Stock Move' args: 'stock.move'
Public methods (0)

No public methods.

New fields (3)
  • avg_price Float
    digits=(16, 2) help='This field is used to store the average price of the products' string='Average Price'
  • avg_weight Float
    digits=(16, 2) help='This field is used to store the average weight of the products' string='Average Weight'
  • supplement Float
    digits=(16, 2) help='This field is used to supplement the cost of the product'
Public methods (0)

No public methods.

New fields (9)
  • active Boolean
    default=True
  • amount_compute_type Selection
    default='category' help="\n Category: The amount is computed based on the product's\n category avg price, avg weight, and supplement.\n Product: The amount is computed based on the product's price.\n " required=True string='Compute amount by' args: [('category', _('Category')), ('product', _('Product'))]
  • analytic_distribution_negative Json
    compute='_compute_analytic_distribution' copy=True readonly=False store=True args: 'Negative Analytic Distribution'
  • company_id Many2one → res.company
    default=<expr> required=True args: 'res.company'
  • financial_account_id Many2one → account.account
    domain=[('deprecated', '=', False)] help='Financial account to use for the analytic lines.' string='Financial Account' args: 'account.account'
  • include_taxes Boolean
    default=False help='If checked, the amount will include taxes when computed by product.'
  • location_dest_ids Many2many → stock.location
    string='To' args: 'stock.location', 'stock_analytic_model_location_dest_rel', 'model_id', 'location_id'
  • location_from_ids Many2many → stock.location
    string='From' args: 'stock.location', 'stock_analytic_model_location_from_rel', 'model_id', 'location_id'
  • name Char
Public methods (4)
  • action_open_form(self)
  • copy(self, default=None)
  • generate_analytic_lines(self, stock_move)
    @api.model
    Generates analytic lines based on matching stock analytic rules.
  • write(self, vals)

New fields (0)

No new fields.

Public methods (2)
  • create(self, vals_list)
    @api.model_create_multi
  • write(self, vals)