Skip to content

Commit

Permalink
[MIG] stock_inventory_lockdown: Migration to 13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AdriaGForgeFlow committed Dec 20, 2019
1 parent d922fc7 commit 21f259c
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 42 deletions.
18 changes: 9 additions & 9 deletions stock_inventory_lockdown/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Inventory Lock Down
: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/12.0/stock_inventory_lockdown
:target: https://github.com/OCA/stock-logistics-warehouse/tree/13.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-12-0/stock-logistics-warehouse-12-0-stock_inventory_lockdown
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_inventory_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/12.0
:target: https://runbot.odoo-community.org/runbot/153/13.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -40,7 +40,7 @@ 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://raw.githubusercontent.com/OCA/stock-logistics-warehouse/12.0/stock_inventory_lockdown/stock_inventory_lockdown/static/images/move_error.png
.. figure:: https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/13.0/stock_inventory_lockdown/static/images/move_error.png
:alt: Error message

Bug Tracker
Expand All @@ -49,7 +49,7 @@ 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_inventory_lockdown%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_inventory_lockdown%0Aversion:%2013.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.

Expand All @@ -60,7 +60,7 @@ Authors
~~~~~~~

* Numérigraphe
* Eficent
* ForgeFlow

Contributors
~~~~~~~~~~~~
Expand All @@ -69,8 +69,8 @@ Contributors
* Lionel Sausin (Numérigraphe) <[email protected]>
* Laetitia Gangloff (Acsone) <[email protected]>
* Laurent Mignon (Acsone) <[email protected]>
* Lois Rilo (Eficent) <lois.rilo@eficent.com>
* Jordi Ballester (Eficent) <jordi.ballester@eficent.com>
* Lois Rilo (ForgeFlow) <lois.rilo@forgeflow.com>
* Jordi Ballester (ForgeFlow) <jordi.ballester@forgeflow.com>
* Michael Allen <[email protected]>
* Bhavesh Odedra <[email protected]>

