Skip to content
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

[16.0][FIX] despatch_advice_import: fix processing #1109

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion despatch_advice_import/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand Down
24 changes: 16 additions & 8 deletions despatch_advice_import/wizard/despatch_advice_import.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2020 ACSONE SA/NV
# Copyright 2025 Jacques-Etienne Baudoux (BCIM) <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging
Expand Down Expand Up @@ -202,11 +203,19 @@
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

Check warning on line 208 in despatch_advice_import/wizard/despatch_advice_import.py

View check run for this annotation

Codecov / codecov/patch

despatch_advice_import/wizard/despatch_advice_import.py#L208

Added line #L208 was not covered by tests
# skip backorder wizard
picking.with_context(
skip_immediate=True, skip_backorder=True, skip_sms=True, skip_expired=True
).button_validate()

def _cancel_extra_moves(self, moves):
# 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.with_context(cancel_backorder=True)._action_cancel()

def _process_rejected(self, stock_moves, parsed_order_document):
parsed_order_document["chatter_msg"] = parsed_order_document.get(
Expand All @@ -215,8 +224,7 @@
parsed_order_document["chatter_msg"].append(
_("Delivery cancelled by the supplier.")
)

stock_moves._action_cancel()
self._cancel_extra_moves(stock_moves)

Check warning on line 227 in despatch_advice_import/wizard/despatch_advice_import.py

View check run for this annotation

Codecov / codecov/patch

despatch_advice_import/wizard/despatch_advice_import.py#L227

Added line #L227 was not covered by tests

def _process_accepted(self, stock_moves, parsed_order_document, forced_qty=False):
parsed_order_document["chatter_msg"] = (
Expand Down Expand Up @@ -296,7 +304,7 @@
# 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()
self._cancel_extra_moves(moves_to_cancel)
# move backorder moves to a backorder
if move_ids_to_backorder:
moves_to_backorder = self.env["stock.move"].browse(move_ids_to_backorder)
Expand Down
Loading