Rename invoice state from cancel to cancelled
issue8927 review303661003
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
* Rename invoice state from cancel to cancelled
|
||||
|
||||
Version 5.6.0 - 2020-05-04
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Allow overpaying invoice
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ Invoice
|
||||
|
||||
There are 4 types of invoice: *Invoice*, *Supplier Invoice*, *Credit Note* and
|
||||
*Supplier Credit Note*. An invoice can be in *Draft*, *Validated*, *Posted*,
|
||||
*Paid* or *Canceled*.
|
||||
*Paid* or *Cancelled*.
|
||||
|
||||
- Company: The company for which the invoice is created.
|
||||
- Tax Identifier: The tax identifier that will be printed on the invoice
|
||||
|
||||
+23
-17
@@ -81,11 +81,11 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
('validated', "Validated"),
|
||||
('posted', "Posted"),
|
||||
('paid', "Paid"),
|
||||
('cancel', "Cancelled"),
|
||||
('cancelled', "Cancelled"),
|
||||
], "State", readonly=True)
|
||||
invoice_date = fields.Date('Invoice Date',
|
||||
states={
|
||||
'readonly': Eval('state').in_(['posted', 'paid', 'cancel']),
|
||||
'readonly': Eval('state').in_(['posted', 'paid', 'cancelled']),
|
||||
'required': Eval('state').in_(
|
||||
If(Eval('type') == 'in',
|
||||
['validated', 'posted', 'paid'],
|
||||
@@ -241,10 +241,10 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
('posted', 'paid'),
|
||||
('validated', 'draft'),
|
||||
('paid', 'posted'),
|
||||
('draft', 'cancel'),
|
||||
('validated', 'cancel'),
|
||||
('posted', 'cancel'),
|
||||
('cancel', 'draft'),
|
||||
('draft', 'cancelled'),
|
||||
('validated', 'cancelled'),
|
||||
('posted', 'cancelled'),
|
||||
('cancelled', 'draft'),
|
||||
))
|
||||
cls._buttons.update({
|
||||
'cancel': {
|
||||
@@ -252,10 +252,11 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
'depends': ['allow_cancel'],
|
||||
},
|
||||
'draft': {
|
||||
'invisible': (~Eval('state').in_(['cancel', 'validated'])
|
||||
| ((Eval('state') == 'cancel')
|
||||
'invisible': (
|
||||
~Eval('state').in_(['cancelled', 'validated'])
|
||||
| ((Eval('state') == 'cancelled')
|
||||
& Eval('cancel_move', -1))),
|
||||
'icon': If(Eval('state') == 'cancel', 'tryton-undo',
|
||||
'icon': If(Eval('state') == 'cancelled', 'tryton-undo',
|
||||
'tryton-back'),
|
||||
'depends': ['state'],
|
||||
},
|
||||
@@ -349,6 +350,11 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
# Add index on create_date
|
||||
table.index_action('create_date', action='add')
|
||||
|
||||
# Migration from 5.6: rename state cancel to cancelled
|
||||
cursor.execute(*sql_table.update(
|
||||
[sql_table.state], ['cancelled'],
|
||||
where=sql_table.state == 'cancel'))
|
||||
|
||||
@staticmethod
|
||||
def default_type():
|
||||
return Transaction().context.get('type', 'out')
|
||||
@@ -854,7 +860,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
to_delete = []
|
||||
to_write = []
|
||||
for invoice in invoices:
|
||||
if invoice.state in ('posted', 'paid', 'cancel'):
|
||||
if invoice.state in ('posted', 'paid', 'cancelled'):
|
||||
continue
|
||||
computed_taxes = invoice._compute_taxes()
|
||||
if not invoice.taxes:
|
||||
@@ -1086,7 +1092,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
@property
|
||||
def is_modifiable(self):
|
||||
return not (self.state in {'posted', 'paid'}
|
||||
or (self.state == 'cancel'
|
||||
or (self.state == 'cancelled'
|
||||
and (self.move or self.cancel_move or self.number)))
|
||||
|
||||
@classmethod
|
||||
@@ -1137,7 +1143,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
| ((Eval('type') == 'in')
|
||||
& (Eval('amount_to_pay_today', 0) < 0)),
|
||||
'danger',
|
||||
If(Eval('state') == 'cancel', 'muted', ''))),
|
||||
If(Eval('state') == 'cancelled', 'muted', ''))),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
@@ -1146,7 +1152,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
# Cancel before delete
|
||||
cls.cancel(invoices)
|
||||
for invoice in invoices:
|
||||
if invoice.state != 'cancel':
|
||||
if invoice.state != 'cancelled':
|
||||
raise AccessError(
|
||||
gettext('account_invoice.msg_invoice_delete_cancel',
|
||||
invoice=invoice.rec_name))
|
||||
@@ -1478,7 +1484,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
|
||||
@classmethod
|
||||
@ModelView.button
|
||||
@Workflow.transition('cancel')
|
||||
@Workflow.transition('cancelled')
|
||||
def cancel(cls, invoices):
|
||||
pool = Pool()
|
||||
Move = pool.get('account.move')
|
||||
@@ -1510,7 +1516,7 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
|
||||
Move.post(cancel_moves)
|
||||
# Write state before reconcile to prevent invoice to go to paid state
|
||||
cls.write(invoices, {
|
||||
'state': 'cancel',
|
||||
'state': 'cancelled',
|
||||
})
|
||||
|
||||
for invoice in invoices:
|
||||
@@ -2130,7 +2136,7 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin):
|
||||
if vals.get('invoice'):
|
||||
invoice_ids.append(vals.get('invoice'))
|
||||
for invoice in Invoice.browse(invoice_ids):
|
||||
if invoice.state in ('posted', 'paid', 'cancel'):
|
||||
if invoice.state in ('posted', 'paid', 'cancelled'):
|
||||
raise AccessError(
|
||||
gettext('account_invoice.msg_invoice_line_create',
|
||||
invoice=invoice.rec_name))
|
||||
@@ -2421,7 +2427,7 @@ class InvoiceTax(sequence_ordered(), ModelSQL, ModelView):
|
||||
if vals.get('invoice'):
|
||||
invoice_ids.append(vals['invoice'])
|
||||
for invoice in Invoice.browse(invoice_ids):
|
||||
if invoice.state in ('posted', 'paid', 'cancel'):
|
||||
if invoice.state in ('posted', 'paid', 'cancelled'):
|
||||
raise AccessError(
|
||||
gettext('account_invoice.msg_invoice_tax_create',
|
||||
invoice=invoice.rec_name))
|
||||
|
||||
@@ -94,7 +94,7 @@ class Erase(metaclass=PoolMeta):
|
||||
invoices = Invoice.search([
|
||||
('party', '=', party.id),
|
||||
('company', '=', company.id),
|
||||
('state', 'not in', ['paid', 'cancel']),
|
||||
('state', 'not in', ['paid', 'cancelled']),
|
||||
])
|
||||
if invoices:
|
||||
raise EraseError(
|
||||
|
||||
@@ -217,7 +217,7 @@ Credit invoice with refund::
|
||||
>>> credit.execute('credit')
|
||||
>>> invoice.reload()
|
||||
>>> invoice.state
|
||||
'cancel'
|
||||
'cancelled'
|
||||
>>> invoice.reconciled == today
|
||||
True
|
||||
>>> receivable.reload()
|
||||
|
||||
@@ -192,7 +192,7 @@ Credit invoice::
|
||||
>>> credit_note.total_amount == -invoice.total_amount
|
||||
True
|
||||
|
||||
Create a posted and a draft invoice to cancel::
|
||||
Create a posted and a draft invoice to cancel::
|
||||
|
||||
>>> invoice = Invoice()
|
||||
>>> invoice.type = 'in'
|
||||
@@ -210,7 +210,7 @@ Cancel draft invoice::
|
||||
|
||||
>>> invoice_draft.click('cancel')
|
||||
>>> invoice_draft.state
|
||||
'cancel'
|
||||
'cancelled'
|
||||
>>> invoice_draft.move
|
||||
>>> invoice_draft.reconciled
|
||||
|
||||
@@ -218,7 +218,7 @@ Cancel posted invoice::
|
||||
|
||||
>>> invoice.click('cancel')
|
||||
>>> invoice.state
|
||||
'cancel'
|
||||
'cancelled'
|
||||
>>> invoice.cancel_move is not None
|
||||
True
|
||||
>>> invoice.reconciled == today
|
||||
|
||||
Reference in New Issue
Block a user