From 8d51b742d250f117db7603fc4a6ed424391e67d1 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Thu, 19 Feb 2026 09:38:26 +0700 Subject: multi reset to draft account payment --- fixco_custom/models/account_payment.py | 6 ++++++ fixco_custom/views/account_payment.xml | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/fixco_custom/models/account_payment.py b/fixco_custom/models/account_payment.py index 41a2ce5..8f36de6 100644 --- a/fixco_custom/models/account_payment.py +++ b/fixco_custom/models/account_payment.py @@ -5,6 +5,12 @@ from odoo.exceptions import UserError class AccountPayment(models.Model): _inherit = 'account.payment' + def action_multi_reset_to_draft(self): + for payment in self: + if payment.state != 'posted': + raise UserError("Only posted payments can be reset to draft.") + payment.action_draft() + @api.constrains('journal_id') def set_default_journal_id(self): for rec in self: diff --git a/fixco_custom/views/account_payment.xml b/fixco_custom/views/account_payment.xml index c291281..a0af30b 100644 --- a/fixco_custom/views/account_payment.xml +++ b/fixco_custom/views/account_payment.xml @@ -11,5 +11,13 @@ + + + Reset to Draft + + + code + action = records.action_multi_reset_to_draft() + -- cgit v1.2.3