diff --git a/despatch_advice_import/__manifest__.py b/despatch_advice_import/__manifest__.py index cb879e543c..8cd8545288 100644 --- a/despatch_advice_import/__manifest__.py +++ b/despatch_advice_import/__manifest__.py @@ -8,7 +8,8 @@ "version": "16.0.1.2.0", "website": "https://github.com/OCA/edi", "license": "AGPL-3", - "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "author": "ACSONE SA/NV,BCIM,Odoo Community Association (OCA)", + "maintainers": ["jbaudoux"], "depends": ["purchase", "purchase_stock", "base_business_document_import"], "data": ["security/ir.model.access.csv", "wizard/despatch_advice_import.xml"], "demo": [], diff --git a/despatch_advice_import/wizard/despatch_advice_import.py b/despatch_advice_import/wizard/despatch_advice_import.py index 17a64b672e..eba1923e1d 100644 --- a/despatch_advice_import/wizard/despatch_advice_import.py +++ b/despatch_advice_import/wizard/despatch_advice_import.py @@ -1,4 +1,5 @@ # Copyright 2020 ACSONE SA/NV +# Copyright 2025 Jacques-Etienne Baudoux (BCIM) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import logging @@ -202,11 +203,11 @@ def process_data(self, parsed_order_document): self._process_picking_done(lines[0].move_ids[0]) def _process_picking_done(self, move): - if all([line.quantity_done != 0 for line in move.picking_id.move_ids]): - move.picking_id.button_validate() - else: - picking = move.picking_id - picking.with_context(skip_backorder=True).button_validate() + picking = move.picking_id + if all(line.state == "cancel" for line in picking.move_ids): + return True + # skip backorder wizard + picking.with_context(skip_backorder=True).button_validate() def _process_rejected(self, stock_moves, parsed_order_document): parsed_order_document["chatter_msg"] = parsed_order_document.get( @@ -216,7 +217,10 @@ def _process_rejected(self, stock_moves, parsed_order_document): _("Delivery cancelled by the supplier.") ) - stock_moves._action_cancel() + # Loose dependency with stock_picking_restrict_cancel_printed module + # that checks we are canceling the backorder to allow move cancellation. + # Mimic odoo setting this cancel_backorder context variable in this case. + stock_moves.with_context(cancel_backorder=True)._action_cancel() def _process_accepted(self, stock_moves, parsed_order_document, forced_qty=False): parsed_order_document["chatter_msg"] = ( @@ -296,7 +300,10 @@ def _process_conditional(self, moves, parsed_order_document, line): # cancel moves to cancel if move_ids_to_cancel: moves_to_cancel = self.env["stock.move"].browse(move_ids_to_cancel) - moves_to_cancel._action_cancel() + # Loose dependency with stock_picking_restrict_cancel_printed module + # that checks we are canceling the backorder to allow move cancellation. + # Mimic odoo setting this cancel_backorder context variable in this case. + moves_to_cancel.with_context(cancel_backorder=True)._action_cancel() # move backorder moves to a backorder if move_ids_to_backorder: moves_to_backorder = self.env["stock.move"].browse(move_ids_to_backorder)