From 89e3ad6791343b9272ad43a5dd1bb1caee8df68b Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Wed, 12 Sep 2018 16:52:42 +0200 Subject: [PATCH] [11.0][MIG] stock_inventory_lockdown --- stock_inventory_lockdown/README.rst | 70 +++++++++++++------ stock_inventory_lockdown/__init__.py | 4 -- stock_inventory_lockdown/__manifest__.py | 7 +- stock_inventory_lockdown/models/__init__.py | 4 -- .../models/stock_inventory.py | 1 - .../models/stock_location.py | 1 - stock_inventory_lockdown/models/stock_move.py | 7 +- .../readme/CONTRIBUTORS.rst | 6 ++ .../readme/DESCRIPTION.rst | 1 + stock_inventory_lockdown/readme/USAGE.rst | 7 ++ stock_inventory_lockdown/tests/__init__.py | 4 -- .../tests/test_stock_inventory_lockdown.py | 37 +++++----- 12 files changed, 88 insertions(+), 61 deletions(-) create mode 100644 stock_inventory_lockdown/readme/CONTRIBUTORS.rst create mode 100644 stock_inventory_lockdown/readme/DESCRIPTION.rst create mode 100644 stock_inventory_lockdown/readme/USAGE.rst diff --git a/stock_inventory_lockdown/README.rst b/stock_inventory_lockdown/README.rst index 2acf8af38..04f4f5490 100644 --- a/stock_inventory_lockdown/README.rst +++ b/stock_inventory_lockdown/README.rst @@ -1,40 +1,65 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 +=================== +Inventory Lock Down +=================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png + :target: https://odoo-community.org/page/development-status + :alt: Mature +.. |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/11.0/stock_inventory_lockdown + :alt: OCA/stock-logistics-warehouse +.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/153/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| -====================================== -Lock down locations during inventories -====================================== This module lets you lock down the locations during an inventory. +**Table of contents** + +.. contents:: + :local: + Usage ===== -.. image:: stock_inventory_lockdown/static/images/move_error.png - :alt: Error message - While an inventory is in the state "In progress", no stock moves can be recorded in/out of the inventory's location: users will get an error message. Creating or modifying locations is also forbidden. -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/153/10.0 +.. image:: stock_inventory_lockdown/static/images/move_error.png + :alt: Error message 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 smashing it by providing a detailed and welcomed feedback. +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 smashing it by providing a detailed and welcomed feedback. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Numérigraphe +* Eficent + Contributors ------------- +~~~~~~~~~~~~ * Loïc Bellier (Numérigraphe) * Lionel Sausin (Numérigraphe) @@ -43,18 +68,19 @@ Contributors * Lois Rilo (Eficent) * Jordi Ballester (Eficent) +Maintainers +~~~~~~~~~~~ -Maintainer ----------- +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - 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. -To contribute to this module, please visit https://odoo-community.org. +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/__init__.py b/stock_inventory_lockdown/__init__.py index ef0c464f0..0650744f6 100644 --- a/stock_inventory_lockdown/__init__.py +++ b/stock_inventory_lockdown/__init__.py @@ -1,5 +1 @@ -# -*- coding: utf-8 -*- -# © 2013-2016 Numérigraphe SARL -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - from . import models diff --git a/stock_inventory_lockdown/__manifest__.py b/stock_inventory_lockdown/__manifest__.py index 1d458eecd..153fcf5a3 100644 --- a/stock_inventory_lockdown/__manifest__.py +++ b/stock_inventory_lockdown/__manifest__.py @@ -1,17 +1,18 @@ -# -*- coding: utf-8 -*- # © 2013-2016 Numérigraphe SARL # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Inventory Lock Down", "summary": "Lock down stock locations during inventories.", - "version": "10.0.1.0.1", + "version": "11.0.1.0.0", + "development_status": "Mature", "depends": ["stock"], "author": "Numérigraphe, Eficent, Odoo Community Association (OCA)", "category": "Warehouse Management", "images": [ "images/move_error.png", - "images/location_locked.png"], + "images/location_locked.png", + ], "license": "AGPL-3", "installable": True, } diff --git a/stock_inventory_lockdown/models/__init__.py b/stock_inventory_lockdown/models/__init__.py index dfae546a6..644da5f35 100644 --- a/stock_inventory_lockdown/models/__init__.py +++ b/stock_inventory_lockdown/models/__init__.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- -# © 2013-2016 Numérigraphe SARL -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - from . import stock_move from . import stock_inventory from . import stock_location diff --git a/stock_inventory_lockdown/models/stock_inventory.py b/stock_inventory_lockdown/models/stock_inventory.py index b1302dfda..92315622b 100644 --- a/stock_inventory_lockdown/models/stock_inventory.py +++ b/stock_inventory_lockdown/models/stock_inventory.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2013-2016 Numérigraphe SARL # Copyright 2017 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) diff --git a/stock_inventory_lockdown/models/stock_location.py b/stock_inventory_lockdown/models/stock_location.py index 62662d4d8..523d7c243 100644 --- a/stock_inventory_lockdown/models/stock_location.py +++ b/stock_inventory_lockdown/models/stock_location.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2016 Numérigraphe SARL # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/stock_inventory_lockdown/models/stock_move.py b/stock_inventory_lockdown/models/stock_move.py index 5655ddd6a..83f0ef713 100644 --- a/stock_inventory_lockdown/models/stock_move.py +++ b/stock_inventory_lockdown/models/stock_move.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2016 Numérigraphe SARL # Copyright 2017 Eficent Business and IT Consulting Services S.L. # (http://www.eficent.com) @@ -14,14 +13,12 @@ class StockMove(models.Model): @api.multi def _get_reserved_locations(self): self.ensure_one() - return self.reserved_quant_ids.mapped('location_id') + \ - self.split_from.reserved_quant_ids.mapped('location_id') + return self.move_line_ids.mapped('location_id') @api.multi def _get_dest_locations(self): self.ensure_one() - return self.linked_move_operation_ids.mapped( - 'operation_id.location_dest_id') + return self.move_line_ids.mapped('location_dest_id') @api.constrains('location_dest_id', 'location_id', 'state') def _check_locked_location(self): diff --git a/stock_inventory_lockdown/readme/CONTRIBUTORS.rst b/stock_inventory_lockdown/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..17d831e18 --- /dev/null +++ b/stock_inventory_lockdown/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* Loïc Bellier (Numérigraphe) +* Lionel Sausin (Numérigraphe) +* Laetitia Gangloff (Acsone) +* Laurent Mignon (Acsone) +* Lois Rilo (Eficent) +* Jordi Ballester (Eficent) diff --git a/stock_inventory_lockdown/readme/DESCRIPTION.rst b/stock_inventory_lockdown/readme/DESCRIPTION.rst new file mode 100644 index 000000000..358e5a840 --- /dev/null +++ b/stock_inventory_lockdown/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module lets you lock down the locations during an inventory. diff --git a/stock_inventory_lockdown/readme/USAGE.rst b/stock_inventory_lockdown/readme/USAGE.rst new file mode 100644 index 000000000..81f302c86 --- /dev/null +++ b/stock_inventory_lockdown/readme/USAGE.rst @@ -0,0 +1,7 @@ +While an inventory is in the state "In progress", no stock moves +can be recorded in/out of the inventory's location: users will get an error +message. +Creating or modifying locations is also forbidden. + +.. image:: stock_inventory_lockdown/static/images/move_error.png + :alt: Error message diff --git a/stock_inventory_lockdown/tests/__init__.py b/stock_inventory_lockdown/tests/__init__.py index c1942bfd6..7cb44613b 100644 --- a/stock_inventory_lockdown/tests/__init__.py +++ b/stock_inventory_lockdown/tests/__init__.py @@ -1,5 +1 @@ -# -*- coding: utf-8 -*- -# © 2013-2016 Numérigraphe SARL -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - from . import test_stock_inventory_lockdown diff --git a/stock_inventory_lockdown/tests/test_stock_inventory_lockdown.py b/stock_inventory_lockdown/tests/test_stock_inventory_lockdown.py index f20b06340..2bcd5b682 100644 --- a/stock_inventory_lockdown/tests/test_stock_inventory_lockdown.py +++ b/stock_inventory_lockdown/tests/test_stock_inventory_lockdown.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # © 2014 Acsone SA/NV (http://www.acsone.eu) # © 2016 Numérigraphe SARL # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -26,17 +25,17 @@ class StockInventoryLocationTest(TestStockCommon): self.env['stock.quant'].create( {'location_id': self.new_location.id, 'product_id': self.productA.id, - 'qty': 10.0}) + 'quantity': 10.0}) self.env['stock.quant'].create( {'location_id': self.new_parent_location.id, 'product_id': self.productB.id, - 'qty': 5.0}) + 'quantity': 5.0}) # Prepare an inventory self.inventory = self.env['stock.inventory'].create( {'name': 'Lock down location', 'filter': 'none', 'location_id': self.new_location.id}) - self.inventory.prepare_inventory() + self.inventory.action_start() self.assertTrue(self.inventory.line_ids, 'The inventory is empty.') def create_stock_move(self, product, origin_id=False, dest_id=False): @@ -79,7 +78,7 @@ class StockInventoryLocationTest(TestStockCommon): {'name': 'Lock down location', 'filter': 'partial', 'location_id': self.new_sublocation.id}) - inventory_subloc.prepare_inventory() + inventory_subloc.action_start() line = self.env['stock.inventory.line'].create( {'product_id': self.productA.id, 'product_qty': 22.0, @@ -95,16 +94,18 @@ class StockInventoryLocationTest(TestStockCommon): location.""" move1 = self.create_stock_move( self.productA, origin_id=self.inventory.location_id.id) - move1.action_confirm() + move1._action_confirm() with self.assertRaises(ValidationError): - move1.action_assign() - move1.action_done() + move1._action_assign() + move1.move_line_ids[0].qty_done = 10.0 + move1._action_done() move2 = self.create_stock_move( self.productA, dest_id=self.inventory.location_id.id) with self.assertRaises(ValidationError): - move2.action_confirm() - move2.action_assign() - move2.action_done() + move2._action_confirm() + move2._action_assign() + move2.move_line_ids[0].qty_done = 10.0 + move2._action_done() def test_move_reserved_quants(self): """Shipping stock should be allowed or not depending on reserved @@ -114,14 +115,16 @@ class StockInventoryLocationTest(TestStockCommon): inventoried.""" move1 = self.create_stock_move( self.productB, self.new_parent_location.id) - move1.action_confirm() - move1.action_assign() - move1.action_done() + move1._action_confirm() + move1._action_assign() + move1.move_line_ids[0].qty_done = 10.0 + move1._action_done() self.assertEqual( move1.state, 'done', 'Move has not been completed') move2 = self.create_stock_move( self.productA, self.new_parent_location.id) - move2.action_confirm() + move2._action_confirm() with self.assertRaises(ValidationError): - move2.action_assign() - move2.action_done() + move2._action_assign() + move2.move_line_ids[0].qty_done = 10.0 + move2._action_done()