Skip to content

Commit 8b3802c

Browse files
committed
[IMP] stock_picking_loss_quantity: Don't lock void ids
1 parent 0fb52be commit 8b3802c

File tree

2 files changed

+36
-27
lines changed

2 files changed

+36
-27
lines changed

stock_picking_operation_loss_quantity/models/stock_quant.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
# Copyright 2018 Okia SPRL <[email protected]>
33
# Copyright 2023 ACSONE SA/NV
44
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
5+
import logging
6+
57
from odoo import models
68

9+
_logger = logging.getLogger(__name__)
10+
711

812
class StockQuant(models.Model):
913

@@ -16,10 +20,16 @@ def _lock_quants_for_loss(self):
1620
1721
TODO: Externalize this in a separate module
1822
"""
19-
self.env.cr.execute(
20-
"SELECT id FROM stock_quant WHERE id in %s FOR UPDATE NOWAIT",
21-
(tuple(self.ids),),
22-
)
23+
if not self.ids:
24+
_logger.warning(
25+
"You try to lock quants for update in a loss operation, "
26+
"but without ids provided."
27+
)
28+
else:
29+
self.env.cr.execute(
30+
"SELECT id FROM stock_quant WHERE id in %s FOR UPDATE NOWAIT",
31+
(tuple(self.ids),),
32+
)
2333

2434
def _apply_inventory(self):
2535
"""When an inventory is validated, we need to cancel any remaining

stock_picking_operation_loss_quantity/static/description/index.html

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
43
<head>
54
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6-
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
5+
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
76
<title>Stock Picking Operation Loss Quantity</title>
87
<style type="text/css">
98

109
/*
1110
:Author: David Goodger ([email protected])
12-
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
11+
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
1312
:Copyright: This stylesheet has been placed in the public domain.
1413
1514
Default cascading style sheet for the HTML output of Docutils.
1615
17-
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
16+
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1817
customize this style sheet.
1918
*/
2019

