-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[14.0][IMP] stock_warehouse_flow: Improve flow matching #991
base: 14.0
Are you sure you want to change the base?
Changes from all commits
5f3f161
a72999c
1852829
6850896
7a75420
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../stock_warehouse_flow_delivery_refresh |
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, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,31 @@ | |
|
||
|
||
class TestWarehouseFlow(common.CommonFlow): | ||
def test_flow_search_after_applied(self): | ||
flow_ship_only = self._get_flow("ship_only") | ||
flow_pick_ship = self._get_flow("pick_ship") | ||
moves_before = self.env["stock.move"].search([]) | ||
self._run_procurement(self.product, 10, flow_pick_ship.carrier_ids) | ||
moves = self.env["stock.move"].search([("id", "not in", moves_before.ids)]) | ||
move_ship = moves.filtered(lambda m: m.picking_type_id.code == "outgoing") | ||
# When flow was applied to move, picking type set by odoo was saved | ||
# in default_picking_type_id, and flow.to_picking_type_id is set | ||
self.assertEqual(move_ship.picking_type_id, flow_pick_ship.to_picking_type_id) | ||
default_type = self.env.ref("stock.picking_type_out") | ||
self.assertEqual(move_ship.default_picking_type_id, default_type) | ||
# Only pick_ship matches, because there's a constraint on the carrier | ||
matching_flows = self.env["stock.warehouse.flow"]._search_for_move(move_ship) | ||
self.assertEqual(matching_flows, flow_pick_ship) | ||
# Drop the carrier from the procurement, only direct flow should match | ||
move_ship.group_id.carrier_id = False | ||
matching_flows = self.env["stock.warehouse.flow"]._search_for_move(move_ship) | ||
self.assertEqual(matching_flows, flow_ship_only) | ||
# Drop default_picking_type_id, no flow is found, because | ||
# now flow has Delivery Orders POST as from_picking_type_id | ||
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure to understand this comment. Current move operation type (which has been updated at the beginning) doesn't match any flows? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You create the move with picking type A. |
||
move_ship.default_picking_type_id = False | ||
matching_flows = self.env["stock.warehouse.flow"]._search_for_move(move_ship) | ||
self.assertFalse(matching_flows) | ||
|
||
def test_flow_ship_only(self): | ||
"""Replace the initial move by a 'ship_only' move.""" | ||
# NOTE: use the recorder when migrating to 15.0 to catch created moves | ||
|
@@ -65,6 +90,17 @@ def test_flow_pick_ship(self): | |
self.assertEqual(move_ship.state, "assigned") | ||
self._validate_picking(move_ship.picking_id) | ||
|
||
def test_disable_flow_at_move_confirm(self): | ||
flow = self._get_flow("pick_ship") | ||
# It is False by default | ||
flow.impacted_route_ids.disable_warehouse_flow_on_confirm = True | ||
moves_before = self.env["stock.move"].search([]) | ||
self._run_procurement(self.product, 10, flow.carrier_ids) | ||
moves = self.env["stock.move"].search([("id", "not in", moves_before.ids)]) | ||
move_ship = moves.filtered(lambda m: m.picking_type_id.code == "outgoing") | ||
# ensure new move doesn't have flow.to_picking_type_id as picking type | ||
self.assertNotEqual(move_ship.picking_type_id, flow.to_picking_type_id) | ||
|
||
def test_no_rule_found_on_delivery_route(self): | ||
flow = self._get_flow("pick_ship") | ||
# Remove the rule | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
===================================== | ||
Stock Warehouse Flow Delivery Refresh | ||
===================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:8de340e2095dadbecd3245322179db3413e3b25e0da75bd649643ab997eb7a60 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |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%2Fwms-lightgray.png?logo=github | ||
:target: https://github.com/OCA/wms/tree/14.0/stock_warehouse_flow_delivery_refresh | ||
:alt: OCA/wms | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/wms-14-0/wms-14-0-stock_warehouse_flow_delivery_refresh | ||
: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/wms&target_branch=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This is a glue module between Stock Warehouse Flow and Stock Available On Premise Release. | ||
|
||
This module applies a new Stock Warehouse Flow on Stock Moves when carrier changes on a Stock Picking | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/wms/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/wms/issues/new?body=module:%20stock_warehouse_flow_delivery_refresh%0Aversion:%2014.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 | ||
~~~~~~~ | ||
|
||
* Camptocamp | ||
* BCIM | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Jacques-Etienne Baudoux <je@bcim.be> | ||
* Matthieu Méquignon <matthieu.mequignon@camptocamp.com> | ||
|
||
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. | ||
|
||
This module is part of the `OCA/wms <https://github.com/OCA/wms/tree/14.0/stock_warehouse_flow_delivery_refresh>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "Stock Warehouse Flow Delivery Refresh", | ||
"summary": "Allow to refresh delivery flow when carrier changes", | ||
"version": "14.0.1.0.0", | ||
"category": "Warehouse Management", | ||
"website": "https://github.com/OCA/wms", | ||
"author": "Camptocamp, BCIM, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"installable": True, | ||
"depends": [ | ||
"stock_warehouse_flow", | ||
"stock_available_to_promise_release", | ||
], | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import stock_move | ||
from . import stock_picking |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2025 Camptocamp SA, BCIM | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo import api, models | ||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
def _stock_warehouse_flow_onchange_carrier(self): | ||
flow_model = self.env["stock.warehouse.flow"] | ||
moves_need_release = self.filtered(lambda m: m.picking_id.need_release) | ||
for move in moves_need_release: | ||
flow_model._search_and_apply_for_move(move, assign_picking=True) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2025 Camptocamp SA, BCIM | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
from odoo import api, models | ||
|
||
class StockPicking(models.Model): | ||
_inherit = "stock.picking" | ||
|
||
def write(self, values): | ||
picking_carrier_mapping = {p.id: p.carrier_id for p in self} | ||
super().write(values) | ||
pickings_to_update = self.filtered( | ||
lambda p: picking_carrier_mapping.get(p.id) != p.carrier_id | ||
) | ||
pickings_to_update.move_lines._stock_warehouse_flow_onchange_carrier() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* Jacques-Etienne Baudoux <je@bcim.be> | ||
* Matthieu Méquignon <matthieu.mequignon@camptocamp.com> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This is a glue module between Stock Warehouse Flow and Stock Available On Premise Release. | ||
|
||
This module applies a new Stock Warehouse Flow on Stock Moves when carrier changes on a Stock Picking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as "direct" is used for shipping policy (confusing)