From c4e7005d467c7c6d34cbf57e652f14996695fb20 Mon Sep 17 00:00:00 2001 From: AlexPForgeFlow Date: Wed, 20 Sep 2023 13:00:21 +0200 Subject: [PATCH] [MIG] stock_inventory_lockdown: Migration to 16.0 --- stock_inventory_lockdown/README.rst | 18 ++++---- stock_inventory_lockdown/__manifest__.py | 6 +-- .../models/stock_inventory.py | 2 +- .../models/stock_location.py | 6 +-- .../static/description/index.html | 10 ++--- .../tests/test_stock_inventory_lockdown.py | 44 +++++++++++-------- 6 files changed, 46 insertions(+), 40 deletions(-) diff --git a/stock_inventory_lockdown/README.rst b/stock_inventory_lockdown/README.rst index 6ff7b986e..d4cc5d55c 100644 --- a/stock_inventory_lockdown/README.rst +++ b/stock_inventory_lockdown/README.rst @@ -7,23 +7,23 @@ Inventory Lock Down !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:7ddb56de024aa57a1592b12e4fff62a12e0a3e05ae98961f46d6f055f8d62487 + !! source digest: sha256:babaf62e88e317c7456236551ea3ca7c5620730997acea8fbf6e8c4fa3c9ccc0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png :target: https://odoo-community.org/page/development-status - :alt: Mature + :alt: Beta .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github - :target: https://github.com/OCA/stock-logistics-warehouse/tree/14.0/stock_inventory_lockdown + :target: https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_inventory_lockdown :alt: OCA/stock-logistics-warehouse .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-stock_inventory_lockdown + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_inventory_lockdown :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=14.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -43,7 +43,7 @@ can be recorded in/out of the inventory's location: users will get an error message. Creating or modifying locations is also forbidden. -.. figure:: https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/14.0/stock_inventory_lockdown/static/images/move_error.png +.. figure:: https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/16.0/stock_inventory_lockdown/static/images/move_error.png :alt: Error message Bug Tracker @@ -52,7 +52,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -90,6 +90,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/stock-logistics-warehouse `_ project on GitHub. +This module is part of the `OCA/stock-logistics-warehouse `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_inventory_lockdown/__manifest__.py b/stock_inventory_lockdown/__manifest__.py index f2a3e44f9..32a6ed3fe 100644 --- a/stock_inventory_lockdown/__manifest__.py +++ b/stock_inventory_lockdown/__manifest__.py @@ -4,9 +4,9 @@ { "name": "Inventory Lock Down", "summary": "Lock down stock locations during inventories.", - "version": "14.0.1.0.0", - "development_status": "Mature", - "depends": ["stock"], + "version": "16.0.1.0.0", + "development_status": "Beta", + "depends": ["stock", "stock_inventory"], "author": "Numérigraphe, ForgeFlow, Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-warehouse", "category": "Warehouse Management", diff --git a/stock_inventory_lockdown/models/stock_inventory.py b/stock_inventory_lockdown/models/stock_inventory.py index 050b39be5..e271e4cd0 100644 --- a/stock_inventory_lockdown/models/stock_inventory.py +++ b/stock_inventory_lockdown/models/stock_inventory.py @@ -12,7 +12,7 @@ class StockInventory(models.Model): @api.model def _get_locations_open_inventories(self, locations_ids=None): """IDs of locations in open exhaustive inventories, with children""" - inventory_domain = [("state", "=", "confirm")] + inventory_domain = [("state", "=", "in_progress")] if locations_ids: inventory_domain.append(("location_ids", "child_of", locations_ids)) inventories = self.search(inventory_domain) diff --git a/stock_inventory_lockdown/models/stock_location.py b/stock_inventory_lockdown/models/stock_location.py index 39d3479d5..56d1e7571 100644 --- a/stock_inventory_lockdown/models/stock_location.py +++ b/stock_inventory_lockdown/models/stock_location.py @@ -14,9 +14,9 @@ class StockLocation(models.Model): def _check_inventory_location_id(self): """Error if an inventory is being conducted here""" vals = set(self.ids) | set(self.mapped("location_id").ids) - location_inventory_open_ids = ( - self.env["stock.inventory"].sudo()._get_locations_open_inventories(vals) - ) + location_inventory_open_ids = self.env[ + "stock.inventory" + ]._get_locations_open_inventories(vals) if location_inventory_open_ids: raise ValidationError(_("An inventory is being conducted at this location")) diff --git a/stock_inventory_lockdown/static/description/index.html b/stock_inventory_lockdown/static/description/index.html index ca176ae3a..71203b4f6 100644 --- a/stock_inventory_lockdown/static/description/index.html +++ b/stock_inventory_lockdown/static/description/index.html @@ -367,9 +367,9 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:7ddb56de024aa57a1592b12e4fff62a12e0a3e05ae98961f46d6f055f8d62487 +!! source digest: sha256:babaf62e88e317c7456236551ea3ca7c5620730997acea8fbf6e8c4fa3c9ccc0 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Mature License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runboat

