Metadata-Version: 2.1
Name: odoo-addon-stock_period_evaluation
Version: 18.0.1.0.0.4
Requires-Python: >=3.10
Requires-Dist: odoo-addon-report_xlsx==18.0.*
Requires-Dist: odoo==18.0.*
Summary: Stock evaluation with FIFO, LIFO and average methods
Home-page: https://github.com/OCA/l10n-italy
License: AGPL-3
Author: Pordenone Linux User Group (PNLUG), Odoo Community Association (OCA), Dinamiche Aziendali srl, Sergio Corato
Author-email: support@odoo-community.org
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 18.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 Period Evaluation
=======================

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

.. |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%2Fl10n--italy-lightgray.png?logo=github
    :target: https://github.com/OCA/l10n-italy/tree/18.0/stock_period_evaluation
    :alt: OCA/l10n-italy
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
    :target: https://translation.odoo-community.org/projects/l10n-italy-18-0/l10n-italy-18-0-stock_period_evaluation
    :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/l10n-italy&target_branch=18.0
    :alt: Try me on Runboat

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

**Stock Period Evaluation** is a comprehensive warehouse management
module that provides period-end stock valuation and inventory closing
capabilities for Odoo.

**Overview**

This module enables businesses to create accurate snapshots of their
inventory valuation at specific dates without disrupting daily warehouse
operations. It's particularly valuable for companies that need periodic
financial reporting, inventory audits, or cost analysis.

**Key Features**

- **Flexible Valuation Methods**: Calculate inventory value using
  multiple approaches:

  - Standard cost from product master data
  - Purchase average cost based on historical purchases
  - Category-based costing using product category settings
  - **FIFO (First In, First Out)** valuation method
  - **LIFO (Last In, First Out)** valuation method
  - Manual cost override capabilities

- **Date-Based Inventory Snapshots**:

  - Create valuations at any specific closing date
  - Track inventory changes between closing periods
  - Link consecutive periods for incremental analysis

- **Advanced Inventory Management**:

  - Location-specific stock tracking
  - Lot/serial number support
  - Owner-based stock segregation (consignment)
  - Multi-currency purchase price conversion

- **Comprehensive Reporting**:

  - Excel (XLSX) export with detailed product information
  - Customizable report columns (location, lot, owner)
  - Automatic value calculations and totals
  - Print wizard for filtered data export

- **Bulk Data Import**:

  - CSV import functionality for mass inventory updates
  - Support for European decimal formats
  - Automatic product validation

- **Performance Optimization**:

  - Optional archiving of processed stock moves
  - Efficient calculation algorithms for large datasets
  - Bypass options for negative quantities

**Business Benefits**

- Accurate period-end financial reporting without stock freezing
- Historical inventory valuation tracking for audits
- Comparison of different costing methods
- Support for multi-location and multi-company operations

**Table of contents**

.. contents::
   :local:

Configuration
=============

**User Access Configuration**

1. **Security Groups**:

   - **Stock Period Evaluation Manager**
     (``stock_period_evaluation.group_stock_period_evaluation_manager``):

     - Full access to create, edit, validate, and delete closing periods
     - Access to import wizard and all reporting functions
     - Can force evaluation methods for cost calculation

   - **Stock Period Evaluation User Read Only**
     (``stock_period_evaluation.group_stock_period_evaluation_user_readonly``):

     - View-only access to closing periods and reports
     - Cannot modify or create new periods

2. **User Assignment**:

   Go to *Settings > Users & Companies > Users*:

   - Select the user to configure
   - Assign appropriate Stock Period Evaluation group

**System Parameters**

The module uses a system parameter for default configuration:

- **Default Last Close Date**:
  ``stock_period_evaluation.last_close_date``

  - Default value: 2010-01-01
  - Can be modified via *Settings > Technical > System Parameters*
  - Used when no previous closing period is selected

**Performance Settings**

Consider these optional configurations for large databases:

- **Bypass Negative Quantities**: Enable to skip products with negative
  stock during calculations
- **No Recompute Lines**: Skip recalculation of quantities for existing
  lines to improve performance

Usage
=====

**Creating a Stock Closing Period**

1. Navigate to *Inventory > Stock Period Evaluation > Stock Period
   Evaluation*
