changeset b1e3e9604ed4 in modules/account_invoice:default
details:
https://hg.tryton.org/modules/account_invoice?cmd=changeset;node=b1e3e9604ed4
description:
Allow to extend invoice's journal type
issue5175
review314451002
diffstat:
invoice.py | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diffs (45 lines):
diff -r 8ec8bd03e679 -r b1e3e9604ed4 invoice.py
--- a/invoice.py Sun Oct 11 13:02:20 2020 +0200
+++ b/invoice.py Mon Oct 12 13:02:30 2020 +0200
@@ -116,13 +116,7 @@
currency_date = fields.Function(fields.Date('Currency Date'),
'on_change_with_currency_date')
journal = fields.Many2One('account.journal', 'Journal', required=True,
- states=_states,
- domain=[
- If(Eval('type') == 'out',
- ('type', '=', 'revenue'),
- ('type', '=', 'expense'))
- ],
- depends=_depends + ['type'])
+ states=_states, depends=_depends)
move = fields.Many2One('account.move', 'Move', readonly=True,
domain=[
('company', '=', Eval('company', -1)),
@@ -235,6 +229,12 @@
('number', 'DESC'),
('id', 'DESC'),
]
+ cls.journal.domain = [
+ If(Eval('type') == 'out',
+ ('type', 'in', cls._journal_types('out')),
+ ('type', 'in', cls._journal_types('in'))),
+ ]
+ cls.journal.depends += ['type']
cls.tax_identifier.domain = [
('party', '=', Eval('company_party', -1)),
('type', 'in', cls.tax_identifier_types()),
@@ -435,6 +435,13 @@
if journals:
self.journal, = journals
+ @classmethod
+ def _journal_types(cls, invoice_type):
+ if invoice_type == 'out':
+ return ['revenue']
+ else:
+ return ['expense']
+
@fields.depends('party')
def on_change_party(self):
self.invoice_address = None