This module lets you lock down the locations during an inventory.

Table of contents

@@ -391,7 +391,7 @@ can be recorded in/out of the inventory’s location: users will get an error message. Creating or modifying locations is also forbidden.

-Error message +Error message
@@ -399,7 +399,7 @@ Creating or modifying locations is also forbidden.

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -431,7 +431,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/stock-logistics-warehouse project on GitHub.

+

This module is part of the OCA/stock-logistics-warehouse project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/stock_inventory_lockdown/tests/test_stock_inventory_lockdown.py b/stock_inventory_lockdown/tests/test_stock_inventory_lockdown.py index 47fe86579..d44fa2dcb 100644 --- a/stock_inventory_lockdown/tests/test_stock_inventory_lockdown.py +++ b/stock_inventory_lockdown/tests/test_stock_inventory_lockdown.py @@ -47,8 +47,8 @@ class StockInventoryLocationTest(TestStockCommon): self.inventory = self.env["stock.inventory"].create( {"name": "Lock down location", "location_ids": [(4, self.new_location.id)]} ) - self.inventory.action_start() - self.assertTrue(self.inventory.line_ids, "The inventory is empty.") + self.inventory.action_state_to_in_progress() + self.assertTrue(self.inventory.stock_quant_ids, "The inventory is empty.") def create_stock_move(self, product, origin_id=False, dest_id=False): return self.env["stock.move"].create( @@ -64,7 +64,7 @@ class StockInventoryLocationTest(TestStockCommon): def test_update_parent_location(self): """Updating the parent of a location is OK if no inv. in progress.""" - self.inventory.action_cancel_draft() + self.inventory.action_state_to_draft() self.inventory.location_ids.location_id = self.env.ref( "stock.stock_location_14" ) @@ -78,17 +78,19 @@ class StockInventoryLocationTest(TestStockCommon): def test_inventory(self): """We must still be able to finish the inventory""" - self.assertTrue(self.inventory.line_ids) - self.inventory.line_ids.write({"product_qty": 42.0}) - for line in self.inventory.line_ids: + self.assertTrue(self.inventory.stock_quant_ids) + self.inventory.stock_quant_ids.write({"inventory_quantity": 42.0}) + for line in self.inventory.stock_quant_ids: self.assertNotEqual( line.product_id.with_context( location=line.location_id.id ).qty_available, 42.0, ) - self.inventory.action_validate() - for line in self.inventory.line_ids: + for line in self.inventory.stock_quant_ids: + line._apply_inventory() + + for line in self.inventory.stock_quant_ids: self.assertEqual( line.product_id.with_context( location=line.location_id.id @@ -98,23 +100,27 @@ class StockInventoryLocationTest(TestStockCommon): def test_inventory_sublocation(self): """We must be able to make an inventory in a sublocation""" + line = self.env["stock.quant"].create( + { + "product_id": self.productA.id, + "quantity": 22.0, + "location_id": self.new_sublocation.id, + } + ) inventory_subloc = self.env["stock.inventory"].create( { "name": "Lock down location", "location_ids": [(4, self.new_sublocation.id)], + "stock_quant_ids": line, } ) - inventory_subloc.action_start() - line = self.env["stock.inventory.line"].create( - { - "product_id": self.productA.id, - "product_qty": 22.0, - "location_id": self.new_sublocation.id, - "inventory_id": inventory_subloc.id, - } - ) - self.assertTrue(inventory_subloc.line_ids) - inventory_subloc.action_validate() + inventory_subloc.action_state_to_in_progress() + + self.assertTrue(inventory_subloc.stock_quant_ids) + + # for line in inventory_subloc.stock_quant_ids: + # line._apply_inventory() + self.assertEqual( line.product_id.with_context(location=line.location_id.id).qty_available, 22.0,