diff --git a/nfu_sale_order_batch_packaging/README.rst b/nfu_sale_order_batch_packaging/README.rst index 89030df..45c7970 100644 --- a/nfu_sale_order_batch_packaging/README.rst +++ b/nfu_sale_order_batch_packaging/README.rst @@ -33,23 +33,24 @@ and adds a packaging default to sale order batch. Changelog ========= -- 0.0.1: Initial module. -- 1.0.0: rename to nfu_sale_order_batch_packaging -- 1.1.0: Live -- 1.2.0: Add regeneration action for batch products -- 1.2.1: refactoring -- 1.3.0: add packaging states -- 1.3.1: add open_max_qty -- 1.3.2: fix color indicator -- 1.3.3: Enable packagings on installation -- 1.3.4: +- 16.0.0.0.1: Initial module. +- 16.0.1.0.0: rename to nfu_sale_order_batch_packaging +- 16.0.1.16.0.1.0: Live +- 16.0.1.2.0: Add regeneration action for batch products +- 16.0.1.2.1: refactoring +- 16.0.1.3.0: add packaging states +- 16.0.1.3.1: add open_max_qty +- 16.0.1.3.2: fix color indicator +- 16.0.1.3.3: Enable packagings on installation +- 16.0.1.3.4: - on creation set max_qty to product_uom_qty if not set - remove zero exception for max_qty - store open_packaging_qty on batch product module to make it sortable - always adjust max_qty to be at least uom_qty except you only set max qty -- 1.3.4: store all quantities and round open values -- 1.3.6: make sure packages are readable by the user -- 1.3.7: really make sure packages are readable by the user +- 16.0.1.3.4: store all quantities and round open values +- 16.0.1.3.6: make sure packages are readable by the user +- 16.0.1.3.7: really make sure packages are readable by the user +- 16.0.1.4.0: Add automatiok batch fillup Bug Tracker =========== diff --git a/nfu_sale_order_batch_packaging/__manifest__.py b/nfu_sale_order_batch_packaging/__manifest__.py index e728f96..3805122 100644 --- a/nfu_sale_order_batch_packaging/__manifest__.py +++ b/nfu_sale_order_batch_packaging/__manifest__.py @@ -4,7 +4,7 @@ "author": "BAKEUP", "website": "https://www.bakeup.org", "category": "Sale", - "version": "16.0.1.3.7", + "version": "16.0.1.4.0", "depends": ["sale", "sale_order_batch"], "data": [ "security/ir.model.access.csv", diff --git a/nfu_sale_order_batch_packaging/models/sale_order_batch.py b/nfu_sale_order_batch_packaging/models/sale_order_batch.py index 56c1ab4..c7f877d 100644 --- a/nfu_sale_order_batch_packaging/models/sale_order_batch.py +++ b/nfu_sale_order_batch_packaging/models/sale_order_batch.py @@ -22,12 +22,11 @@ class SaleOrderBatch(models.Model): for line in batch.sale_order_line_ids ) - @api.depends("product_ids.open_packaging_qty", "product_ids.open_packaging_max_qty") + @api.depends("product_ids.open_packaging_qty") def _compute_has_fillable_packages(self): for batch in self: batch.has_fillable_packages = any( - p.open_packaging_qty > 0 and p.open_packaging_max_qty == 0.0 - for p in batch.product_ids + p.open_packaging_qty > 0 for p in batch.product_ids ) def action_restore_ordered_qty(self): diff --git a/nfu_sale_order_batch_packaging/readme/HISTORY.rst b/nfu_sale_order_batch_packaging/readme/HISTORY.rst index 53a9977..df31a30 100644 --- a/nfu_sale_order_batch_packaging/readme/HISTORY.rst +++ b/nfu_sale_order_batch_packaging/readme/HISTORY.rst @@ -1,17 +1,18 @@ -- 0.0.1: Initial module. -- 1.0.0: rename to nfu_sale_order_batch_packaging -- 1.1.0: Live -- 1.2.0: Add regeneration action for batch products -- 1.2.1: refactoring -- 1.3.0: add packaging states -- 1.3.1: add open_max_qty -- 1.3.2: fix color indicator -- 1.3.3: Enable packagings on installation -- 1.3.4: +- 16.0.0.0.1: Initial module. +- 16.0.1.0.0: rename to nfu_sale_order_batch_packaging +- 16.0.1.16.0.1.0: Live +- 16.0.1.2.0: Add regeneration action for batch products +- 16.0.1.2.1: refactoring +- 16.0.1.3.0: add packaging states +- 16.0.1.3.1: add open_max_qty +- 16.0.1.3.2: fix color indicator +- 16.0.1.3.3: Enable packagings on installation +- 16.0.1.3.4: - on creation set max_qty to product_uom_qty if not set - remove zero exception for max_qty - store open_packaging_qty on batch product module to make it sortable - always adjust max_qty to be at least uom_qty except you only set max qty -- 1.3.4: store all quantities and round open values -- 1.3.6: make sure packages are readable by the user -- 1.3.7: really make sure packages are readable by the user \ No newline at end of file +- 16.0.1.3.4: store all quantities and round open values +- 16.0.1.3.6: make sure packages are readable by the user +- 16.0.1.3.7: really make sure packages are readable by the user +- 16.0.1.4.0: Add automatiok batch fillup \ No newline at end of file diff --git a/nfu_sale_order_batch_packaging/static/description/index.html b/nfu_sale_order_batch_packaging/static/description/index.html index d14fce9..012dcf4 100644 --- a/nfu_sale_order_batch_packaging/static/description/index.html +++ b/nfu_sale_order_batch_packaging/static/description/index.html @@ -388,17 +388,17 @@ and adds a packaging default to sale order batch.

