Skip to content

Commit

Permalink
[ADD] stock_picking_putaway_recompute
Browse files Browse the repository at this point in the history
  • Loading branch information
rousseldenis committed Oct 9, 2024
1 parent afec509 commit e42d350
Show file tree
Hide file tree
Showing 21 changed files with 1,018 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/stock_picking_putaway_recompute/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
117 changes: 117 additions & 0 deletions stock_picking_putaway_recompute/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
===============================
Stock Picking Putaway Recompute
===============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:d732c5716c0c78265f37cdfbb2f846a45031a2dcb2792e8e3aca65a9df5c9ca3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_picking_putaway_recompute
:alt: OCA/stock-logistics-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/stock-logistics-workflow-16-0/stock-logistics-workflow-16-0-stock_picking_putaway_recompute
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module will allow to recompute the destination locations from
putaway rules on the picking operations side.

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

As stock operations are computed at a certain moment of time,
configuration can change and the computed destination locations for
those operations (that are not done yet) are incoherent from those
configurations changes.

So, the aim of this module is to provide a way to recompute the
destination locations without having to unreserve the picking (that
unlock products for being reserved for another picking).

Configuration
=============

- Enable Stock locations in Inventory > Configuration > Settings
- In order to be able to recompute the putaways, you need to enable it
on the picking type level.

Usage
=====

- In a picking where the recompute operation is enabled (see
Configuration), the recompute is available on picking level and on
the detailed operations if enabled.
- If a putaway rule has been changed after product reservation, click
on the button 'Recompute putaways'. This will recompute the
destination locations on all detailed operations that have no done
quantity yet.
- Moreover, the action is available on picking level and on detailed
operation one too.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`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**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* ACSONE SA/NV

Contributors
------------

- Denis Roussel [email protected]

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-rousseldenis| image:: https://github.com/rousseldenis.png?size=40px
:target: https://github.com/rousseldenis
:alt: rousseldenis

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-rousseldenis|

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.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions stock_picking_putaway_recompute/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions stock_picking_putaway_recompute/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Stock Picking Putaway Recompute",
"summary": """
This module allows to recompute the picking operations putaways if
configurations have changed""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/stock-logistics-workflow",
"maintainers": ["rousseldenis"],
"depends": ["stock"],
"data": [
"views/stock_picking.xml",
"views/stock_picking_type.xml",
"views/stock_move_line.xml",
],
}
1 change: 1 addition & 0 deletions stock_picking_putaway_recompute/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import stock_move_line, stock_picking, stock_picking_type
48 changes: 48 additions & 0 deletions stock_picking_putaway_recompute/models/stock_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from __future__ import annotations

from typing_extensions import Self

from odoo import api, fields, models


class StockMoveLine(models.Model):

_inherit = "stock.move.line"

can_recompute_putaways = fields.Boolean(
compute="_compute_can_recompute_putaways",
)

@api.depends(
"picking_type_id.allow_to_recompute_putaways", "picking_id.printed", "qty_done"
)
def _compute_can_recompute_putaways(self):
can_recompute_lines = self._filtered_for_putaway_recompute()
can_recompute_lines.can_recompute_putaways = True
(self - can_recompute_lines).can_recompute_putaways = False

Check warning on line 24 in stock_picking_putaway_recompute/models/stock_move_line.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_putaway_recompute/models/stock_move_line.py#L22-L24

Added lines #L22 - L24 were not covered by tests

def _filtered_for_putaway_recompute(self) -> Self:
"""
Recompute putaways on operations that:
- have their picking type configured for that
- have their picking not printed (started)
- have their qty_done field != 0
"""
return self.filtered(
lambda line: line.picking_type_id.allow_to_recompute_putaways
and not line.picking_id.printed
and not line.qty_done
)

def _recompute_putaways(self) -> None:
"""
Launches the computation of putaways on operations that are
allowed to.
"""
self._filtered_for_putaway_recompute()._apply_putaway_strategy()

Check warning on line 45 in stock_picking_putaway_recompute/models/stock_move_line.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_putaway_recompute/models/stock_move_line.py#L45

Added line #L45 was not covered by tests

def action_recompute_putaways(self):
self._recompute_putaways()

Check warning on line 48 in stock_picking_putaway_recompute/models/stock_move_line.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_putaway_recompute/models/stock_move_line.py#L48

Added line #L48 was not covered by tests
38 changes: 38 additions & 0 deletions stock_picking_putaway_recompute/models/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from __future__ import annotations

from typing_extensions import Self

from odoo import api, fields, models


class StockPicking(models.Model):

_inherit = "stock.picking"

can_recompute_putaways = fields.Boolean(
compute="_compute_can_recompute_putaways",
help="Technical field in order to display the Recompute Putaways button.",
)

def action_recompute_putaways(self) -> dict:
"""
Launches the putaways recomputation on operations
"""
for picking in self:
picking.move_line_ids._recompute_putaways()

Check warning on line 24 in stock_picking_putaway_recompute/models/stock_picking.py

View check run for this annotation

Codecov / codecov/patch

stock_picking_putaway_recompute/models/stock_picking.py#L24

Added line #L24 was not covered by tests

def _filtered_can_recompute_putaways(self) -> Self:
"""
Filter current recordset in order to get the pickings that can
"""
return self.filtered(
lambda picking: picking.state == "assigned" and not picking.printed
)

@api.depends("state", "printed")
def _compute_can_recompute_putaways(self):
can_recompute_pickings = self._filtered_can_recompute_putaways()
can_recompute_pickings.can_recompute_putaways = True
(self - can_recompute_pickings).can_recompute_putaways = False
14 changes: 14 additions & 0 deletions stock_picking_putaway_recompute/models/stock_picking_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class StockPickingType(models.Model):

_inherit = "stock.picking.type"

allow_to_recompute_putaways = fields.Boolean(
help="Check this if you want to authorize putaways recomputations for the operations"
"of this type."
)
3 changes: 3 additions & 0 deletions stock_picking_putaway_recompute/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Enable Stock locations in Inventory > Configuration > Settings
- In order to be able to recompute the putaways, you need to enable it on
the picking type level.
7 changes: 7 additions & 0 deletions stock_picking_putaway_recompute/readme/CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
As stock operations are computed at a certain moment of time, configuration
can change and the computed destination locations for those operations (that
are not done yet) are incoherent from those configurations changes.

So, the aim of this module is to provide a way to recompute the destination locations
without having to unreserve the picking (that unlock products for being reserved for
another picking).
1 change: 1 addition & 0 deletions stock_picking_putaway_recompute/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Denis Roussel <[email protected]>
2 changes: 2 additions & 0 deletions stock_picking_putaway_recompute/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module will allow to recompute the destination locations from putaway rules
on the picking operations side.
7 changes: 7 additions & 0 deletions stock_picking_putaway_recompute/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- In a picking where the recompute operation is enabled (see Configuration),
the recompute is available on picking level and on the detailed operations if
enabled.
- If a putaway rule has been changed after product reservation, click on
the button 'Recompute putaways'. This will recompute the destination locations
on all detailed operations that have no done quantity yet.
- Moreover, the action is available on picking level and on detailed operation one too.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e42d350

Please sign in to comment.