2. Click **Create** to start a new closing period
3. Configure the following fields:

   - **Reference**: Enter a unique name for this closing (e.g., "2024-Q1
     Closing")
   - **Close Date**: Select the date for inventory valuation
   - **Force Evaluation Method**: Choose the costing approach:

     - *Compute based on category setup*: Uses product category
       configuration
     - *Compute based on purchase average cost*: Calculates from
       purchase history
     - *Compute based on cost in product*: Uses standard product cost
     - *Compute based on FIFO*: First In, First Out valuation
     - *Compute based on LIFO (continuous)*: Last In, First Out
       valuation

   - **Last Closed** (optional): Link to previous period for incremental
     calculations
   - **Bypass Negative Quantity**: Enable to ignore products with
     negative stock

**Processing Workflow**

1. **Start - Calculate Quantities**:

   - Click the **Start** button to begin processing
   - System calculates product quantities at the closing date
   - Review and manually adjust quantities if needed (e.g., for
     consignment stock)
   - The state changes to "In Progress"

2. **Compute Purchase Costs**:

   - Click **Compute Purchase** to calculate product costs
   - System applies the selected evaluation method
   - For purchase average: calculates from purchase orders between
     periods
   - Process may take time for large inventories

3. **Manual Adjustments** (if needed):

   - Edit individual line items for cost corrections
   - Modify quantities for special cases
   - Add notes or references as needed

4. **Validation**:

   - Review the total stock amount value
   - Click **Validate** to finalize the closing
   - State changes to "Validated"
   - Period becomes read-only

**Using CSV Import**

For bulk inventory data import:

1. Navigate to *Inventory > Stock Period Evaluation > Stock Period
   Import*

2. Select the target **Stock Period Evaluation**

3. Prepare CSV file with semicolon-separated format:

   .. code:: text

      CODE;COST;QTY
      PROD001;15,50;100,00
      PROD002;8,25;250,50
      PROD003;102,00;50,00

   - CODE: Product default code (must exist in system)
   - COST: Unit cost (comma or dot as decimal separator)
   - QTY: Quantity (comma or dot as decimal separator)

4. Upload the file and click **Import**

5. System validates products and creates closing lines

6. The period is automatically marked as "done"

**Understanding Valuation Methods: LIFO, FIFO, and Weighted Average**

The module supports three main inventory valuation methods. Here's a
practical example showing how each method calculates costs using
identical transactions:

**LIFO Method (Last In, First Out)**

LIFO assumes that the most recently purchased items are sold first. This
method values ending inventory using the oldest costs.

+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| Date       | Operation     | Qty | Balance | Unit Cost | Total  | Prog    | LIFO Avg  |
|            |               |     |         |           | Cost   | Cost    | Cost      |
+============+===============+=====+=========+===========+========+=========+===========+
| 15/11/2023 | Purchase      | 10  | 10      | 3.00      | 30     | 30      | 3.00      |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 15/12/2023 | Purchase      | 10  | 20      | 7.00      | 70     | 100     | 5.00      |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 31/12/2023 | Opening Inv   | 20  | 20      | 5.00      | 100    | 100     | 5.00      |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 31/10/2024 | Purchase      | 10  | 30      | 7.00      | 70     | 170     | 5.67      |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 15/11/2024 | Purchase      | 10  | 40      | 10.00     | 100    | 270     | 6.75      |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 30/11/2024 | Sale          | -10 | 30      | 10.00     | -100   | 170     | -         |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 30/11/2024 | Sale          | -10 | 20      | 7.00      | -70    | 100     | -         |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 30/11/2024 | Sale          | -10 | 10      | 5.00      | -50    | 50      | 5.00      |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 02/12/2024 | Purchase      | 15  | 25      | 12.00     | 180    | 230     | 9.20      |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 03/12/2024 | Sale          | -5  | 20      | 12.00     | -60    | 170     | 8.50      |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 04/12/2024 | Purchase      | 10  | 30      | 15.00     | 150    | 320     | 10.67     |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| **Final**  | **Inventory** | 30  | 30      | **15.00** | **0**  | **320** | **10.67** |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+

*Final LIFO inventory value: €320 (30 units @ €10.67 average)*

**FIFO Method (First In, First Out)**

FIFO assumes that the oldest purchased items are sold first. This method
values ending inventory using the most recent costs.

+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| Date       | Operation     | Qty | Balance | Unit Cost | Total  | Prog    | FIFO Avg  |
|            |               |     |         |           | Cost   | Cost    | Cost      |
+============+===============+=====+=========+===========+========+=========+===========+
| 31/12/2023 | Opening Inv   | 20  | 20      | 5.00      | 100    | 100     | 5.00      |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 31/10/2024 | Purchase      | 10  | 30      | 7.00      | 70     | 170     | 5.67      |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 15/11/2024 | Purchase      | 10  | 40      | 10.00     | 100    | 270     | 6.75      |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 30/11/2024 | Sale          | -10 | 30      | 5.00      | -50    | 220     | -         |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 30/11/2024 | Sale          | -10 | 20      | 5.00      | -50    | 170     | -         |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 30/11/2024 | Sale          | -10 | 10      | 7.00      | -70    | 100     | 10.00     |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 02/12/2024 | Purchase      | 15  | 25      | 12.00     | 180    | 280     | 11.20     |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 03/12/2024 | Sale          | -5  | 20      | 10.00     | -50    | 230     | 11.50     |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| 04/12/2024 | Purchase      | 10  | 30      | 15.00     | 150    | 380     | 12.67     |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+
| **Final**  | **Inventory** | 30  | 30      | **15.00** | **0**  | **380** | **12.67** |
+------------+---------------+-----+---------+-----------+--------+---------+-----------+

*Final FIFO inventory value: €380 (30 units @ €12.67 average)*

**Weighted Average Method**

The weighted average method calculates a new average cost after each
purchase, which is then applied to all units in inventory.

+------------+---------------+-----+---------+-------+-------+-------+---------+----------+
| Date       | Operation     | Qty | Balance | Purch | Unit  | Total | Prog    | Avg Cost |
|            |               |     |         | Bal   | Cost  | Cost  | Cost    |          |
+============+===============+=====+=========+=======+=======+=======+=========+==========+
| 31/12/2023 | Opening Inv   | 20  | 20      | 20    | 5.00  | 100   | 100     | 5.00     |
+------------+---------------+-----+---------+-------+-------+-------+---------+----------+
| 31/10/2024 | Purchase      | 10  | 30      | 30    | 7.00  | 70    | 170     | -        |
+------------+---------------+-----+---------+-------+-------+-------+---------+----------+
| 15/11/2024 | Purchase      | 10  | 40      | 40    | 10.00 | 100   | 270     | 6.75     |
+------------+---------------+-----+---------+-------+-------+-------+---------+----------+
| 30/11/2024 | Sale          | -10 | 30      | 40    | -     | -     | 270     | -        |
+------------+---------------+-----+---------+-------+-------+-------+---------+----------+
| 30/11/2024 | Sale          | -10 | 20      | 40    | -     | -     | 270     | -        |
+------------+---------------+-----+---------+-------+-------+-------+---------+----------+
| 30/11/2024 | Sale          | -10 | 10      | 40    | -     | -     | 270     | 6.75     |
+------------+---------------+-----+---------+-------+-------+-------+---------+----------+
| 02/12/2024 | Purchase      | 15  | 25      | 55    | 12.00 | 180   | 450     | 8.18     |
+------------+---------------+-----+---------+-------+-------+-------+---------+----------+
| 03/12/2024 | Sale          | -5  | 20      | 55    | -     | -     | 450     | 8.18     |
+------------+---------------+-----+---------+-------+-------+-------+---------+----------+
| 04/12/2024 | Purchase      | 10  | 30      | 65    | 15.00 | 150   | 600     | 9.23     |
+------------+---------------+-----+---------+-------+-------+-------+---------+----------+
| **Final**  | **Inventory** | 30  | 30      | 65    | -     | **0** | **600** | **9.23** |
+------------+---------------+-----+---------+-------+-------+-------+---------+----------+

*Final weighted average inventory value: €277 (30 units @ €9.23
average)*

**Comparison of Methods**

Using the same transaction history, the three methods produce different
results:

- **LIFO**: €320 total value (€10.67/unit) - Reflects most recent
  purchase costs
- **FIFO**: €380 total value (€12.67/unit) - Reflects current
  replacement costs
- **Weighted Average**: €277 total value (€9.23/unit) - Smooths price
  fluctuations

**Key Observations:**

1. **LIFO** assumes newest items sold first, leaving older (cheaper)
   items in inventory
2. **FIFO** assumes oldest items sold first, leaving newer (more
   expensive) items in inventory
3. **Weighted Average** recalculates average cost after each purchase

The choice significantly impacts:

- Balance sheet inventory valuation
- Cost of goods sold (COGS) calculation
- Gross profit and taxable income
- Cash flow from operations

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-italy/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/l10n-italy/issues/new?body=module:%20stock_period_evaluation%0Aversion:%2018.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
-------

* Pordenone Linux User Group (PNLUG)
* Dinamiche Aziendali srl
* Sergio Corato

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

- Pordenone Linux User Group (PNLUG)
- Marco Calcagni - Dinamiche Aziendali srl
  <mcalcagni@dinamicheaziendali.it>
- Giuseppe Borruso - Dinamiche Aziendali srl
  <gborruso@dinamicheaziendali.it>
- Sergio Corato <sergiocorato@gmail.com>
- Lorenzo Battistini

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-MarcoCalcagni| image:: https://github.com/MarcoCalcagni.png?size=40px
    :target: https://github.com/MarcoCalcagni
    :alt: MarcoCalcagni
.. |maintainer-Borruso| image:: https://github.com/Borruso.png?size=40px
    :target: https://github.com/Borruso
    :alt: Borruso

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

|maintainer-MarcoCalcagni| |maintainer-Borruso| 

This module is part of the `OCA/l10n-italy <https://github.com/OCA/l10n-italy/tree/18.0/stock_period_evaluation>`_ project on GitHub.

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