Changelog

diff --git a/nfu_sale_order_batch_packaging/tests/test_batch_packaging_reconcile.py b/nfu_sale_order_batch_packaging/tests/test_batch_packaging_reconcile.py index 2b5d253..027cc1d 100644 --- a/nfu_sale_order_batch_packaging/tests/test_batch_packaging_reconcile.py +++ b/nfu_sale_order_batch_packaging/tests/test_batch_packaging_reconcile.py @@ -83,7 +83,9 @@ class TestBatchPackagingReconcile(TransactionCase): bp._reconcile_packaging(0.001) self.assertAlmostEqual(bp.open_packaging_qty, 0.0, places=2) - capped = bp.sale_order_line_ids.filtered(lambda l: l.product_uom_max_qty == 9.0) + capped = bp.sale_order_line_ids.filtered( + lambda line: line.product_uom_max_qty == 9.0 + ) # capped line must be at its max self.assertAlmostEqual(capped.product_uom_qty, 9.0, places=3) # every line must stay within its max @@ -96,7 +98,7 @@ class TestBatchPackagingReconcile(TransactionCase): # total = 7, open = 5; rooms: 3 and 5 bp = self._add_lines(product, [(3.0, 6.0), (4.0, 9.0)]) self.assertAlmostEqual(bp.open_packaging_qty, 5.0, places=2) - orig = {l.id: l.product_uom_qty for l in bp.sale_order_line_ids} + orig = {line.id: line.product_uom_qty for line in bp.sale_order_line_ids} bp._reconcile_packaging(1.0) @@ -111,7 +113,7 @@ class TestBatchPackagingReconcile(TransactionCase): # total = 7, open = 3; rooms: 7 and 6 → sorted: line2(6), line1(7) bp = self._add_lines(product, [(3.0, 10.0), (4.0, 10.0)]) self.assertAlmostEqual(bp.open_packaging_qty, 3.0, places=2) - orig = {l.id: l.product_uom_qty for l in bp.sale_order_line_ids} + orig = {line.id: line.product_uom_qty for line in bp.sale_order_line_ids} bp._reconcile_packaging(0.1) @@ -230,8 +232,8 @@ class TestBatchPackagingReconcile(TransactionCase): # reconciliation must have increased some qty self.assertTrue( any( - l.product_uom_qty != l.product_uom_ordered_qty - for l in bp.sale_order_line_ids + line.product_uom_qty != line.product_uom_ordered_qty + for line in bp.sale_order_line_ids ) ) self.batch.action_restore_ordered_qty() @@ -258,8 +260,8 @@ class TestBatchPackagingReconcile(TransactionCase): # product_b lines must be unchanged self.assertTrue( any( - l.product_uom_qty != l.product_uom_ordered_qty - for l in bp_b.sale_order_line_ids + line.product_uom_qty != line.product_uom_ordered_qty + for line in bp_b.sale_order_line_ids ) ) @@ -284,6 +286,32 @@ class TestBatchPackagingReconcile(TransactionCase): self.batch.action_restore_ordered_qty() self.assertFalse(self.batch.has_qty_adjusted) + def test_has_fillable_packages_false_when_no_open_qty(self): + """has_fillable_packages is False when all products have complete packages.""" + product = self._make_product(self.uom_kg, 10.0) + self._add_lines(product, [(10.0, 15.0)]) # qty is exact multiple of packaging + self.assertFalse(self.batch.has_fillable_packages) + + def test_has_fillable_packages_true_for_eligible(self): + """has_fillable_packages is True when an eligible product has open packaging qty.""" + product = self._make_product(self.uom_kg, 10.0) + self._add_lines(product, [(23.0, 30.0)]) # open_packaging_max_qty == 0 + self.assertTrue(self.batch.has_fillable_packages) + + def test_has_fillable_packages_true_for_ineligible(self): + """has_fillable_packages is True even for ineligible (zero-out) products.""" + product = self._make_product(self.uom_kg, 10.0) + self._add_lines( + product, [(23.0, 24.0)] + ) # max too tight → open_packaging_max_qty != 0 + self.assertGreater( + self.batch.product_ids.filtered( + lambda p: p.product_id == product + ).open_packaging_max_qty, + 0.0, + ) + self.assertTrue(self.batch.has_fillable_packages) + # ------------------------------------------------------------------ # Zero-out # ------------------------------------------------------------------ @@ -320,7 +348,7 @@ class TestBatchPackagingReconcile(TransactionCase): """Lines with keep_qty=True are not zeroed out.""" ineligible = self._make_product(self.uom_kg, 10.0) bp = self._add_lines(ineligible, [(23.0, 24.0)]) - orig_qtys = {l.id: l.product_uom_qty for l in bp.sale_order_line_ids} + orig_qtys = {line.id: line.product_uom_qty for line in bp.sale_order_line_ids} action = self.batch.action_fill_packages() wizard = self.env["sale.order.batch.packaging.reconcile"].browse( diff --git a/nfu_sale_order_batch_packaging/views/sale_order_batch_views.xml b/nfu_sale_order_batch_packaging/views/sale_order_batch_views.xml index 70f6236..ef8e13c 100644 --- a/nfu_sale_order_batch_packaging/views/sale_order_batch_views.xml +++ b/nfu_sale_order_batch_packaging/views/sale_order_batch_views.xml @@ -5,6 +5,37 @@ sale.order.batch + + + + +