Criptomart/red-supermercados-coop#6 add stock_valuation_layer_category_groupby

This commit is contained in:
Luis 2025-12-04 18:28:18 +01:00
parent 18f98defeb
commit 19af717773
8 changed files with 167 additions and 0 deletions

View file

@ -0,0 +1,57 @@
# Stock Valuation Layer Category Groupby
## Description
This module allows grouping by product category in the stock valuation layer reports.
### Problem
By default, the `categ_id` field in `stock.valuation.layer` is a related field without storage (`store=False`). This means it cannot be used for grouping in reports and pivot views, even though it can be used for filtering and searching.
### Solution
This module makes the `categ_id` field stored (`store=True`) and indexed, which enables:
- Grouping by product category in list views
- Grouping by product category in pivot views
- Grouping by product category in graph views
- Better performance when filtering by category
## Installation
1. Install the module from the Apps menu
2. The field will be automatically populated for existing records
## Usage
After installation:
1. Go to Inventory > Reporting > Inventory Valuation
2. Switch to Pivot or Graph view
3. Click on "Measures" or group options
4. You will now see "Product Category" available for grouping
## Technical Details
The module extends `stock.valuation.layer` model and modifies the `categ_id` field to:
- `store=True`: Store the value in the database
- `index=True`: Add database index for better performance
The field remains a related field, so it will automatically update when the product category changes.
## Bug Tracker
Bugs are tracked on [GitHub Issues](https://github.com/OCA/stock-logistics-warehouse/issues).
## Credits
### Contributors
* Criptomart
### Maintainers
This module is maintained by the OCA.
## Compatibility
- Odoo 16.0
- stock_account