From a2724701deed34d2bd115cbcf0960281b2ee7826 Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 19 Sep 2023 18:11:53 +0200 Subject: [PATCH] [14.0][FIX] l10n_es_ticketbai: Fixed tbai refund type --- l10n_es_ticketbai/models/account_move.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/l10n_es_ticketbai/models/account_move.py b/l10n_es_ticketbai/models/account_move.py index f6768e03f7d..c5b91c6a919 100644 --- a/l10n_es_ticketbai/models/account_move.py +++ b/l10n_es_ticketbai/models/account_move.py @@ -627,6 +627,17 @@ def _compute_tbai_description(self): description += " - ".join(filter(None, names)) invoice.tbai_description_operation = (description or "")[:250] or "/" + def action_switch_invoice_into_refund_credit_note(self): + super().action_switch_invoice_into_refund_credit_note() + for move in self: + if "out_refund" == move.move_type: + vals = {"tbai_refund_type": RefundType.differences.value} + if move.partner_id.aeat_anonymous_cash_customer: + vals["tbai_refund_key"] = RefundCode.R5.value + else: + vals["tbai_refund_key"] = RefundCode.R1.value + move.write(vals) + class AccountMoveLine(models.Model): _inherit = "account.move.line"