@@ -369,7 +368,7 @@ <h1 class="title">Stock Picking Operation Loss Quantity</h1>
369368
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370369
!! source digest: sha256:34adfe790ce497d9ad0d0c218e587880cae283d4bd8eef450871e220372076cb
371370
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external" 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" 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-workflow/tree/16.0/stock_picking_operation_loss_quantity"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_picking_operation_loss_quantity"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&amp;target_branch=16.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-workflow/tree/16.0/stock_picking_operation_loss_quantity"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_picking_operation_loss_quantity"><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-workflow&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373372
<p>This module allows to declare loss product quantities during picking
374373
operations.</p>
375374
<p>To avoid unwanted stock losses if it is not justified, movements will be
@@ -379,21 +378,21 @@ <h1 class="title">Stock Picking Operation Loss Quantity</h1>
379378
<p><strong>Table of contents</strong></p>
380379
<div class="contents local topic" id="contents">
381380
<ul class="simple">
382-
<li><a class="reference internal" href="#use-cases-context" id="id1">Use Cases / Context</a></li>
383-
<li><a class="reference internal" href="#configuration" id="id2">Configuration</a></li>
384-
<li><a class="reference internal" href="#usage" id="id3">Usage</a></li>
385-
<li><a class="reference internal" href="#known-issues-roadmap" id="id4">Known issues / Roadmap</a></li>
386-
<li><a class="reference internal" href="#bug-tracker" id="id5">Bug Tracker</a></li>
387-
<li><a class="reference internal" href="#credits" id="id6">Credits</a><ul>
388-
<li><a class="reference internal" href="#authors" id="id7">Authors</a></li>
389-
<li><a class="reference internal" href="#contributors" id="id8">Contributors</a></li>
390-
<li><a class="reference internal" href="#maintainers" id="id9">Maintainers</a></li>
381+
<li><a class="reference internal" href="#use-cases-context" id="toc-entry-1">Use Cases / Context</a></li>
382+
<li><a class="reference internal" href="#configuration" id="toc-entry-2">Configuration</a></li>
383+
<li><a class="reference internal" href="#usage" id="toc-entry-3">Usage</a></li>
384+
<li><a class="reference internal" href="#known-issues-roadmap" id="toc-entry-4">Known issues / Roadmap</a></li>
385+
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-5">Bug Tracker</a></li>
386+
<li><a class="reference internal" href="#credits" id="toc-entry-6">Credits</a><ul>
387+
<li><a class="reference internal" href="#authors" id="toc-entry-7">Authors</a></li>
388+
<li><a class="reference internal" href="#contributors" id="toc-entry-8">Contributors</a></li>
389+
<li><a class="reference internal" href="#maintainers" id="toc-entry-9">Maintainers</a></li>
391390
</ul>
392391
</li>
393392
</ul>
394393
</div>
395394
<div class="section" id="use-cases-context">
396-
<h1><a class="toc-backref" href="#id1">Use Cases / Context</a></h1>
395+
<h1><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h1>
397396
<p>As stock inventories take place asynchronously from stock common
398397
operations, it is better to declare losses at the moment the operator
399398
try to transfer product quantities. He usually has the direct vision on
@@ -403,7 +402,7 @@ <h1><a class="toc-backref" href="#id1">Use Cases / Context</a></h1>
403402
assigned picking, confirm or cancel loss in a second time.</p>
404403
</div>
405404
<div class="section" id="configuration">
406-
<h1><a class="toc-backref" href="#id2">Configuration</a></h1>
405+
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
407406
<ul class="simple">
408407
<li>Go to Inventory &gt; Configuration &gt; Settings &gt; Warehouse</li>
409408
<li>Enable ‘Storage Locations’ and ‘Multi-Step Routes’.</li>
@@ -413,7 +412,7 @@ <h1><a class="toc-backref" href="#id2">Configuration</a></h1>
413412
</ul>
414413
</div>
415414
<div class="section" id="usage">
416-
<h1><a class="toc-backref" href="#id3">Usage</a></h1>
415+
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
417416
<ul class="simple">
418417
<li>You need to have enabled the ‘Show Detailed Operations’ on the
419418
Picking type(s) you want.</li>
@@ -436,40 +435,40 @@ <h1><a class="toc-backref" href="#id3">Usage</a></h1>
436435
</ul>
437436
</div>
438437
<div class="section" id="known-issues-roadmap">
439-
<h1><a class="toc-backref" href="#id4">Known issues / Roadmap</a></h1>
438+
<h1><a class="toc-backref" href="#toc-entry-4">Known issues / Roadmap</a></h1>
440439
<ul class="simple">
441440
<li>Enable loss feature on stock.move level too if ‘Detailed Operations’
442441
feature is disabled.</li>
443442
</ul>
444443
</div>
445444
<div class="section" id="bug-tracker">
446-
<h1><a class="toc-backref" href="#id5">Bug Tracker</a></h1>
445+
<h1><a class="toc-backref" href="#toc-entry-5">Bug Tracker</a></h1>
447446
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/issues">GitHub Issues</a>.
448447
In case of trouble, please check there if your issue has already been reported.
449448
If you spotted it first, help us to smash it by providing a detailed and welcomed
450449
<a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_picking_operation_loss_quantity%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
451450
<p>Do not contact contributors directly about support or help with technical issues.</p>
452451
</div>
453452
<div class="section" id="credits">
454-
<h1><a class="toc-backref" href="#id6">Credits</a></h1>
453+
<h1><a class="toc-backref" href="#toc-entry-6">Credits</a></h1>
455454
<div class="section" id="authors">
456-
<h2><a class="toc-backref" href="#id7">Authors</a></h2>
455+
<h2><a class="toc-backref" href="#toc-entry-7">Authors</a></h2>
457456
<ul class="simple">
458457
<li>ACSONE SA/NV</li>
459458
<li>Okia</li>
460459
<li>BCIM</li>
461460
</ul>
462461
</div>
463462
<div class="section" id="contributors">
464-
<h2><a class="toc-backref" href="#id8">Contributors</a></h2>
463+
<h2><a class="toc-backref" href="#toc-entry-8">Contributors</a></h2>
465464
<ul class="simple">
466465
<li>Jacques-Etienne Baudoux <a class="reference external" href="mailto:je&#64;bcim.be">je&#64;bcim.be</a></li>
467466
<li>Sylvain Van Hoof <a class="reference external" href="mailto:sylvain&#64;okia.be">sylvain&#64;okia.be</a></li>
468467
<li>Denis Roussel <a class="reference external" href="mailto:denis.roussel&#64;acsone.eu">denis.roussel&#64;acsone.eu</a></li>
469468
</ul>
470469
</div>
471470
<div class="section" id="maintainers">
472-
<h2><a class="toc-backref" href="#id9">Maintainers</a></h2>
471+
<h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
473472
<p>This module is maintained by the OCA.</p>
474473
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
475474
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose

0 commit comments

Comments
 (0)