Skip to content

Commit e42d350

Browse files
committed
[ADD] stock_picking_putaway_recompute
1 parent afec509 commit e42d350

File tree

21 files changed

+1018
-0
lines changed

21 files changed

+1018
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../stock_picking_putaway_recompute
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: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
===============================
2+
Stock Picking Putaway Recompute
3+
===============================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:d732c5716c0c78265f37cdfbb2f846a45031a2dcb2792e8e3aca65a9df5c9ca3
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--workflow-lightgray.png?logo=github
20+
:target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_picking_putaway_recompute
21+
:alt: OCA/stock-logistics-workflow
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_picking_putaway_recompute
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-workflow&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module will allow to recompute the destination locations from
32+
putaway rules on the picking operations side.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Use Cases / Context
40+
===================
41+
42+
As stock operations are computed at a certain moment of time,
43+
configuration can change and the computed destination locations for
44+
those operations (that are not done yet) are incoherent from those
45+
configurations changes.
46+
47+
So, the aim of this module is to provide a way to recompute the
48+
destination locations without having to unreserve the picking (that
49+
unlock products for being reserved for another picking).
50+
51+
Configuration
52+
=============
53+
54+
- Enable Stock locations in Inventory > Configuration > Settings
55+
- In order to be able to recompute the putaways, you need to enable it
56+
on the picking type level.
57+
58+
Usage
59+
=====
60+
61+
- In a picking where the recompute operation is enabled (see
62+
Configuration), the recompute is available on picking level and on
63+
the detailed operations if enabled.
64+
- If a putaway rule has been changed after product reservation, click
65+
on the button 'Recompute putaways'. This will recompute the
66+
destination locations on all detailed operations that have no done
67+
quantity yet.
68+
- Moreover, the action is available on picking level and on detailed
69+
operation one too.
70+
71+
Bug Tracker
72+
===========
73+
74+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/issues>`_.
75+
In case of trouble, please check there if your issue has already been reported.
76+
If you spotted it first, help us to smash it by providing a detailed and welcomed
77+
`feedback <https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20stock_picking_putaway_recompute%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
78+
79+
Do not contact contributors directly about support or help with technical issues.
80+
81+
Credits
82+
=======
83+
84+
Authors
85+
-------
86+
87+
* ACSONE SA/NV
88+
89+
Contributors
90+
------------
91+
92+
- Denis Roussel denis.roussel@acsone.eu
93+
94+
Maintainers
95+
-----------
96+
97+
This module is maintained by the OCA.
98+
99+
.. image:: https://odoo-community.org/logo.png
100+
:alt: Odoo Community Association
101+
:target: https://odoo-community.org
102+
103+
OCA, or the Odoo Community Association, is a nonprofit organization whose
104+
mission is to support the collaborative development of Odoo features and
105+
promote its widespread use.
106+
107+
.. |maintainer-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px
108+
:target: https://github.com/rousseldenis
109+
:alt: rousseldenis
110+
111+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
112+
113+
|maintainer-rousseldenis|
114+
115+
This module is part of the `OCA/stock-logistics-workflow <https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_picking_putaway_recompute>`_ project on GitHub.
116+
117+
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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2024 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Stock Picking Putaway Recompute",
6+
"summary": """
7+
This module allows to recompute the picking operations putaways if
8+
configurations have changed""",
9+
"version": "16.0.1.0.0",
10+
"license": "AGPL-3",
11+
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
12+
"website": "https://github.com/OCA/stock-logistics-workflow",
13+
"maintainers": ["rousseldenis"],
14+
"depends": ["stock"],
15+
"data": [
16+
"views/stock_picking.xml",
17+
"views/stock_picking_type.xml",
18+
"views/stock_move_line.xml",
19+
],
20+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import stock_move_line, stock_picking, stock_picking_type
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright 2024 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from __future__ import annotations
4+
5+
from typing_extensions import Self
6+
7+
from odoo import api, fields, models
8+
9+
10+
class StockMoveLine(models.Model):
11+
12+
_inherit = "stock.move.line"
13+
14+
can_recompute_putaways = fields.Boolean(
15+
compute="_compute_can_recompute_putaways",
16+
)
17+
18+
@api.depends(
19+
"picking_type_id.allow_to_recompute_putaways", "picking_id.printed", "qty_done"
20+
)
21+
def _compute_can_recompute_putaways(self):
22+
can_recompute_lines = self._filtered_for_putaway_recompute()
23+
can_recompute_lines.can_recompute_putaways = True
24+
(self - can_recompute_lines).can_recompute_putaways = False
25+
26+
def _filtered_for_putaway_recompute(self) -> Self:
27+
"""
28+
Recompute putaways on operations that:
29+
30+
- have their picking type configured for that
31+
- have their picking not printed (started)
32+
- have their qty_done field != 0
33+
"""
34+
return self.filtered(
35+
lambda line: line.picking_type_id.allow_to_recompute_putaways
36+
and not line.picking_id.printed
37+
and not line.qty_done
38+
)
39+
40+
def _recompute_putaways(self) -> None:
41+
"""
42+
Launches the computation of putaways on operations that are
43+
allowed to.
44+
"""
45+
self._filtered_for_putaway_recompute()._apply_putaway_strategy()
46+
47+
def action_recompute_putaways(self):
48+
self._recompute_putaways()
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2024 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from __future__ import annotations
4+
5+
from typing_extensions import Self
6+
7+
from odoo import api, fields, models
8+
9+
10+
class StockPicking(models.Model):
11+
12+
_inherit = "stock.picking"
13+
14+
can_recompute_putaways = fields.Boolean(
15+
compute="_compute_can_recompute_putaways",
16+
help="Technical field in order to display the Recompute Putaways button.",
17+
)
18+
19+
def action_recompute_putaways(self) -> dict:
20+
"""
21+
Launches the putaways recomputation on operations
22+
"""
23+
for picking in self:
24+
picking.move_line_ids._recompute_putaways()
25+
26+
def _filtered_can_recompute_putaways(self) -> Self:
27+
"""
28+
Filter current recordset in order to get the pickings that can
29+
"""
30+
return self.filtered(
31+
lambda picking: picking.state == "assigned" and not picking.printed
32+
)
33+
34+
@api.depends("state", "printed")
35+
def _compute_can_recompute_putaways(self):
36+
can_recompute_pickings = self._filtered_can_recompute_putaways()
37+
can_recompute_pickings.can_recompute_putaways = True
38+
(self - can_recompute_pickings).can_recompute_putaways = False
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2024 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class StockPickingType(models.Model):
8+
9+
_inherit = "stock.picking.type"
10+
11+
allow_to_recompute_putaways = fields.Boolean(
12+
help="Check this if you want to authorize putaways recomputations for the operations"
13+
"of this type."
14+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Enable Stock locations in Inventory > Configuration > Settings
2+
- In order to be able to recompute the putaways, you need to enable it on
3+
the picking type level.

0 commit comments

Comments
 (0)