-
-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] account_move_cancel_confirm: Migration to V12
- Loading branch information
1 parent
cf55dc0
commit 5ee55b8
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |