From 1ab12f3e87ca18e14ce3069a14b5392cab927c63 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Sun, 30 Jun 2024 19:16:05 +0200 Subject: [PATCH] Display lot of counted inventory line Closes #13083 --- modules/stock_lot/__init__.py | 1 + modules/stock_lot/stock.py | 15 ++++++++++++++- modules/stock_lot/stock.xml | 6 ++++++ .../view/inventory_count_quantity_form.xml | 9 +++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 modules/stock_lot/view/inventory_count_quantity_form.xml diff --git a/modules/stock_lot/__init__.py b/modules/stock_lot/__init__.py index 2021916f1e..3f5c5dd919 100644 --- a/modules/stock_lot/__init__.py +++ b/modules/stock_lot/__init__.py @@ -29,6 +29,7 @@ def register(): stock.Inventory, stock.InventoryLine, stock.InventoryCountSearch, + stock.InventoryCountQuantity, product.Configuration, product.ConfigurationDefaultLotSequence, product.Template, diff --git a/modules/stock_lot/stock.py b/modules/stock_lot/stock.py index 0398014bb7..2d1bacef12 100644 --- a/modules/stock_lot/stock.py +++ b/modules/stock_lot/stock.py @@ -888,6 +888,7 @@ class InventoryCount(metaclass=PoolMeta): def default_quantity(self, fields): pool = Pool() Product = pool.get('product.product') + InventoryLine = pool.get('stock.inventory.line') inventory = self.record if isinstance(self.search.search, Product): product = self.search.search @@ -896,7 +897,10 @@ class InventoryCount(metaclass=PoolMeta): raise RequiredValidationError( gettext('stock_lot.msg_only_lot', product=product.rec_name)) - return super(InventoryCount, self).default_quantity(fields) + values = super(InventoryCount, self).default_quantity(fields) + line = InventoryLine(values['line']) + values['lot'] = line.lot.id if line.lot else None + return values def get_line_domain(self, inventory): pool = Pool() @@ -924,3 +928,12 @@ class InventoryCountSearch(metaclass=PoolMeta): def __setup__(cls): super(InventoryCountSearch, cls).__setup__() cls.search.selection.append(('stock.lot', "Lot")) + + +class InventoryCountQuantity(ModelView): + __name__ = 'stock.inventory.count.quantity' + + lot = fields.Many2One('stock.lot', "Lot", readonly=True, + states={ + 'invisible': ~Eval('lot', None), + }) diff --git a/modules/stock_lot/stock.xml b/modules/stock_lot/stock.xml index e43ecdf69a..000a89d8d0 100644 --- a/modules/stock_lot/stock.xml +++ b/modules/stock_lot/stock.xml @@ -417,5 +417,11 @@ this repository contains the full copyright notices and license terms. --> inventory_line_tree + + stock.inventory.count.quantity + + inventory_count_quantity_form + + diff --git a/modules/stock_lot/view/inventory_count_quantity_form.xml b/modules/stock_lot/view/inventory_count_quantity_form.xml new file mode 100644 index 0000000000..6882aa4ecc --- /dev/null +++ b/modules/stock_lot/view/inventory_count_quantity_form.xml @@ -0,0 +1,9 @@ + + + + + +