From d19cf48499b42fbd24e6a7ec283433a577362666 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 29 Nov 2016 10:56:37 +0100 Subject: [PATCH] [FIX] account, account_cancel: cancel payment Commit b17e4a0f6b0a prevents gaps in payment numbering by keeping tack of the account move name used. It also prevents the unlinking of a payment which already generated an account move. However, no 'Cancelled' state has been introduced for the payments. It means that the cancellation of a payment will set it to a draft state, and it won't be possible to delete or flag it as 'Cancelled' later on. It will therefore be a misleading entry for the users. opw-694351 --- addons/account/models/account_payment.py | 8 ++++++-- addons/account/views/account_payment_view.xml | 5 +++-- addons/account_cancel/views/account_views.xml | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index e21847878e2..1bc39562f77 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -192,7 +192,7 @@ class account_payment(models.Model): company_id = fields.Many2one(store=True) name = fields.Char(readonly=True, copy=False, default="Draft Payment") # The name is attributed upon post() - state = fields.Selection([('draft', 'Draft'), ('posted', 'Posted'), ('sent', 'Sent'), ('reconciled', 'Reconciled')], readonly=True, default='draft', copy=False, string="Status") + state = fields.Selection([('draft', 'Draft'), ('posted', 'Posted'), ('sent', 'Sent'), ('reconciled', 'Reconciled'), ('cancel', 'Cancelled')], readonly=True, default='draft', copy=False, string="Status") payment_type = fields.Selection(selection_add=[('transfer', 'Internal Transfer')]) payment_reference = fields.Char(copy=False, readonly=True, help="Reference of the document used to issue this payment. Eg. check number, file name, etc.") @@ -315,7 +315,7 @@ class account_payment(models.Model): move.line_ids.remove_move_reconcile() move.button_cancel() move.unlink() - rec.state = 'draft' + rec.state = 'cancel' @api.multi def unlink(self): @@ -370,6 +370,10 @@ class account_payment(models.Model): rec.write({'state': 'posted', 'move_name': move.name}) + @api.multi + def action_draft(self): + return self.write({'state': 'draft'}) + def _create_payment_entry(self, amount): """ Create a journal entry corresponding to a payment, if the payment references invoice(s) they are reconciled. Return the journal entry. diff --git a/addons/account/views/account_payment_view.xml b/addons/account/views/account_payment_view.xml index a14c4c73ffa..8602bb3727a 100644 --- a/addons/account/views/account_payment_view.xml +++ b/addons/account/views/account_payment_view.xml @@ -6,7 +6,7 @@ account.payment.tree account.payment - + @@ -25,7 +25,7 @@ account.supplier.payment.tree account.payment - + @@ -76,6 +76,7 @@
diff --git a/addons/account_cancel/views/account_views.xml b/addons/account_cancel/views/account_views.xml index 6242c279c45..35fdead50df 100644 --- a/addons/account_cancel/views/account_views.xml +++ b/addons/account_cancel/views/account_views.xml @@ -65,7 +65,7 @@ -