Criptomart/red-supermercados-coop#6 add stock_valuation_layer_category_groupby
This commit is contained in:
parent
18f98defeb
commit
19af717773
8 changed files with 167 additions and 0 deletions
57
stock_valuation_layer_category_groupby/README.md
Normal file
57
stock_valuation_layer_category_groupby/README.md
Normal 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
|
||||
1
stock_valuation_layer_category_groupby/__init__.py
Normal file
1
stock_valuation_layer_category_groupby/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from . import models
|
||||
13
stock_valuation_layer_category_groupby/__manifest__.py
Normal file
13
stock_valuation_layer_category_groupby/__manifest__.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Copyright 2025 Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
{
|
||||
"name": "Stock Valuation Layer Category Groupby",
|
||||
"version": "16.0.1.0.0",
|
||||
"summary": "Allow grouping by product category in stock valuation layer reports",
|
||||
"license": "AGPL-3",
|
||||
"author": "Criptomart",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
"depends": ["stock_account"],
|
||||
"data": ["views/stock_valuation_layer_views.xml"],
|
||||
"installable": True,
|
||||
}
|
||||
32
stock_valuation_layer_category_groupby/i18n/es.po
Normal file
32
stock_valuation_layer_category_groupby/i18n/es.po
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * stock_valuation_layer_category_groupby
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-12-04 17:24+0000\n"
|
||||
"PO-Revision-Date: 2025-12-04 17:24+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: stock_valuation_layer_category_groupby
|
||||
#: model:ir.model.fields,field_description:stock_valuation_layer_category_groupby.field_stock_valuation_layer__categ_id
|
||||
#: model_terms:ir.ui.view,arch_db:stock_valuation_layer_category_groupby.view_inventory_valuation_search_category
|
||||
msgid "Product Category"
|
||||
msgstr "Categoría de producto"
|
||||
|
||||
#. module: stock_valuation_layer_category_groupby
|
||||
#: model:ir.model.fields,field_description:stock_valuation_layer_category_groupby.field_stock_valuation_layer__smart_search
|
||||
msgid "Smart Search"
|
||||
msgstr "Búsqueda inteligente"
|
||||
|
||||
#. module: stock_valuation_layer_category_groupby
|
||||
#: model:ir.model,name:stock_valuation_layer_category_groupby.model_stock_valuation_layer
|
||||
msgid "Stock Valuation Layer"
|
||||
msgstr "Nivel de Valoración de Existencias"
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * stock_valuation_layer_category_groupby
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-12-04 17:24+0000\n"
|
||||
"PO-Revision-Date: 2025-12-04 17:24+0000\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: stock_valuation_layer_category_groupby
|
||||
#: model:ir.model.fields,field_description:stock_valuation_layer_category_groupby.field_stock_valuation_layer__categ_id
|
||||
#: model_terms:ir.ui.view,arch_db:stock_valuation_layer_category_groupby.view_inventory_valuation_search_category
|
||||
msgid "Product Category"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_valuation_layer_category_groupby
|
||||
#: model:ir.model.fields,field_description:stock_valuation_layer_category_groupby.field_stock_valuation_layer__smart_search
|
||||
msgid "Smart Search"
|
||||
msgstr ""
|
||||
|
||||
#. module: stock_valuation_layer_category_groupby
|
||||
#: model:ir.model,name:stock_valuation_layer_category_groupby.model_stock_valuation_layer
|
||||
msgid "Stock Valuation Layer"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1 @@
|
|||
from . import stock_valuation_layer
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Copyright 2025 Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class StockValuationLayer(models.Model):
|
||||
_inherit = "stock.valuation.layer"
|
||||
|
||||
# Make categ_id stored to allow grouping in reports
|
||||
categ_id = fields.Many2one(store=True, index=True)
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<!-- Add Product Category to group by options -->
|
||||
<record id="view_inventory_valuation_search_category" model="ir.ui.view">
|
||||
<field name="name">stock.valuation.layer.search.category</field>
|
||||
<field name="model">stock.valuation.layer</field>
|
||||
<field name="inherit_id" ref="stock_account.view_inventory_valuation_search" />
|
||||
<field name="arch" type="xml">
|
||||
<filter name="group_by_product_id" position="after">
|
||||
<filter
|
||||
string="Product Category"
|
||||
name="group_by_categ_id"
|
||||
context="{'group_by': 'categ_id'}"
|
||||
/>
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue