Skip to content

Commit

Permalink
[IMP]connector_pms_wubook: unlink draft invoices linked to wubook can…
Browse files Browse the repository at this point in the history
…cel reservation
  • Loading branch information
DarioLodeiros committed Oct 24, 2023
1 parent 6c58997 commit ccb00d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions connector_pms_wubook/models/pms_folio/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ def _after_import(self, binding):
# If Wubook status is 7 (Wubook modification) the folio state is not changed
if binding.wubook_status in ("3", "5", "6") and binding.state != "cancel":
# If folio has draft invoice, cancel invoices:
if folio.move_ids.filtered(lambda x: x.state == "draft"):
folio.move_ids.filtered(lambda x: x.state == "draft").button_cancel()
draft_invoices = folio.move_ids.filtered(lambda x: x.state == "draft")
if draft_invoices:
draft_invoices.button_cancel()
draft_invoices.unlink()
folio.action_cancel()
elif binding.wubook_status in ("1", "2", "4") and binding.state == "cancel":
folio.with_context(confirm_all_reservations=True).action_confirm()
Expand Down
1 change: 1 addition & 0 deletions connector_pms_wubook/models/pms_folio/mapper_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def get_all_items(self, mapper, items, parent, to_attr, options):
draft_invoices = binding.move_ids.filtered(lambda x: x.state == "draft")
if draft_invoices:
draft_invoices.button_cancel()
draft_invoices.unlink()
reservations.filtered(lambda x: x.allowed_cancel).with_context(
modified=True, force_write_blocked=True
).action_cancel()
Expand Down

0 comments on commit ccb00d0

Please sign in to comment.