Skip to content

Commit

Permalink
[MIG] account_move_cancel_confirm: Migration to V12
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiMForgeFlow committed Nov 25, 2024
1 parent cf55dc0 commit 5ee55b8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion account_move_cancel_confirm/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Account Move Cancel Confirm",
"version": "13.0.1.0.0",
"version": "12.0.1.0.0",
"author": "Ecosoft, Odoo Community Association (OCA)",
"category": "Usability",
"license": "AGPL-3",
Expand Down
1 change: 1 addition & 0 deletions account_move_cancel_confirm/model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import account_invoice
from . import account_move
from . import account_payment
30 changes: 30 additions & 0 deletions account_move_cancel_confirm/model/account_invoice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2024 ForgeFlow
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import models


class AccountInvoice(models.Model):
_name = "account.invoice"
_inherit = ["account.invoice", "base.cancel.confirm"]

_has_cancel_reason = "optional" # ["no", "optional", "required"]

def action_invoice_cancel(self):
cancel_res_model = self.env.context.get("cancel_res_model", False)
cancel_res_ids = self.env.context.get("cancel_res_ids", False)
cancel_method = self.env.context.get("cancel_method", False)
# cancel from payment
if cancel_res_model == "account.payment" and cancel_method == "action_cancel":
docs = self.env[cancel_res_model].browse(cancel_res_ids)
cancel_reason = ", ".join(
docs.filtered("cancel_reason").mapped("cancel_reason")
)
self.write({"cancel_confirm": True, "cancel_reason": cancel_reason})
if not self.filtered("cancel_confirm"):
return self.open_cancel_confirm_wizard()
return super().action_invoice_cancel()

def action_invoice_draft(self):
self.clear_cancel_confirm_data()
return super().action_invoice_draft()

0 comments on commit 5ee55b8

Please sign in to comment.