Skip to content

Commit 2200233

Browse files
[IMP] stock_inventory_verification_request: improvements in order to see in the tree view who has processed the svr and some minor improvements
1 parent 96f8636 commit 2200233

File tree

8 files changed

+140
-46
lines changed

8 files changed

+140
-46
lines changed

stock_inventory_verification_request/README.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.. image:: https://odoo-community.org/readme-banner-image
2-
:target: https://odoo-community.org/get-involved?utm_source=readme
3-
:alt: Odoo Community Association
4-
51
====================================
62
Stock Inventory Verification Request
73
====================================
@@ -17,7 +13,7 @@ Stock Inventory Verification Request
1713
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1814
:target: https://odoo-community.org/page/development-status
1915
:alt: Beta
20-
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
2117
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2218
:alt: License: AGPL-3
2319
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github

stock_inventory_verification_request/__manifest__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"data": [
2020
"security/ir.model.access.csv",
2121
"security/stock_security.xml",
22+
"views/stock_move_line_views.xml",
2223
"views/stock_slot_verification_request_view.xml",
2324
"views/stock_inventory_view.xml",
2425
"views/stock_location_view.xml",

stock_inventory_verification_request/models/stock_inventory.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ def action_request_verification(self):
7575
"product_id": quant.product_id.id,
7676
"company_id": quant.company_id.id,
7777
"lot_id": quant.lot_id.id if quant.lot_id else False,
78+
"inventory_id": quant.current_inventory_id.id
79+
if quant.current_inventory_id
80+
else False,
7881
}
7982
)
8083
quant.requested_verification = True

stock_inventory_verification_request/models/stock_slot_verification_request.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017-20 ForgeFlow S.L.
1+
# Copyright 2017-25 ForgeFlow S.L.
22
# (http://www.forgeflow.com)
33
# Copyright 2025 OERP Canada <https://www.oerp.ca>
44
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
@@ -82,6 +82,12 @@ def _compute_created_inventory_count(self):
8282
readonly=True,
8383
tracking=True,
8484
)
85+
product_name = fields.Char(
86+
"Product", related="product_id.name", store=True, translate=False
87+
)
88+
product_default_code = fields.Char(
89+
related="product_id.default_code", store=True, translate=False
90+
)
8591
lot_id = fields.Many2one(
8692
comodel_name="stock.lot",
8793
string="Lot",
@@ -115,16 +121,19 @@ def _compute_created_inventory_count(self):
115121
comodel_name="stock.inventory",
116122
string="Created Inventories",
117123
inverse_name="solving_slot_verification_request_id",
118-
help="These inventory adjustment were created from this SVR.",
124+
help="These inventory adjustments were created from this SVR.",
119125
)
120126
created_inventory_count = fields.Integer(compute="_compute_created_inventory_count")
127+
processed_by = fields.Many2one(
128+
"res.users",
129+
readonly=True,
130+
copy=False,
131+
help="User who has solved or cancelled the request.",
132+
)
121133

122134
@api.depends("location_id", "product_id", "lot_id", "state")
123135
def _compute_involved_move_lines(self):
124136
for rec in self:
125-
# Only compute when state is 'open' to prevent irrelevant data accumulation.
126-
# No need to accumulate movements for a 'solved' or 'cancelled'
127-
# SVR a lot of time after resolution.
128137
if rec.state == "open":
129138
rec.involved_move_line_ids = self.env["stock.move.line"].search(
130139
rec._get_involved_move_lines_domain()
@@ -167,22 +176,33 @@ def action_confirm(self):
167176
return True
168177

169178
def action_cancel(self):
170-
self.write({"state": "cancelled"})
179+
self.write(
180+
{
181+
"state": "cancelled",
182+
"processed_by": self.env.uid,
183+
}
184+
)
171185
if self.quant_id:
172186
self.quant_id.requested_verification = False
173187
return True
174188

175189
def action_solved(self):
176-
self.write({"state": "done"})
190+
self.write(
191+
{
192+
"state": "done",
193+
"processed_by": self.env.uid,
194+
}
195+
)
177196
if self.quant_id:
178197
self.quant_id.requested_verification = False
179198
return True
180199

181200
def action_view_move_lines(self):
182-
action = self.env.ref("stock.stock_move_line_action")
183-
result = action.read()[0]
184-
result["context"] = {}
201+
action = self.env.ref(
202+
"stock_inventory_verification_request.action_move_lines_svr"
203+
).read()[0]
185204
moves_ids = self.mapped("involved_move_line_ids").ids
205+
result = action
186206
result["domain"] = [("id", "in", moves_ids)]
187207
return result
188208

@@ -218,7 +238,6 @@ def action_create_inventory_adjustment(self):
218238
)
219239
action = self.env.ref("stock_inventory.action_view_inventory_group_form")
220240
result = action.read()[0]
221-
222241
res = self.env.ref("stock_inventory.view_inventory_group_form", False)
223242
result["views"] = [(res and res.id or False, "form")]
224243
result["res_id"] = inventory.id

