From 91641c7c8866ecc4e88fb91b1e62c34182c72380 Mon Sep 17 00:00:00 2001 From: luis Date: Tue, 7 Oct 2025 11:33:25 +0200 Subject: [PATCH] Criptomart/red-supermercados-coop#2 stock_inventory_category_concurrency: store product_category_id in stock.quants. Add search and group_by categories --- .../__manifest__.py | 4 +++- .../i18n/es.po | 18 ++++++++++++++++++ .../stock_inventory_category_concurrency.pot | 18 ++++++++++++++++++ .../models/stock_inventory.py | 19 ++++++++++++------- .../views/stock_quant_view.xml | 13 +++++++++++++ 5 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 stock_inventory_category_concurrency/i18n/es.po create mode 100644 stock_inventory_category_concurrency/i18n/stock_inventory_category_concurrency.pot create mode 100644 stock_inventory_category_concurrency/views/stock_quant_view.xml diff --git a/stock_inventory_category_concurrency/__manifest__.py b/stock_inventory_category_concurrency/__manifest__.py index 3cefe03..d92e23d 100644 --- a/stock_inventory_category_concurrency/__manifest__.py +++ b/stock_inventory_category_concurrency/__manifest__.py @@ -7,6 +7,8 @@ "license": "AGPL-3", "author": "Criptomart", "depends": ["stock_inventory"], - "data": [], + "data": [ + "views/stock_quant_view.xml", + ], "installable": True, } diff --git a/stock_inventory_category_concurrency/i18n/es.po b/stock_inventory_category_concurrency/i18n/es.po new file mode 100644 index 0000000..102eb94 --- /dev/null +++ b/stock_inventory_category_concurrency/i18n/es.po @@ -0,0 +1,18 @@ +# Traducciones para stock_inventory_category_concurrency +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-10-07 00:00+0000\n" +"PO-Revision-Date: 2025-10-07 00:00+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_inventory_category_concurrency +#: model_terms:ir.ui.view,arch_db:stock_inventory_category_concurrency.stock_quant_search_category_filter +msgid "Product Category" +msgstr "Categoría de producto" diff --git a/stock_inventory_category_concurrency/i18n/stock_inventory_category_concurrency.pot b/stock_inventory_category_concurrency/i18n/stock_inventory_category_concurrency.pot new file mode 100644 index 0000000..d2e1655 --- /dev/null +++ b/stock_inventory_category_concurrency/i18n/stock_inventory_category_concurrency.pot @@ -0,0 +1,18 @@ +# Translation template for stock_inventory_category_concurrency +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-10-07 00:00+0000\n" +"PO-Revision-Date: 2025-10-07 00:00+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_inventory_category_concurrency +#: model_terms:ir.ui.view,arch_db:stock_inventory_category_concurrency.stock_quant_search_category_filter +msgid "Product Category" +msgstr "" diff --git a/stock_inventory_category_concurrency/models/stock_inventory.py b/stock_inventory_category_concurrency/models/stock_inventory.py index 93f8f33..4b83067 100644 --- a/stock_inventory_category_concurrency/models/stock_inventory.py +++ b/stock_inventory_category_concurrency/models/stock_inventory.py @@ -1,18 +1,23 @@ -from odoo import _, models +from odoo import _, models, fields from odoo.exceptions import ValidationError +class StockQuant(models.Model): + _inherit = "stock.quant" + + product_categ_id = fields.Many2one( + related="product_tmpl_id.categ_id", + store=True, + index=True, + string="Product Category", + ) + + class InventoryAdjustmentsGroup(models.Model): _inherit = "stock.inventory" def action_state_to_in_progress(self): - """ - Relaja el bloqueo por categoría: si el ajuste actual es por categoría, - solo bloquea otros ajustes en progreso que afecten a la MISMA categoría exacta, - no a categorías hermanas distintas ni a todas sus hijas. - """ self.ensure_one() - # Reusar la lógica original, pero parchear el caso de category search_filter = [ ( "location_id", diff --git a/stock_inventory_category_concurrency/views/stock_quant_view.xml b/stock_inventory_category_concurrency/views/stock_quant_view.xml new file mode 100644 index 0000000..92baaf4 --- /dev/null +++ b/stock_inventory_category_concurrency/views/stock_quant_view.xml @@ -0,0 +1,13 @@ + + + + stock.quant.search.category.filter + stock.quant + + + + + + + + \ No newline at end of file