diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2026-02-19 09:38:26 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2026-02-19 09:38:26 +0700 |
| commit | 8d51b742d250f117db7603fc4a6ed424391e67d1 (patch) | |
| tree | 47ec8379e0728a3a10c0e7fe3861dc23b71b815f /fixco_custom | |
| parent | 672c09c00d8ca5ba3675c223ca0cb31e007f11ad (diff) | |
<Miqdad> multi reset to draft account payment
Diffstat (limited to 'fixco_custom')
| -rw-r--r-- | fixco_custom/models/account_payment.py | 6 | ||||
| -rw-r--r-- | fixco_custom/views/account_payment.xml | 8 |
2 files changed, 14 insertions, 0 deletions
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 @@ </button> </field> </record> + + <record id="action_reset_to_draft" model="ir.actions.server"> + <field name="name">Reset to Draft</field> + <field name="model_id" ref="account.model_account_payment" /> + <field name="binding_model_id" ref="account.model_account_payment" /> + <field name="state">code</field> + <field name="code">action = records.action_multi_reset_to_draft()</field> + </record> </data> </odoo> |