stock_inventory_verification_request/static/description/index.html

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Stock Inventory Verification Request</title>
77
<style type="text/css">
88

99
/*
1010
:Author: David Goodger ([email protected])
11-
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
11+
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
1212
:Copyright: This stylesheet has been placed in the public domain.
1313
1414
Default cascading style sheet for the HTML output of Docutils.
15-
Despite the name, some widely supported CSS2 features are used.
1615
1716
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1817
customize this style sheet.
@@ -275,7 +274,7 @@
275274
margin-left: 2em ;
276275
margin-right: 2em }
277276

278-
pre.code .ln { color: gray; } /* line numbers */
277+
pre.code .ln { color: grey; } /* line numbers */
279278
pre.code, code { background-color: #eeeeee }
280279
pre.code .comment, code .comment { color: #5C6576 }
281280
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +300,7 @@
301300
span.pre {
302301
white-space: pre }
303302

304-
span.problematic, pre.problematic {
303+
span.problematic {
305304
color: red }
306305

307306
span.section-subtitle {
@@ -360,21 +359,16 @@
360359
</style>
361360
</head>
362361
<body>
363-
<div class="document">
362+
<div class="document" id="stock-inventory-verification-request">
363+
<h1 class="title">Stock Inventory Verification Request</h1>
364364

365-
366-
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367-
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368-
</a>
369-
<div class="section" id="stock-inventory-verification-request">
370-
<h1>Stock Inventory Verification Request</h1>
371365
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372366
!! This file is generated by oca-gen-addon-readme !!
373367
!! changes will be overwritten. !!
374368
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375369
!! source digest: sha256:f3bc9bf64a73db5a8cd369d1690d4376973ab74fe4d2a53300ed3dc91869b263
376370
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<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/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/stock-logistics-warehouse/tree/18.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-18-0/stock-logistics-warehouse-18-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=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
371+
<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/18.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-18-0/stock-logistics-warehouse-18-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=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378372
<p>Adds the capability to request a Slot Verification when an inventory is
379373
‘Pending to Approve’ or create one at will when a potential issue with a
380374
specific location is found. When asked from an inventory adjustment,
@@ -406,7 +400,7 @@ <h1>Stock Inventory Verification Request</h1>
406400
</ul>
407401
</div>
408402
<div class="section" id="usage">
409-
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
403+
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
410404
<p>In order to use this module act as follow:</p>
411405
<ul class="simple">
412406
<li>From a Inventory Adjustment in state ‘Pending to Approve’ click in the
@@ -421,23 +415,23 @@ <h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
421415
<p>You can also create the SVR manually.</p>
422416
</div>
423417
<div class="section" id="bug-tracker">
424-
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
418+
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
425419
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
426420
In case of trouble, please check there if your issue has already been reported.
427421
If you spotted it first, help us to smash it by providing a detailed and welcomed
428422
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_inventory_verification_request%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
429423
<p>Do not contact contributors directly about support or help with technical issues.</p>
430424
</div>
431425
<div class="section" id="credits">
432-
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
426+
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
433427
<div class="section" id="authors">
434-
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
428+
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
435429
<ul class="simple">
436430
<li>ForgeFlow</li>
437431
</ul>
438432
</div>
439433
<div class="section" id="contributors">
440-
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
434+
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
441435
<ul class="simple">
442436
<li>Lois Rilo Antelo &lt;<a class="reference external" href="mailto:lois.rilo&#64;forgeflow.com">lois.rilo&#64;forgeflow.com</a>&gt;</li>
443437
<li>Michael Allen &lt;<a class="reference external" href="mailto:mallen&#64;opensourceintegrators.com">mallen&#64;opensourceintegrators.com</a>&gt;</li>
@@ -447,11 +441,9 @@ <h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
447441
</ul>
448442
</div>
449443
<div class="section" id="maintainers">
450-
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
444+
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
451445
<p>This module is maintained by the OCA.</p>
452-
<a class="reference external image-reference" href="https://odoo-community.org">
453-
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
454-
</a>
446+
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
455447
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
456448
mission is to support the collaborative development of Odoo features and
457449
promote its widespread use.</p>
@@ -462,6 +454,5 @@ <h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
462454
</div>
463455
</div>
464456
</div>
465-
</div>
466457
</body>
467458
</html>

stock_inventory_verification_request/tests/test_verification_request.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,3 +684,57 @@ def test_action_view_quants(self):
684684
action["domain"],
685685
"Domain must filter the correct quant ID.",
686686
)
687+
688+
def test_09_product_related_fields(self):
689+
svr = self.obj_svr.create(
690+
{
691+
"location_id": self.test_loc.id,
692+
"state": "wait",
693+
"product_id": self.product1.id,
694+
}
695+
)
696+
self.assertEqual(
697+
svr.product_name, "Test Product 1", "Product name not set correctly in SVR."
698+
)
699+
self.assertEqual(
700+
svr.product_default_code,
701+
"PROD1",
702+
"Product default code not set correctly in SVR.",
703+
)
704+
705+
def test_10_processed_by(self):
706+
svr = self.obj_svr.create(
707+
{
708+
"location_id": self.test_loc.id,
709+
"state": "wait",
710+
"product_id": self.product1.id,
711+
}
712+
)
713+
self.assertFalse(svr.processed_by)
714+
svr.action_confirm()
715+
self.assertFalse(
716+
svr.processed_by, "Processed By should remain empty after confirm."
717+
)
718+
svr.action_solved()
719+
self.assertEqual(
720+
svr.processed_by.id,
721+
self.env.uid,
722+
"Processed By not set correctly after solved action.",
723+
)
724+
svr_cancel = self.obj_svr.create(
725+
{
726+
"location_id": self.test_loc.id,
727+
"state": "wait",
728+
"product_id": self.product1.id,
729+
}
730+
)
731+
svr_cancel.action_confirm()
732+
self.assertFalse(
733+
svr_cancel.processed_by, "Processed By should remain empty after confirm."
734+
)
735+
svr_cancel.action_cancel()
736+
self.assertEqual(
737+
svr_cancel.processed_by.id,
738+
self.env.uid,
739+
"Processed By not set correctly after cancel action.",
740+
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!-- Copyright 2025 ForgeFlow S.L.
3+
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
4+
<odoo>
5+
<record id="view_move_line_tree_svr" model="ir.ui.view">
6+
<field name="name">stock.move.line.tree.svr</field>
7+
<field name="model">stock.move.line</field>
8+
<field name="inherit_id" ref="stock.view_move_line_tree" />
9+
<field name="arch" type="xml">
10+
<list position="attributes">
11+
<attribute name="default_order">date desc</attribute>
12+
</list>
13+
</field>
14+
</record>
15+
<record id="action_move_lines_svr" model="ir.actions.act_window">
16+
<field name="name">Product Moves Involved</field>
17+
<field name="res_model">stock.move.line</field>
18+
<field name="view_mode">list,form</field>
19+
<field
20+
name="view_id"
21+
ref="stock_inventory_verification_request.view_move_line_tree_svr"
22+
/>
23+
<field name="domain">[]</field>
24+
<field name="context">{}</field>
25+
</record>
26+
</odoo>

stock_inventory_verification_request/views/stock_slot_verification_request_view.xml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
<field name="arch" type="xml">
1010
<list default_order="id desc">
1111
<field name="name" />
12+
<field name="product_id" invisible="1" />
13+
<field name="product_default_code" />
14+
<field name="product_name" />
1215
<field name="location_id" />
13-
<field name="product_id" />
1416
<field name="lot_id" groups="stock.group_production_lot" />
15-
<field name="create_uid" readonly="1" />
17+
<field name="create_uid" readonly="1" invisible="1" />
1618
<field name="create_date" readonly="1" />
1719
<field name="responsible_id" />
18-
<field name="inventory_id" />
20+
<field name="inventory_id" optional="hide" />
21+
<field name="processed_by" />
1922
<field name="state" />
2023
<field name="company_id" groups="base.group_multi_company" />
2124
</list>
@@ -90,9 +93,9 @@
9093
<field
9194
name="involved_move_line_count"
9295
widget="statinfo"
93-
string="Stock Moves Involved"
94-
help="Stock Moves related to the given location and product."
96+
help="Product Moves related to the given location and Product/lot."
9597
modifiers="{'readonly': true}"
98+
string="Product Moves Involved"
9699
/>
97100
</button>
98101
<button
@@ -129,11 +132,12 @@
129132
name="company_id"
130133
groups="base.group_multi_company"
131134
/>
132-
<field name="create_uid" readonly="1" />
133135
<field name="create_date" readonly="1" />
136+
<field name="create_uid" readonly="1" invisible="1" />
134137
<field name="responsible_id" />
135138
<field name="inventory_id" />
136-
<field name="quant_id" />
139+
<field name="processed_by" readonly="1" />
140+
<field name="quant_id" invisible="1" />
137141
</group>
138142
<group>
139143
<field name="notes" />

0 commit comments

Comments
 (0)