From 415cd2c33f9aff78956fca46fc7dd260376d46c2 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Wed, 7 Dec 2022 17:09:20 +0100 Subject: [PATCH] stock_release_channel: assign channel When the move is not generated by a SO, also assign the release channel --- stock_release_channel/models/__init__.py | 1 - .../models/sale_order_line.py | 22 ------------------- stock_release_channel/models/stock_move.py | 7 ++++++ 3 files changed, 7 insertions(+), 23 deletions(-) delete mode 100644 stock_release_channel/models/sale_order_line.py diff --git a/stock_release_channel/models/__init__.py b/stock_release_channel/models/__init__.py index 0c03017164..66e7660731 100644 --- a/stock_release_channel/models/__init__.py +++ b/stock_release_channel/models/__init__.py @@ -1,4 +1,3 @@ -from . import sale_order_line from . import stock_move from . import stock_picking from . import stock_release_channel diff --git a/stock_release_channel/models/sale_order_line.py b/stock_release_channel/models/sale_order_line.py deleted file mode 100644 index 876f202a6c..0000000000 --- a/stock_release_channel/models/sale_order_line.py +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2020 Camptocamp -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) - -from odoo import models - - -class SaleOrderLine(models.Model): - _inherit = "sale.order.line" - - def _action_launch_stock_rule(self, previous_product_uom_qty=False): - # As the user who confirms the order might not have enough access rights to process - # the order (using orderpoints, assign channels, etc...) we use sudo here - self = self.sudo() - result = super()._action_launch_stock_rule( - previous_product_uom_qty=previous_product_uom_qty - ) - pickings = self.move_ids.picking_id - # ensure we assign a channel on any picking OUT generated for the sale, - # if moves are assigned to an existing transfer, we recompute the - # channel - pickings._delay_assign_release_channel() - return result diff --git a/stock_release_channel/models/stock_move.py b/stock_release_channel/models/stock_move.py index 87e548cccb..e653533211 100644 --- a/stock_release_channel/models/stock_move.py +++ b/stock_release_channel/models/stock_move.py @@ -15,3 +15,10 @@ def release_available_to_promise(self): res = super().release_available_to_promise() self.picking_id.assign_release_channel() return res + + def _action_confirm(self, merge=True, merge_into=False): + moves = super()._action_confirm(merge=merge, merge_into=merge_into) + pickings = moves.filtered("need_release").picking_id + if pickings: + pickings._delay_assign_release_channel() + return moves