Expand All @@ -87,6 +87,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 <https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_inventory_lockdown>`_ project on GitHub.
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_inventory_lockdown>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions stock_inventory_lockdown/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
{
"name": "Inventory Lock Down",
"summary": "Lock down stock locations during inventories.",
"version": "12.0.1.0.1",
"version": "13.0.1.0.0",
"development_status": "Mature",
"depends": ["stock"],
"author": "Numérigraphe, Eficent, Odoo Community Association (OCA)",
"author": "Numérigraphe, ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"category": "Warehouse Management",
"images": ["images/move_error.png", "images/location_locked.png"],
Expand Down
8 changes: 5 additions & 3 deletions stock_inventory_lockdown/models/stock_inventory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# © 2013-2016 Numérigraphe SARL
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2017 ForgeFlow S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

Expand All @@ -14,15 +14,17 @@ def _get_locations_open_inventories(self, locations_ids=None):
"""IDs of locations in open exhaustive inventories, with children"""
inventory_domain = [("state", "=", "confirm")]
if locations_ids:
inventory_domain.append(("location_id", "child_of", locations_ids))
inventory_domain.append(("location_ids", "child_of", locations_ids))
inventories = self.search(inventory_domain)
if not inventories:
# Early exit if no match found
return []
location_ids = inventories.mapped("location_id")
location_ids = inventories.mapped("location_ids")

# Extend to the children Locations
location_domain = [
"|",
("location_id", "in", location_ids.ids),
("location_id", "child_of", location_ids.ids),
("usage", "in", ["internal", "transit"]),
]
Expand Down
2 changes: 0 additions & 2 deletions stock_inventory_lockdown/models/stock_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class StockLocation(models.Model):
_inherit = "stock.location"
_order = "name"

@api.multi
@api.constrains("location_id")
def _check_inventory_location_id(self):
"""Error if an inventory is being conducted here"""
Expand All @@ -22,7 +21,6 @@ def _check_inventory_location_id(self):
if location_inventory_open_ids:
raise ValidationError(_("An inventory is being conducted at this location"))

@api.multi
def unlink(self):
"""Refuse unlink if an inventory is being conducted"""
location_inventory_open_ids = (
Expand Down
6 changes: 2 additions & 4 deletions stock_inventory_lockdown/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# © 2016 Numérigraphe SARL
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2017 ForgeFlow S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

Expand All @@ -10,12 +10,10 @@
class StockMove(models.Model):
_inherit = "stock.move"

@api.multi
def _get_reserved_locations(self):
self.ensure_one()
return self.move_line_ids.mapped("location_id")

@api.multi
def _get_dest_locations(self):
self.ensure_one()
return self.move_line_ids.mapped("location_dest_id")
Expand Down Expand Up @@ -48,7 +46,7 @@ def _check_locked_location(self):
raise ValidationError(
_(
"An inventory is being conducted at the following "
"location(s):\n%s"
"location(s):\n - %s"
)
% "\n - ".join(location_names)
)
4 changes: 2 additions & 2 deletions stock_inventory_lockdown/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Lionel Sausin (Numérigraphe) <[email protected]>
* Laetitia Gangloff (Acsone) <[email protected]>
* Laurent Mignon (Acsone) <[email protected]>
* Lois Rilo (Eficent) <lois.rilo@eficent.com>
* Jordi Ballester (Eficent) <jordi.ballester@eficent.com>
* Lois Rilo (ForgeFlow) <lois.rilo@forgeflow.com>
* Jordi Ballester (ForgeFlow) <jordi.ballester@forgeflow.com>
* Michael Allen <[email protected]>
* Bhavesh Odedra <[email protected]>
2 changes: 1 addition & 1 deletion stock_inventory_lockdown/readme/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ 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
.. figure:: static/images/move_error.png
:alt: Error message
16 changes: 9 additions & 7 deletions stock_inventory_lockdown/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Inventory Lock Down</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_inventory_lockdown"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_inventory_lockdown"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_inventory_lockdown"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_inventory_lockdown"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module lets you lock down the locations during an inventory.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand All @@ -388,14 +388,16 @@ <h1><a class="toc-backref" href="#id1">Usage</a></h1>
can be recorded in/out of the inventory’s location: users will get an error
message.
Creating or modifying locations is also forbidden.</p>
<img alt="Error message" src="https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/12.0/stock_inventory_lockdown/stock_inventory_lockdown/static/images/move_error.png" />
<div class="figure">
<img alt="Error message" src="https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/13.0/stock_inventory_lockdown/static/images/move_error.png" />
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_inventory_lockdown%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_inventory_lockdown%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -404,7 +406,7 @@ <h1><a class="toc-backref" href="#id3">Credits</a></h1>
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
<ul class="simple">
<li>Numérigraphe</li>
<li>Eficent</li>
<li>ForgeFlow</li>
</ul>
</div>
<div class="section" id="contributors">
Expand All @@ -414,8 +416,8 @@ <h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<li>Lionel Sausin (Numérigraphe) &lt;<a class="reference external" href="mailto:ls&#64;numerigraphe.com">ls&#64;numerigraphe.com</a>&gt;</li>
<li>Laetitia Gangloff (Acsone) &lt;<a class="reference external" href="mailto:laetitia.gangloff&#64;acsone.eu">laetitia.gangloff&#64;acsone.eu</a>&gt;</li>
<li>Laurent Mignon (Acsone) &lt;<a class="reference external" href="mailto:laurent.mignon&#64;acsone.eu">laurent.mignon&#64;acsone.eu</a>&gt;</li>
<li>Lois Rilo (Eficent) &lt;<a class="reference external" href="mailto:lois.rilo&#64;eficent.com">lois.rilo&#64;eficent.com</a>&gt;</li>
<li>Jordi Ballester (Eficent) &lt;<a class="reference external" href="mailto:jordi.ballester&#64;eficent.com">jordi.ballester&#64;eficent.com</a>&gt;</li>
<li>Lois Rilo (ForgeFlow) &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
<li>Jordi Ballester (ForgeFlow) &lt;<a class="reference external" href="mailto:jordi.ballester&#64;forgeflow.com">jordi.ballester&#64;forgeflow.com</a>&gt;</li>
<li>Michael Allen &lt;<a class="reference external" href="mailto:mallen&#64;opensourceintegrators.com">mallen&#64;opensourceintegrators.com</a>&gt;</li>
<li>Bhavesh Odedra &lt;<a class="reference external" href="mailto:bodedra&#64;opensourceintegrators.com">bodedra&#64;opensourceintegrators.com</a>&gt;</li>
</ul>
Expand All @@ -427,7 +429,7 @@ <h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_inventory_lockdown">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/13.0/stock_inventory_lockdown">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
21 changes: 9 additions & 12 deletions stock_inventory_lockdown/tests/test_stock_inventory_lockdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ def setUp(self):
)
# Prepare an inventory
self.inventory = self.env["stock.inventory"].create(
{
"name": "Lock down location",
"filter": "none",
"location_id": self.new_location.id,
}
{"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.")
Expand All @@ -69,13 +65,15 @@ def create_stock_move(self, product, origin_id=False, dest_id=False):
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.location_id.location_id = self.env.ref("stock.stock_location_4")
self.inventory.location_ids.location_id = self.env.ref(
"stock.stock_location_14"
)

def test_update_parent_location_locked_down(self):
"""Updating the parent of a location must fail"""
with self.assertRaises(ValidationError):
self.inventory.location_id.location_id = self.env.ref(
"stock.stock_location_4"
self.inventory.location_ids.location_id = self.env.ref(
"stock.stock_location_stock"
)

def test_inventory(self):
Expand Down Expand Up @@ -103,8 +101,7 @@ def test_inventory_sublocation(self):
inventory_subloc = self.env["stock.inventory"].create(
{
"name": "Lock down location",
"filter": "partial",
"location_id": self.new_sublocation.id,
"location_ids": [(4, self.new_sublocation.id)],
}
)
inventory_subloc.action_start()
Expand All @@ -127,15 +124,15 @@ def test_move(self):
"""Stock moves must be forbidden during inventory from/to inventoried
location."""
move1 = self.create_stock_move(
self.productA, origin_id=self.inventory.location_id.id
self.productA, origin_id=self.inventory.location_ids.id
)
move1._action_confirm()
with self.assertRaises(ValidationError):
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
self.productA, dest_id=self.inventory.location_ids.id
)
with self.assertRaises(ValidationError):
move2._action_confirm()
Expand Down

0 comments on commit 21f259c

Please sign in to comment.