diff --git a/stock_location_lockdown/__openerp__.py b/stock_location_lockdown/__manifest__.py similarity index 68% rename from stock_location_lockdown/__openerp__.py rename to stock_location_lockdown/__manifest__.py index 182f19b8d..c6e9b7a73 100644 --- a/stock_location_lockdown/__openerp__.py +++ b/stock_location_lockdown/__manifest__.py @@ -4,18 +4,14 @@ { "name": "Stock Location Lockdown", - "summary": "Prevent to add stock in flag locations", + "summary": "Prevent to add stock on flagged locations", "author": "Akretion, Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-warehouse", "category": "Warehouse", - "version": "9.0.1.0.0", + "version": "10.0.1.0.0", "license": "AGPL-3", "application": False, "installable": True, - "depends": [ - "stock", - ], - "data": [ - "views/stock_location.xml", - ] + "depends": ["stock"], + "data": ["views/stock_location.xml"], } diff --git a/stock_location_lockdown/models/stock_location.py b/stock_location_lockdown/models/stock_location.py index 377e8ca68..965144e8b 100644 --- a/stock_location_lockdown/models/stock_location.py +++ b/stock_location_lockdown/models/stock_location.py @@ -2,12 +2,13 @@ # Copyright 2018 Akretion # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import fields, models +from odoo import fields, models class StockLocation(models.Model): _inherit = 'stock.location' block_stock_entrance = fields.Boolean( - help="if this box is checked, put stock in this location won't be " - "allowed. Usually used for virtual location, which has children") + help="if this box is checked, putting stock on this location won't be " + "allowed. Usually used for a virtual location that has " + "childrens.") diff --git a/stock_location_lockdown/models/stock_quant.py b/stock_location_lockdown/models/stock_quant.py index 032cb5169..9639eb3f0 100644 --- a/stock_location_lockdown/models/stock_quant.py +++ b/stock_location_lockdown/models/stock_quant.py @@ -2,18 +2,25 @@ # Copyright 2018 Akretion # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import api, models, _ -from openerp.exceptions import UserError +from odoo import api, models, _ +from odoo.exceptions import UserError class StockQuant(models.Model): _inherit = 'stock.quant' @api.model - def _check_location(self, location): - res = super(StockQuant, self)._check_location(location) - if location.block_stock_entrance: - raise UserError( - _('The location %s is not configured to receive stock.') - % (location.name)) - return res + def quants_move( + self, quants, move, location_to, location_from=False, lot_id=False, + owner_id=False, src_package_id=False, dest_package_id=False, + entire_pack=False): + if ( + location_to.usage == 'internal' and + location_to.block_stock_entrance): + raise UserError(_( + "The location '%s' is not configured to receive stock.") + % location_to.display_name) + return super(StockQuant, self).quants_move( + quants, move, location_to, location_from=location_from, + lot_id=lot_id, owner_id=owner_id, src_package_id=src_package_id, + dest_package_id=dest_package_id, entire_pack=entire_pack) diff --git a/stock_location_lockdown/readme/DESCRIPTION.rst b/stock_location_lockdown/readme/DESCRIPTION.rst index 8e7c3841a..4fc3faa49 100644 --- a/stock_location_lockdown/readme/DESCRIPTION.rst +++ b/stock_location_lockdown/readme/DESCRIPTION.rst @@ -1,4 +1,4 @@ -The aims of this module is to mark locations where no product should transit. -Indeed, in complex warehouse environment, we may have a complicated tree of locations with a lot of virtual ones, used to create the hierarchy of the locations. -We might want to avoid to put stock in these locations since they are not physical locations, they just represent a zone of the warehouse. -For these location, the usage should be internal as it belongs to a warehouse, so the usage 'view' can't be used for these purpose. +The aim of this module is to mark internal locations where no product should transit. +Indeed, in complex warehouse setups, we may have a complicated tree of internal locations with parent locations only used to create the hierarchy of the internal locations. +We may want to avoid to put stock on these parent internal locations since they are not physical locations, they just represent a zone of the warehouse. +Theses locations must have *Location Type* set to *Internal Location* because they belong to a warehouse (they can't be configured with *Location Type* set to *View*, cf `Odoo bug #26679 `_). With this module, you will be able to enable a new option *Block stock entrance* for these locations. diff --git a/stock_location_lockdown/readme/USAGE.rst b/stock_location_lockdown/readme/USAGE.rst index b1b77caab..a8727fb3b 100644 --- a/stock_location_lockdown/readme/USAGE.rst +++ b/stock_location_lockdown/readme/USAGE.rst @@ -1 +1 @@ -* Once the module is installed, goes to any location for which you want to prevent stock entrance and check the box "Block Stock Entrance". Then, you won't be allow to add stock in these locations. +* Once the module is installed, select any internal location for which you want to prevent stock entrance and check the box *Block Stock Entrance*. Then, you won't be allow to add stock on these locations. diff --git a/stock_location_lockdown/tests/test_block_stock_location_entrance.py b/stock_location_lockdown/tests/test_block_stock_location_entrance.py index 44543ce4a..e55a2edb7 100644 --- a/stock_location_lockdown/tests/test_block_stock_location_entrance.py +++ b/stock_location_lockdown/tests/test_block_stock_location_entrance.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2018 Akretion France # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp.exceptions import UserError -from openerp.tests.common import TransactionCase +from odoo.exceptions import UserError +from odoo.tests.common import TransactionCase class TestStockLocationLockdown(TransactionCase): @@ -13,7 +13,7 @@ class TestStockLocationLockdown(TransactionCase): self.main_stock_location = self.env.ref('stock.stock_location_stock') self.main_stock_location.block_stock_entrance = True self.supplier_location = self.env.ref('stock.stock_location_suppliers') - self.product = self.env.ref('product.product_product_35') + self.product = self.env.ref('product.product_product_27') def test_transfer_stock_in_locked_location(self): """