Skip to content

Commit c6e35aa

Browse files
committed
Merge PR #2040 into 16.0
Signed-off-by rousseldenis
2 parents 9ed1916 + 83af01d commit c6e35aa

16 files changed

Lines changed: 777 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../stock_picking_location_check
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
============================
2+
Stock Picking Location Check
3+
============================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:1629c3544e6c20c084a98fd69503dcf4685cc1ff2cf7bbda0b2a5311cc888ba0
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
20+
:target: https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_picking_location_check
21+
:alt: OCA/stock-logistics-warehouse
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_picking_location_check
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-warehouse&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module intends to ensure the consistency between the picking and
32+
its stock move lines at the time of validation.
33+
34+
Here 'consistency' means being in the state where all the locations in
35+
stock move lines are the same as or under that of the corresponding
36+
location in the picking.
37+
38+
**Table of contents**
39+
40+
.. contents::
41+
:local:
42+
43+
Use Cases / Context
44+
===================
45+
46+
Users sometimes change locations (location_id/location_dest_id) in the
47+
picking after reserving stock, and forget to update the corresponding
48+
locations in the detailed operations. This oversight can lead to the
49+
generation of stock transactions with incorrect locations.
50+
51+
Usage
52+
=====
53+
54+
An error should be displayed when validating a picking in case any of
55+
the locations involved in the move lines is not part of the
56+
corresponding location in the picking.
57+
58+
Selecting 'Allow Location Inconsistency' lets users bypass this error.
59+
60+
Bug Tracker
61+
===========
62+
63+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
64+
In case of trouble, please check there if your issue has already been reported.
65+
If you spotted it first, help us to smash it by providing a detailed and welcomed
66+
`feedback <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20stock_picking_location_check%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
67+
68+
Do not contact contributors directly about support or help with technical issues.
69+
70+
Credits
71+
=======
72+
73+
Authors
74+
-------
75+
76+
* Quartile
77+
78+
Contributors
79+
------------
80+
81+
- `Quartile <https://www.quartile.co>`__:
82+
83+
- Aung Ko Ko Lin
84+
- Yoshi Tashiro
85+
86+
Maintainers
87+
-----------
88+
89+
This module is maintained by the OCA.
90+
91+
.. image:: https://odoo-community.org/logo.png
92+
:alt: Odoo Community Association
93+
:target: https://odoo-community.org
94+
95+
OCA, or the Odoo Community Association, is a nonprofit organization whose
96+
mission is to support the collaborative development of Odoo features and
97+
promote its widespread use.
98+
99+
This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/16.0/stock_picking_location_check>`_ project on GitHub.
100+
101+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2024 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
3+
4+
{
5+
"name": "Stock Picking Location Check",
6+
"summary": "Ensure picking and move line locations are consistent",
7+
"version": "16.0.1.0.0",
8+
"author": "Quartile, Odoo Community Association (OCA)",
9+
"website": "https://github.com/OCA/stock-logistics-warehouse",
10+
"license": "AGPL-3",
11+
"depends": ["stock"],
12+
"category": "Stock",
13+
"data": [
14+
"views/stock_picking_views.xml",
15+
],
16+
"maintainers": ["yostashiro", "aungkokolin1997"],
17+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * stock_picking_location_check
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 16.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2024-05-20 04:25+0000\n"
10+
"PO-Revision-Date: 2024-05-20 04:25+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: stock_picking_location_check
19+
#. odoo-python
20+
#: code:addons/stock_picking_location_check/models/stock_picking.py:0
21+
#, python-format
22+
msgid "A move line location is not related to that of the picking: %s"
23+
msgstr "移動明細のロケーションが運送のものと不整合です: %s"
24+
25+
#. module: stock_picking_location_check
26+
#: model:ir.model.fields,field_description:stock_picking_location_check.field_stock_picking__allow_location_inconsistency
27+
msgid "Allow Location Inconsistency"
28+
msgstr "ロケーション不整合を許可"
29+
30+
#. module: stock_picking_location_check
31+
#: model:ir.model.fields,help:stock_picking_location_check.field_stock_picking__allow_location_inconsistency
32+
msgid ""
33+
"If enabled, no error is raised for location inconsistency between picking "
34+
"and its move lines at the time of validation."
35+
msgstr "選択した場合、検証時に運送と移動明細で不整合があってもエラーを出しません。"
36+
37+
#. module: stock_picking_location_check
38+
#: model:ir.model,name:stock_picking_location_check.model_stock_picking
39+
msgid "Transfer"
40+
msgstr "運送"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import stock_picking
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2024 Quartile (https://www.quartile.co)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
3+
4+
from odoo import _, fields, models
5+
from odoo.exceptions import UserError
6+
from odoo.tools.float_utils import float_compare
7+
8+
9+
class StockPicking(models.Model):
10+
_inherit = "stock.picking"
11+
12+
allow_location_inconsistency = fields.Boolean(
13+
copy=False,
14+
help="If enabled, no error is raised for location inconsistency between "
15+
"picking and its move lines at the time of validation.",
16+
)
17+
18+
def _get_child_location_ids(self, location):
19+
return self.env["stock.location"].search(
20+
[("id", "child_of", location.id), ("usage", "!=", "view")]
21+
)
22+
23+
def _check_location_consistency(self, pick_location, line_locations):
24+
self.ensure_one()
25+
if not set(line_locations).issubset(
26+
self._get_child_location_ids(pick_location)
27+
):
28+
raise UserError(
29+
_(
30+
"A move line location is not related to that of the picking: %s",
31+
self.name,
32+
)
33+
)
34+
35+
def _action_done(self):
36+
for pick in self:
37+
if pick.allow_location_inconsistency:
38+
continue
39+
line_source_locations = [
40+
line.location_id
41+
for line in pick.move_line_ids
42+
if not getattr(line.move_id, "is_subcontract", False)
43+
]
44+
pick._check_location_consistency(pick.location_id, line_source_locations)
45+
if pick._check_immediate():
46+
line_dest_locations = pick.move_line_ids.location_dest_id
47+
else:
48+
line_dest_locations = pick.move_line_ids.filtered(
49+
lambda line: float_compare(
50+
line.qty_done,
51+
0.0,
52+
precision_rounding=line.product_uom_id.rounding,
53+
)
54+
> 0
55+
).mapped("location_dest_id")
56+
pick._check_location_consistency(pick.location_dest_id, line_dest_locations)
57+
return super()._action_done()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Users sometimes change locations (location_id/location_dest_id) in the picking after
2+
reserving stock, and forget to update the corresponding locations in the detailed
3+
operations. This oversight can lead to the generation of stock transactions with
4+
incorrect locations.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- [Quartile](https://www.quartile.co):
2+
- Aung Ko Ko Lin
3+
- Yoshi Tashiro

0 commit comments

Comments
 (0)