Skip to content

Commit

Permalink
[MIG] stock_inventory_lockdown: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPForgeFlow authored and ArnauCForgeFlow committed Dec 9, 2024
1 parent 3614cd9 commit afbc8e1
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 43 deletions.
16 changes: 8 additions & 8 deletions stock_inventory_lockdown/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ Inventory Lock Down
!! source digest: sha256:7ddb56de024aa57a1592b12e4fff62a12e0a3e05ae98961f46d6f055f8d62487
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Mature
: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/14.0/stock_inventory_lockdown
:target: https://github.com/OCA/stock-logistics-warehouse/tree/16.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-14-0/stock-logistics-warehouse-14-0-stock_inventory_lockdown
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_inventory_lockdown
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=14.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -43,7 +43,7 @@ can be recorded in/out of the inventory's location: users will get an error
message.
Creating or modifying locations is also forbidden.

.. figure:: https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/14.0/stock_inventory_lockdown/static/images/move_error.png
.. figure:: https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/16.0/stock_inventory_lockdown/static/images/move_error.png
:alt: Error message

Bug Tracker
Expand All @@ -52,7 +52,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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_inventory_lockdown%0Aversion:%2014.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:%2016.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 Down Expand Up @@ -90,6 +90,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/14.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/16.0/stock_inventory_lockdown>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
6 changes: 3 additions & 3 deletions stock_inventory_lockdown/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
{
"name": "Inventory Lock Down",
"summary": "Lock down stock locations during inventories.",
"version": "14.0.1.0.0",
"development_status": "Mature",
"depends": ["stock"],
"version": "16.0.1.0.0",
"development_status": "Beta",
"depends": ["stock", "stock_inventory"],
"author": "Numérigraphe, ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"category": "Warehouse Management",
Expand Down
2 changes: 1 addition & 1 deletion stock_inventory_lockdown/models/stock_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class StockInventory(models.Model):
@api.model
def _get_locations_open_inventories(self, locations_ids=None):
"""IDs of locations in open exhaustive inventories, with children"""
inventory_domain = [("state", "=", "confirm")]
inventory_domain = [("state", "=", "in_progress")]
if locations_ids:
inventory_domain.append(("location_ids", "child_of", locations_ids))
inventories = self.search(inventory_domain)
Expand Down
6 changes: 3 additions & 3 deletions stock_inventory_lockdown/models/stock_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class StockLocation(models.Model):
def _check_inventory_location_id(self):
"""Error if an inventory is being conducted here"""
vals = set(self.ids) | set(self.mapped("location_id").ids)
location_inventory_open_ids = (
self.env["stock.inventory"].sudo()._get_locations_open_inventories(vals)
)
location_inventory_open_ids = self.env[
"stock.inventory"
]._get_locations_open_inventories(vals)
if location_inventory_open_ids:
raise ValidationError(_("An inventory is being conducted at this location"))

Expand Down
20 changes: 11 additions & 9 deletions stock_inventory_lockdown/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Inventory Lock Down</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7ddb56de024aa57a1592b12e4fff62a12e0a3e05ae98961f46d6f055f8d62487
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/stock-logistics-warehouse/tree/14.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 image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" 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 image-reference" href="https://github.com/OCA/stock-logistics-warehouse/tree/16.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 image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-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 @@ -391,15 +391,15 @@ <h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
message.
Creating or modifying locations is also forbidden.</p>
<div class="figure">
<img alt="Error message" src="https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/14.0/stock_inventory_lockdown/static/images/move_error.png" />
<img alt="Error message" src="https://raw.githubusercontent.com/OCA/stock-logistics-warehouse/16.0/stock_inventory_lockdown/static/images/move_error.png" />
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">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 to smash 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:%2014.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:%2016.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 Down Expand Up @@ -427,11 +427,13 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<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/14.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/16.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
44 changes: 25 additions & 19 deletions stock_inventory_lockdown/tests/test_stock_inventory_lockdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def setUp(self):
self.inventory = self.env["stock.inventory"].create(
{"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.")
self.inventory.action_state_to_in_progress()
self.assertTrue(self.inventory.stock_quant_ids, "The inventory is empty.")

def create_stock_move(self, product, origin_id=False, dest_id=False):
return self.env["stock.move"].create(
Expand All @@ -64,7 +64,7 @@ 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.action_state_to_draft()
self.inventory.location_ids.location_id = self.env.ref(
"stock.stock_location_14"
)
Expand All @@ -78,17 +78,19 @@ def test_update_parent_location_locked_down(self):

def test_inventory(self):
"""We must still be able to finish the inventory"""
self.assertTrue(self.inventory.line_ids)
self.inventory.line_ids.write({"product_qty": 42.0})
for line in self.inventory.line_ids:
self.assertTrue(self.inventory.stock_quant_ids)
self.inventory.stock_quant_ids.write({"inventory_quantity": 42.0})
for line in self.inventory.stock_quant_ids:
self.assertNotEqual(
line.product_id.with_context(
location=line.location_id.id
).qty_available,
42.0,
)
self.inventory.action_validate()
for line in self.inventory.line_ids:
for line in self.inventory.stock_quant_ids:
line._apply_inventory()

for line in self.inventory.stock_quant_ids:
self.assertEqual(
line.product_id.with_context(
location=line.location_id.id
Expand All @@ -98,23 +100,27 @@ def test_inventory(self):

def test_inventory_sublocation(self):
"""We must be able to make an inventory in a sublocation"""
inventory_subloc = self.env["stock.inventory"].create(
line = self.env["stock.quant"].create(
{
"name": "Lock down location",
"location_ids": [(4, self.new_sublocation.id)],
"product_id": self.productA.id,
"quantity": 22.0,
"location_id": self.new_sublocation.id,
}
)
inventory_subloc.action_start()
line = self.env["stock.inventory.line"].create(
inventory_subloc = self.env["stock.inventory"].create(
{
"product_id": self.productA.id,
"product_qty": 22.0,
"location_id": self.new_sublocation.id,
"inventory_id": inventory_subloc.id,
"name": "Lock down location",
"location_ids": [(4, self.new_sublocation.id)],
"stock_quant_ids": line,
}
)
self.assertTrue(inventory_subloc.line_ids)
inventory_subloc.action_validate()
inventory_subloc.action_state_to_in_progress()

self.assertTrue(inventory_subloc.stock_quant_ids)

# for line in inventory_subloc.stock_quant_ids:
# line._apply_inventory()

self.assertEqual(
line.product_id.with_context(location=line.location_id.id).qty_available,
22.0,
Expand Down

0 comments on commit afbc8e1

Please sign in to comment.