mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] stock_inventory_lockdown: Migration to 13.0
This commit is contained in:
committed by
Ben Stannard
parent
17d044a760
commit
067bedbc0a
@@ -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|
|
||||
@@ -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
|
||||
@@ -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.
|
||||
|
||||
@@ -60,7 +60,7 @@ Authors
|
||||
~~~~~~~
|
||||
|
||||
* Numérigraphe
|
||||
* Eficent
|
||||
* ForgeFlow
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
@@ -69,8 +69,8 @@ Contributors
|
||||
* Lionel Sausin (Numérigraphe) <ls@numerigraphe.com>
|
||||
* Laetitia Gangloff (Acsone) <laetitia.gangloff@acsone.eu>
|
||||
* Laurent Mignon (Acsone) <laurent.mignon@acsone.eu>
|
||||
* 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 <mallen@opensourceintegrators.com>
|
||||
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
|
||||
|
||||
@@ -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,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"],
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -14,15 +14,17 @@ class StockInventory(models.Model):
|
||||
"""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"]),
|
||||
]
|
||||
|
||||
@@ -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"""
|
||||
@@ -22,7 +21,6 @@ class StockLocation(models.Model):
|
||||
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 = (
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -10,12 +10,10 @@ from odoo.exceptions import ValidationError
|
||||
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")
|
||||
@@ -48,7 +46,7 @@ class StockMove(models.Model):
|
||||
raise ValidationError(
|
||||
_(
|
||||
"An inventory is being conducted at the following "
|
||||
"location(s):\n%s"
|
||||
"location(s):\n - %s"
|
||||
)
|
||||
% "\n - ".join(location_names)
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Lionel Sausin (Numérigraphe) <ls@numerigraphe.com>
|
||||
* Laetitia Gangloff (Acsone) <laetitia.gangloff@acsone.eu>
|
||||
* Laurent Mignon (Acsone) <laurent.mignon@acsone.eu>
|
||||
* 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 <mallen@opensourceintegrators.com>
|
||||
* Bhavesh Odedra <bodedra@opensourceintegrators.com>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -367,7 +367,7 @@ ul.auto-toc {
|
||||
!! 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">
|
||||
@@ -388,14 +388,16 @@ ul.auto-toc {
|
||||
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">
|
||||
@@ -404,7 +406,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<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">
|
||||
@@ -414,8 +416,8 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<li>Lionel Sausin (Numérigraphe) <<a class="reference external" href="mailto:ls@numerigraphe.com">ls@numerigraphe.com</a>></li>
|
||||
<li>Laetitia Gangloff (Acsone) <<a class="reference external" href="mailto:laetitia.gangloff@acsone.eu">laetitia.gangloff@acsone.eu</a>></li>
|
||||
<li>Laurent Mignon (Acsone) <<a class="reference external" href="mailto:laurent.mignon@acsone.eu">laurent.mignon@acsone.eu</a>></li>
|
||||
<li>Lois Rilo (Eficent) <<a class="reference external" href="mailto:lois.rilo@eficent.com">lois.rilo@eficent.com</a>></li>
|
||||
<li>Jordi Ballester (Eficent) <<a class="reference external" href="mailto:jordi.ballester@eficent.com">jordi.ballester@eficent.com</a>></li>
|
||||
<li>Lois Rilo (ForgeFlow) <<a class="reference external" href="mailto:lois.rilo@forgeflow.com">lois.rilo@forgeflow.com</a>></li>
|
||||
<li>Jordi Ballester (ForgeFlow) <<a class="reference external" href="mailto:jordi.ballester@forgeflow.com">jordi.ballester@forgeflow.com</a>></li>
|
||||
<li>Michael Allen <<a class="reference external" href="mailto:mallen@opensourceintegrators.com">mallen@opensourceintegrators.com</a>></li>
|
||||
<li>Bhavesh Odedra <<a class="reference external" href="mailto:bodedra@opensourceintegrators.com">bodedra@opensourceintegrators.com</a>></li>
|
||||
</ul>
|
||||
@@ -427,7 +429,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<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>
|
||||
|
||||
@@ -45,11 +45,7 @@ class StockInventoryLocationTest(TestStockCommon):
|
||||
)
|
||||
# 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.")
|
||||
@@ -69,13 +65,15 @@ class StockInventoryLocationTest(TestStockCommon):
|
||||
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):
|
||||
@@ -103,8 +101,7 @@ class StockInventoryLocationTest(TestStockCommon):
|
||||
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()
|
||||
@@ -127,7 +124,7 @@ class StockInventoryLocationTest(TestStockCommon):
|
||||
"""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):
|
||||
@@ -135,7 +132,7 @@ class StockInventoryLocationTest(TestStockCommon):
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user