Skip to content

Commit

Permalink
Merge pull request #1638 from OCA/15.0
Browse files Browse the repository at this point in the history
Syncing from upstream OCA/stock-logistics-warehouse (15.0)
  • Loading branch information
bt-admin authored Feb 25, 2025
2 parents e211c73 + 6c43ef5 commit 01bd440
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ addon | version | maintainers | summary
[stock_inventory_count_to_zero](stock_inventory_count_to_zero/) | 15.0.1.0.0 | | Request an inventory count filling the quantities to zero as default
[stock_inventory_discrepancy](stock_inventory_discrepancy/) | 15.0.1.1.0 | | Adds the capability to show the discrepancy of every line in an inventory and to block the inventory validation when the discrepancy is over a user defined threshold.
[stock_inventory_lockdown](stock_inventory_lockdown/) | 15.0.1.0.0 | | Lock down stock locations during inventories.
[stock_inventory_verification_request](stock_inventory_verification_request/) | 15.0.1.0.0 | [![LoisRForgeFlow](https://github.com/LoisRForgeFlow.png?size=30px)](https://github.com/LoisRForgeFlow) | Adds the capability to request a Slot Verification when a inventory is Pending to Approve
[stock_inventory_verification_request](stock_inventory_verification_request/) | 15.0.1.1.0 | [![LoisRForgeFlow](https://github.com/LoisRForgeFlow.png?size=30px)](https://github.com/LoisRForgeFlow) | Adds the capability to request a Slot Verification when a inventory is Pending to Approve
[stock_location_lockdown](stock_location_lockdown/) | 15.0.1.0.1 | | Prevent to add stock on locked locations
[stock_location_position](stock_location_position/) | 15.0.1.0.0 | | Add coordinate attributes on stock location.
[stock_location_route_description](stock_location_route_description/) | 15.0.1.0.0 | | Add description field on stock routes.
Expand Down
2 changes: 1 addition & 1 deletion stock_inventory_verification_request/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Stock Inventory Verification Request
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7709b979928555cca3d1036322c3b6979090816cc51c2bb1a9b975c8f3a821fa
!! source digest: sha256:e8207eb0b6f09fbc1714420abfaf7e76203f514240a8587e00a4193f6fc585d7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion stock_inventory_verification_request/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Stock Inventory Verification Request",
"summary": "Adds the capability to request a Slot Verification when "
"a inventory is Pending to Approve",
"version": "15.0.1.0.0",
"version": "15.0.1.1.0",
"maintainers": ["LoisRForgeFlow"],
"author": "ForgeFlow, " "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-warehouse",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def _compute_created_inventory_count(self):
column1="slot_verification_request_id",
column2="move_line_id",
string="Involved Stock Moves",
compute="_compute_involved_move_lines",
store=False,
)
involved_move_line_count = fields.Integer(
compute="_compute_involved_move_line_count"
Expand All @@ -110,6 +112,8 @@ def _compute_created_inventory_count(self):
column1="slot_verification_request_id",
column2="quant_id",
string="Involved Inventory Quants",
compute="_compute_involved_quants",
store=False,
)
involved_quant_count = fields.Integer(compute="_compute_involved_quant_count")
created_inventory_ids = fields.One2many(
Expand All @@ -120,6 +124,29 @@ def _compute_created_inventory_count(self):
)
created_inventory_count = fields.Integer(compute="_compute_created_inventory_count")

@api.depends("location_id", "product_id", "lot_id", "state")
def _compute_involved_move_lines(self):
for rec in self:
# Only compute when state is 'open' to prevent irrelevant data accumulation.
# No need to accumulate movements for a 'solved' or 'cancelled'
# SVR a lot of time after resolution.
if rec.state == "open":
rec.involved_move_line_ids = self.env["stock.move.line"].search(
rec._get_involved_move_lines_domain()
)
else:
rec.involved_move_line_ids = self.env["stock.move.line"]

@api.depends("location_id", "product_id", "lot_id", "state")
def _compute_involved_quants(self):
for rec in self:
if rec.state == "open":
rec.involved_quant_ids = self.env["stock.quant"].search(
rec._get_involved_quants_domain()
)
else:
rec.involved_quant_ids = self.env["stock.quant"]

def _get_involved_move_lines_domain(self):
domain = [
"|",
Expand All @@ -140,24 +167,8 @@ def _get_involved_quants_domain(self):
domain.append(("lot_id", "=", self.lot_id.id))
return domain

def _get_involved_quants_and_locations(self):
involved_move_lines = self.env["stock.move.line"].search(
self._get_involved_move_lines_domain()
)
involved_quants = self.env["stock.quant"].search(
self._get_involved_quants_domain()
)
return involved_move_lines, involved_quants

def action_confirm(self):
self.write({"state": "open"})
for rec in self:
(
involved_moves_lines,
involved_quants,
) = rec._get_involved_quants_and_locations()
rec.involved_move_line_ids = involved_moves_lines
rec.involved_quant_ids = involved_quants
return True

def action_cancel(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Stock Inventory Verification Request</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7709b979928555cca3d1036322c3b6979090816cc51c2bb1a9b975c8f3a821fa
!! source digest: sha256:e8207eb0b6f09fbc1714420abfaf7e76203f514240a8587e00a4193f6fc585d7
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/15.0/stock_inventory_verification_request"><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-15-0/stock-logistics-warehouse-15-0-stock_inventory_verification_request"><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=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Adds the capability to request a Slot Verification when an inventory is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def setUp(self):
}
).action_apply_inventory()

def test_svr_creation(self):
def test_01_svr_creation(self):
"""Tests the creation of Slot Verification Requests."""
inventory = self.obj_inventory.create(
{
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_svr_creation(self):
for quant in inventory.stock_quant_ids:
quant.action_open_svr()

def test_svr_workflow(self):
def test_02_svr_workflow(self):
"""Tests workflow of Slot Verification Request."""
test_svr = self.env["stock.slot.verification.request"].create(
{
Expand Down Expand Up @@ -135,7 +135,7 @@ def test_svr_workflow(self):
"Slot Verification Request not marked as cancelled.",
)

def test_view_methods(self):
def test_03_view_methods(self):
"""Tests the methods used to handle de UI."""
test_svr = self.env["stock.slot.verification.request"].create(
{
Expand All @@ -152,7 +152,7 @@ def test_view_methods(self):
test_svr.action_view_move_lines()
test_svr.action_view_quants()

def test_svr_full_workflow(self):
def test_04_svr_full_workflow(self):
test_svr = self.env["stock.slot.verification.request"].create(
{
"location_id": self.test_loc.id,
Expand Down Expand Up @@ -182,7 +182,7 @@ def test_svr_full_workflow(self):
"Slot Verification Request not marked as cancelled.",
)

def test_user_permissions_on_svr(self):
def test_05_user_permissions_on_svr(self):
"""Tests that users without the correct permissions cannot change SVR state."""
test_svr = self.env["stock.slot.verification.request"].create(
{
Expand All @@ -197,17 +197,69 @@ def test_user_permissions_on_svr(self):
with self.assertRaises(AccessError):
test_svr.with_user(self.user).action_solved()

def test_06_action_view_methods(self):
"""Tests the view methods in Slot Verification Request."""
svr = self.obj_svr.create(
{
"location_id": self.test_loc.id,
"state": "wait",
"product_id": self.product1.id,
}
)
svr.action_view_move_lines()
svr.action_view_quants()
svr.action_create_inventory_adjustment()
svr.action_view_inventories()

def test_07_involved_move_lines_compute(self):
move = self.obj_move.create(
{
"name": "Test Move",
"product_id": self.product1.id,
"product_uom_qty": 10,
"product_uom": self.product1.uom_id.id,
"location_id": self.test_loc.id,
"location_dest_id": self.test_loc.id,
}
)
move._action_confirm()
move._action_assign()
move_line = move.move_line_ids[0]
test_svr = self.obj_svr.create(
{
"location_id": self.test_loc.id,
"state": "wait",
"product_id": self.product1.id,
}
)
test_svr.action_confirm()
self.assertEqual(
test_svr.state, "open", "Slot Verification Request not confirmed properly."
)
self.assertIn(
move_line,
test_svr.involved_move_line_ids,
"Move line not found in involved_move_line_ids",
)

def test_action_view_methods(self):
"""Tests the view methods in Slot Verification Request."""
svr = self.obj_svr.create(
{
"location_id": self.test_loc.id,
"state": "wait",
"product_id": self.product1.id,
}
)
svr.action_view_move_lines()
svr.action_view_quants()
svr.action_create_inventory_adjustment()
svr.action_view_inventories()
def test_08_involved_quants_compute(self):
self.quant3 = self.env["stock.quant"].create(
{
"location_id": self.test_loc.id,
"product_id": self.product1.id,
"quantity": 20.0,
}
)
test_svr = self.obj_svr.create(
{
"location_id": self.test_loc.id,
"state": "wait",
"product_id": self.product1.id,
}
)
test_svr.action_confirm()
self.assertIn(
self.quant3,
test_svr.involved_quant_ids,
"Quant3 not found in involved_quant_ids",
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<field name="name" />
<field name="location_id" />
<field name="product_id" />
<field name="lot_id" groups="stock.group_production_lot" />
<field name="create_uid" readonly="1" />
<field name="create_date" readonly="1" />
<field name="responsible_id" />
Expand Down Expand Up @@ -71,6 +72,7 @@
type="object"
class="oe_stat_button"
icon="fa-building-o"
attrs="{'invisible':[('created_inventory_count', '=', 0)]}"
>
<field
name="created_inventory_count"
Expand Down Expand Up @@ -119,7 +121,7 @@
<group>
<field name="location_id" />
<field name="product_id" />
<field name="lot_id" />
<field name="lot_id" groups="stock.group_production_lot" />
<field
name="company_id"
groups="base.group_multi_company"
Expand Down

0 comments on commit 01bd440

Please sign in to comment.