diff --git a/stock_location_lockdown/README.rst b/stock_location_lockdown/README.rst new file mode 100644 index 000000000..e6007a651 --- /dev/null +++ b/stock_location_lockdown/README.rst @@ -0,0 +1,81 @@ +======================= +Stock Location Lockdown +======================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :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/9.0/stock_location_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-9-0/stock-logistics-warehouse-9-0-stock_location_lockdown + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/153/9.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +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. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +* 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. + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Akretion + +Contributors +~~~~~~~~~~~~ + +* Florian da Costa + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_location_lockdown/__init__.py b/stock_location_lockdown/__init__.py new file mode 100644 index 000000000..9cf531149 --- /dev/null +++ b/stock_location_lockdown/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/stock_location_lockdown/__openerp__.py b/stock_location_lockdown/__openerp__.py new file mode 100644 index 000000000..182f19b8d --- /dev/null +++ b/stock_location_lockdown/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Location Lockdown", + "summary": "Prevent to add stock in flag locations", + "author": "Akretion, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "category": "Warehouse", + "version": "9.0.1.0.0", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "stock", + ], + "data": [ + "views/stock_location.xml", + ] +} diff --git a/stock_location_lockdown/i18n/fr.po b/stock_location_lockdown/i18n/fr.po new file mode 100644 index 000000000..57547ba5e --- /dev/null +++ b/stock_location_lockdown/i18n/fr.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_location_lockdown +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 9.0c\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-09-06 13:10+0000\n" +"PO-Revision-Date: 2018-09-06 13:10+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_location_lockdown +#: model:ir.model.fields,field_description:stock_location_lockdown.field_stock_location_lockdown_entrance +msgid "Block stock entrance" +msgstr "Bloquer les entrées de stock" + +#. module: stock_location_lockdown +#: model:ir.model,name:stock_location_lockdown.model_stock_location +msgid "Location" +msgstr "Emplacement" + +#. module: stock_location_lockdown +#: code:addons/stock_location_lockdown/models/stock_quant.py:17 +#, python-format +msgid "The location %s is not configured to receive stock." +msgstr "L'emplacement %s n'est pas configuré pour recevoir du stock." + +#. module: stock_location_lockdown +#: model:ir.model.fields,help:stock_location_lockdown.field_stock_location_block_stock_entrance +msgid "if this box is checked, put stock in this location won't be allowed. Usually used for virtual location, which has children" +msgstr "Si cette case est cochée, il ne sera pas possible d'ajouter du stock dans cette emplacement. Habituellement utilisée pour les emplacements virtuels ayant des enfants." diff --git a/stock_location_lockdown/models/__init__.py b/stock_location_lockdown/models/__init__.py new file mode 100644 index 000000000..28f630281 --- /dev/null +++ b/stock_location_lockdown/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import stock_location +from . import stock_quant diff --git a/stock_location_lockdown/models/stock_location.py b/stock_location_lockdown/models/stock_location.py new file mode 100644 index 000000000..377e8ca68 --- /dev/null +++ b/stock_location_lockdown/models/stock_location.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp 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") diff --git a/stock_location_lockdown/models/stock_quant.py b/stock_location_lockdown/models/stock_quant.py new file mode 100644 index 000000000..032cb5169 --- /dev/null +++ b/stock_location_lockdown/models/stock_quant.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# 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 + + +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 diff --git a/stock_location_lockdown/readme/CONTRIBUTORS.rst b/stock_location_lockdown/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..0bddb053a --- /dev/null +++ b/stock_location_lockdown/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Florian da Costa diff --git a/stock_location_lockdown/readme/DESCRIPTION.rst b/stock_location_lockdown/readme/DESCRIPTION.rst new file mode 100644 index 000000000..8e7c3841a --- /dev/null +++ b/stock_location_lockdown/readme/DESCRIPTION.rst @@ -0,0 +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. diff --git a/stock_location_lockdown/readme/USAGE.rst b/stock_location_lockdown/readme/USAGE.rst new file mode 100644 index 000000000..b1b77caab --- /dev/null +++ b/stock_location_lockdown/readme/USAGE.rst @@ -0,0 +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. diff --git a/stock_location_lockdown/static/description/index.html b/stock_location_lockdown/static/description/index.html new file mode 100644 index 000000000..fbe0e8a7f --- /dev/null +++ b/stock_location_lockdown/static/description/index.html @@ -0,0 +1,429 @@ + + + + + + +Stock Location Lockdown + + + +
+

Stock Location Lockdown

+ + +

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

+

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.

+

Table of contents

+ +
+

Usage

+
    +
  • 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.
  • +
+
+
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

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

+
+
+
+ + diff --git a/stock_location_lockdown/tests/__init__.py b/stock_location_lockdown/tests/__init__.py new file mode 100644 index 000000000..26c695414 --- /dev/null +++ b/stock_location_lockdown/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Akretion +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_block_stock_location_entrance diff --git a/stock_location_lockdown/tests/test_block_stock_location_entrance.py b/stock_location_lockdown/tests/test_block_stock_location_entrance.py new file mode 100644 index 000000000..44543ce4a --- /dev/null +++ b/stock_location_lockdown/tests/test_block_stock_location_entrance.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp.exceptions import UserError +from openerp.tests.common import TransactionCase + + +class TestStockLocationLockdown(TransactionCase): + + def setUp(self, *args, **kwargs): + super(TestStockLocationLockdown, self).setUp(*args, **kwargs) + 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') + + def test_transfer_stock_in_locked_location(self): + """ + Test to move stock within a location that should not accept + Stock entrance. + """ + move_vals = { + 'location_id': self.supplier_location.id, + 'location_dest_id': self.main_stock_location.id, + 'product_id': self.product.id, + 'product_uom_qty': '2.0', + 'product_uom': 1, + 'name': 'test', + } + stock_move = self.env['stock.move'].create(move_vals) + with self.assertRaises(UserError): + stock_move.action_done() diff --git a/stock_location_lockdown/views/stock_location.xml b/stock_location_lockdown/views/stock_location.xml new file mode 100644 index 000000000..be16e7e21 --- /dev/null +++ b/stock_location_lockdown/views/stock_location.xml @@ -0,0 +1,17 @@ + + + + + + + stock.location + + + + + + + + +