Skip to content

Commit

Permalink
Merge PR #720 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by rousseldenis
  • Loading branch information
OCA-git-bot committed Sep 30, 2019
2 parents 2f031ef + 1014d79 commit bd44954
Show file tree
Hide file tree
Showing 17 changed files with 851 additions and 0 deletions.
81 changes: 81 additions & 0 deletions stock_location_lockdown/README.rst
Original file line number Diff line number Diff line change
@@ -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/10.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-10-0/stock-logistics-warehouse-10-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/10.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

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 <https://github.com/odoo/odoo/issues/26679>`_). With this module, you will be able to enable a new option *Block stock entrance* for these locations.

**Table of contents**

.. contents::
:local:

Usage
=====

* 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.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/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 <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_location_lockdown%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* Florian da Costa <florian.dacosta@akretion.com>

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 <https://github.com/OCA/stock-logistics-warehouse/tree/10.0/stock_location_lockdown>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions stock_location_lockdown/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2018 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
16 changes: 16 additions & 0 deletions stock_location_lockdown/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2018 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Stock Location Lockdown",
"summary": "Prevent to add stock on locked locations",
"author": "Akretion, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"category": "Warehouse",
"version": "12.0.1.0.0",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["stock"],
"data": ["views/stock_location.xml"],
}
57 changes: 57 additions & 0 deletions stock_location_lockdown/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# 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"
"Language: \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_block_stock_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 "Inventory Locations"
msgstr ""

#. module: stock_location_lockdown
#: model:ir.model,name:stock_location_lockdown.model_stock_quant
msgid "Quants"
msgstr ""

#. module: stock_location_lockdown
#: code:addons/stock_location_lockdown/models/stock_quant.py:17
#, python-format
msgid ""
"The location %s is blocked and can not be used for moving the product %s"
msgstr ""

#. module: stock_location_lockdown
#: model:ir.model.fields,help:stock_location_lockdown.field_stock_location_block_stock_entrance
#, fuzzy
msgid ""
"if this box is checked, putting stock on this location won't be allowed. "
"Usually used for a virtual location that has childrens."
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."

#, fuzzy
#~ msgid "The location '%s' is not configured to receive stock."
#~ msgstr "L'emplacement %s n'est pas configuré pour recevoir du stock."

#~ msgid "Location"
#~ msgstr "Emplacement"
52 changes: 52 additions & 0 deletions stock_location_lockdown/i18n/pt.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_location_lockdown
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2018-12-28 01:41+0000\n"
"Last-Translator: Pedro Castro Silva <pedrocs@exo.pt>\n"
"Language-Team: none\n"
"Language: pt\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 3.3\n"

#. module: stock_location_lockdown
#: model:ir.model.fields,field_description:stock_location_lockdown.field_stock_location_block_stock_entrance
msgid "Block stock entrance"
msgstr "Bloquear entradas de stock"

#. module: stock_location_lockdown
#: model:ir.model,name:stock_location_lockdown.model_stock_location
msgid "Inventory Locations"
msgstr "Localizações de Inventário"

#. module: stock_location_lockdown
#: model:ir.model,name:stock_location_lockdown.model_stock_quant
msgid "Quants"
msgstr ""

#. module: stock_location_lockdown
#: code:addons/stock_location_lockdown/models/stock_quant.py:17
#, python-format
msgid ""
"The location %s is blocked and can not be used for moving the product %s"
msgstr ""

#. module: stock_location_lockdown
#: model:ir.model.fields,help:stock_location_lockdown.field_stock_location_block_stock_entrance
msgid ""
"if this box is checked, putting stock on this location won't be allowed. "
"Usually used for a virtual location that has childrens."
msgstr ""
"Se esta caixa estiver selecionada, não será permitido colocar stock nesta "
"localização. É geralmente utilizada em localizações virtuais com "
"descendentes."

#~ msgid "The location '%s' is not configured to receive stock."
#~ msgstr "A localização '%s' não está configurada para receber stock."
41 changes: 41 additions & 0 deletions stock_location_lockdown/i18n/stock_location_lockdown.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * stock_location_lockdown
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \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_block_stock_entrance
msgid "Block stock entrance"
msgstr ""

#. module: stock_location_lockdown
#: model:ir.model,name:stock_location_lockdown.model_stock_location
msgid "Inventory Locations"
msgstr ""

#. module: stock_location_lockdown
#: model:ir.model,name:stock_location_lockdown.model_stock_quant
msgid "Quants"
msgstr ""

#. module: stock_location_lockdown
#: code:addons/stock_location_lockdown/models/stock_quant.py:17
#, python-format
msgid "The location %s is blocked and can not be used for moving the product %s"
msgstr ""

#. module: stock_location_lockdown
#: model:ir.model.fields,help:stock_location_lockdown.field_stock_location_block_stock_entrance
msgid "if this box is checked, putting stock on this location won't be allowed. Usually used for a virtual location that has childrens."
msgstr ""

5 changes: 5 additions & 0 deletions stock_location_lockdown/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2019 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import stock_location
from . import stock_quant
31 changes: 31 additions & 0 deletions stock_location_lockdown/models/stock_location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2019 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models, _
from odoo.exceptions import UserError


class StockLocation(models.Model):
_inherit = 'stock.location'

block_stock_entrance = fields.Boolean(
help="if this box is checked, putting stock on this location won't be "
"allowed. Usually used for a virtual location that has "
"childrens.")

# Raise error if the location that you're trying to block
# has already got quants
def write(self, values):
res = super().write(values)

if ('block_stock_entrance' in values
and values['block_stock_entrance']):
# Unlink zero quants before checking
# if there are quants on the location
self.env['stock.quant']._unlink_zero_quants()
if self.mapped('quant_ids'):
raise UserError(
_("It is impossible to prohibit this location from\
receiving products as it already contains some.")
)
return res
22 changes: 22 additions & 0 deletions stock_location_lockdown/models/stock_quant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2019 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models, _
from odoo.exceptions import ValidationError


class StockQuant(models.Model):
_inherit = 'stock.quant'

# Raise an error when trying to change a quant
# which corresponding stock location is blocked
@api.constrains('location_id')
def check_location_blocked(self):
for record in self:
if record.location_id.block_stock_entrance:
raise ValidationError(
_('The location %s is blocked and can '
'not be used for moving the product %s')
% (record.location_id.name, record.product_id.name)
)
return True
1 change: 1 addition & 0 deletions stock_location_lockdown/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Florian da Costa <florian.dacosta@akretion.com>
4 changes: 4 additions & 0 deletions stock_location_lockdown/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
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 <https://github.com/odoo/odoo/issues/26679>`_). With this module, you will be able to enable a new option *Block stock entrance* for these locations.
1 change: 1 addition & 0 deletions stock_location_lockdown/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* 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.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bd44954

Please sign in to comment.