Metadata-Version: 2.1
Name: odoo-addon-stock_analytic_rule
Version: 17.0.1.0.0.4
Requires-Python: >=3.10
Requires-Dist: odoo>=17.0a,<17.1dev
Summary: Adds distribution rules for stock moves to automatically create analytic lines
Home-page: https://github.com/OCA/account-analytic
License: AGPL-3
Author: Odoo Community Association (OCA), APSL-Nagarro, Bernat Obrador
Author-email: support@odoo-community.org
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 17.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Description-Content-Type: text/x-rst

.. image:: https://odoo-community.org/readme-banner-image
   :target: https://odoo-community.org/get-involved?utm_source=readme
   :alt: Odoo Community Association

===================
Stock Analytic Rule
===================

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:84034616be16bc515c383ccaf44485ab2f4b8122bd53cd580223416790dcce08
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
    :target: https://odoo-community.org/page/development-status
    :alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
    :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
    :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github
    :target: https://github.com/OCA/account-analytic/tree/17.0/stock_analytic_rule
    :alt: OCA/account-analytic
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
    :target: https://translation.odoo-community.org/projects/account-analytic-17-0/account-analytic-17-0-stock_analytic_rule
    :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
    :target: https://runboat.odoo-community.org/builds?repo=OCA/account-analytic&target_branch=17.0
    :alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

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.

**Table of contents**

.. contents::
   :local:

Usage
=====

1. Configure Product Categories

Navigate to **Inventory > Configuration > Product Categories**.

For each relevant product category, configure the following fields:

- ``Average Price``: Base cost per unit.
- ``Average Weight``: Used to scale the cost relative to quantity.
- ``Supplement``: Additional surcharge applied on top of base cost.

These values are used when the compute type is set to **Category**.

--------------

2. Define Analytic Accounts and Plans

Navigate to **Accounting > Configuration > Analytic Accounting**.

- Create one or more **Analytic Plans**.
- Create **Analytic Accounts** linked to these plans.

These accounts will be referenced in the analytic distribution logic of
each model.

--------------

3. Create Stock Analytic Rules

Navigate to **Accounting > Configuration > Stock Analytic Rules**.

Configure each rule with:

- ``Name``: Used as the label for the generated analytic lines.
- ``Source Locations`` and ``Destination Locations``: Determines when
  the model applies.
- ``Amount Compute Type``: Choose between:

  - **Product** – uses the product's list price.
  - **Category** – uses the category's formula
    ``(avg_price × weight × qty) + (weight × qty × supplement)``.

- ``Analytic Distribution`` (for positive lines)
- ``Negative Analytic Distribution`` (for negative lines)
- ``Financial Account``: Used in the generated analytic line.

📌 **Note**: The distribution for reversed moves (e.g. returns) is
automatically computed by inverting the accounts — no need to define a
separate rule.

4. Perform a Stock Move

Create a Transfer that matches the configured rule:

- It can be internal, delivery, or receipt.

- Ensure the source and destination locations match the analytic rule.

5. Review Analytic Lines

Navigate to Accounting > Accounting > Analytic Lines.

You should now see the automatically generated analytic lines reflecting
the cost and distribution defined in your model.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-analytic/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-analytic/issues/new?body=module:%20stock_analytic_rule%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* APSL-Nagarro
* Bernat Obrador

Contributors
------------

- APSL - Nagarro <https://apsl.tech>

  - Bernat Obrador

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
   :alt: Odoo Community Association
   :target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-BernatObrador| image:: https://github.com/BernatObrador.png?size=40px
    :target: https://github.com/BernatObrador
    :alt: BernatObrador

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-BernatObrador| 

This module is part of the `OCA/account-analytic <https://github.com/OCA/account-analytic/tree/17.0/stock_analytic_rule>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
