changeset c03842e8190a in modules/account_invoice:default
details:
https://hg.tryton.org/modules/account_invoice?cmd=changeset;node=c03842e8190a
description:
Rename invoice state from cancel to cancelled
issue8927
review303661003
diffstat:
CHANGELOG | 2 +
doc/index.rst | 2 +-
invoice.py | 40 +++++++++++++++++++++---------------
party.py | 2 +-
tests/scenario_invoice.rst | 2 +-
tests/scenario_invoice_supplier.rst | 6 ++--
6 files changed, 31 insertions(+), 23 deletions(-)
diffs (206 lines):
diff -r ec6214201a0c -r c03842e8190a CHANGELOG
--- a/CHANGELOG Mon Jun 01 10:08:02 2020 +0100
+++ b/CHANGELOG Sat Jun 06 10:23:14 2020 +0100
@@ -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
diff -r ec6214201a0c -r c03842e8190a doc/index.rst
--- a/doc/index.rst Mon Jun 01 10:08:02 2020 +0100
+++ b/doc/index.rst Sat Jun 06 10:23:14 2020 +0100
@@ -8,7 +8,7 @@
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
diff -r ec6214201a0c -r c03842e8190a invoice.py
--- a/invoice.py Mon Jun 01 10:08:02 2020 +0100
+++ b/invoice.py Sat Jun 06 10:23:14 2020 +0100
@@ -81,11 +81,11 @@
('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 @@
('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 @@
'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 @@
# 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 @@
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 @@
@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 @@
| ((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 @@
# 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 @@
@classmethod
@ModelView.button
- @Workflow.transition('cancel')
+ @Workflow.transition('cancelled')
def cancel(cls, invoices):
pool = Pool()
Move = pool.get('account.move')
@@ -1510,7 +1516,7 @@
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 @@
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 @@
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))
diff -r ec6214201a0c -r c03842e8190a party.py
--- a/party.py Mon Jun 01 10:08:02 2020 +0100
+++ b/party.py Sat Jun 06 10:23:14 2020 +0100
@@ -94,7 +94,7 @@
invoices = Invoice.search([
('party', '=', party.id),
('company', '=', company.id),
- ('state', 'not in', ['paid', 'cancel']),
+ ('state', 'not in', ['paid', 'cancelled']),
])
if invoices:
raise EraseError(
diff -r ec6214201a0c -r c03842e8190a tests/scenario_invoice.rst
--- a/tests/scenario_invoice.rst Mon Jun 01 10:08:02 2020 +0100
+++ b/tests/scenario_invoice.rst Sat Jun 06 10:23:14 2020 +0100
@@ -217,7 +217,7 @@
>>> credit.execute('credit')
>>> invoice.reload()
>>> invoice.state
- 'cancel'
+ 'cancelled'
>>> invoice.reconciled == today
True
>>> receivable.reload()
diff -r ec6214201a0c -r c03842e8190a tests/scenario_invoice_supplier.rst
--- a/tests/scenario_invoice_supplier.rst Mon Jun 01 10:08:02 2020 +0100
+++ b/tests/scenario_invoice_supplier.rst Sat Jun 06 10:23:14 2020 +0100
@@ -192,7 +192,7 @@
>>> 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 @@
>>> invoice_draft.click('cancel')
>>> invoice_draft.state
- 'cancel'
+ 'cancelled'
>>> invoice_draft.move
>>> invoice_draft.reconciled
@@ -218,7 +218,7 @@
>>> invoice.click('cancel')
>>> invoice.state
- 'cancel'
+ 'cancelled'
>>> invoice.cancel_move is not None
True
>>> invoice.reconciled == today