[FIX] account, account_cancel: cancel payment
Commit b17e4a0f6b 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
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="name">account.payment.tree</field>
|
||||
<field name="model">account.payment</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree decoration-info="state=='draft'" decoration-muted="state=='reconciled'" edit="false">
|
||||
<tree decoration-info="state == 'draft'" decoration-muted="state in ['reconciled', 'cancel']" edit="false">
|
||||
<field name="payment_date"/>
|
||||
<field name="name"/>
|
||||
<field name="journal_id"/>
|
||||
@@ -25,7 +25,7 @@
|
||||
<field name="name">account.supplier.payment.tree</field>
|
||||
<field name="model">account.payment</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree decoration-info="state=='draft'" decoration-muted="state=='reconciled'" edit="false">
|
||||
<tree decoration-info="state == 'draft'" decoration-muted="state in ['reconciled', 'cancel']" edit="false">
|
||||
<field name="payment_date"/>
|
||||
<field name="name"/>
|
||||
<field name="journal_id"/>
|
||||
@@ -76,6 +76,7 @@
|
||||
<form string="Register Payment" version="7">
|
||||
<header>
|
||||
<button name="post" class="oe_highlight" states="draft" string="Confirm" type="object"/>
|
||||
<button name="action_draft" states="cancel" string="Set to Draft" type="object"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="posted,reconciled"/>
|
||||
</header>
|
||||
<sheet>
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<field name="inherit_id" ref="account.view_account_payment_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//header/field[@name='state']" position="before">
|
||||
<button name="cancel" attrs="{'invisible': [('state', '=', 'draft')]}" string="Cancel" type="object"/>
|
||||
<button name="cancel" states="posted,sent,reconciled" string="Cancel" type="object"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user