changeset 03080bfc31b0 in modules/account_invoice:default
details:
https://hg.tryton.org/modules/account_invoice?cmd=changeset;node=03080bfc31b0
description:
Show cancel button on posted invoices when its company allows
issue8543
review255741002
diffstat:
invoice.py | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
diffs (39 lines):
diff -r 813596e36500 -r 03080bfc31b0 invoice.py
--- a/invoice.py Wed Jul 31 11:59:11 2019 +0200
+++ b/invoice.py Sat Aug 03 11:15:42 2019 +0200
@@ -228,6 +228,8 @@
file_id=file_id, store_prefix=store_prefix)
invoice_report_cache_id = fields.Char('Invoice Report ID', readonly=True)
invoice_report_format = fields.Char('Invoice Report Format', readonly=True)
+ allow_cancel = fields.Function(
+ fields.Boolean("Allow Cancel Invoice"), 'get_allow_cancel')
@classmethod
def __setup__(cls):
@@ -257,10 +259,8 @@
))
cls._buttons.update({
'cancel': {
- 'invisible': (~Eval('state').in_(['draft', 'validated'])
- & ~((Eval('state') == 'posted')
- & (Eval('type') == 'in'))),
- 'depends': ['state', 'type'],
+ 'invisible': ~Eval('allow_cancel', False),
+ 'depends': ['allow_cancel'],
},
'draft': {
'invisible': (~Eval('state').in_(['cancel', 'validated'])
@@ -809,6 +809,13 @@
value))
return [('id', 'in', query)]
+ def get_allow_cancel(self, name):
+ if self.state in {'draft', 'validated'}:
+ return True
+ if self.state == 'posted':
+ return self.type == 'in' or self.company.cancel_invoice_out
+ return False
+
@property
def taxable_lines(self):
taxable_lines = []