splitline: add-2nd-unit-values extendable, new field 'feature'
This commit is contained in:
parent
11d6183d65
commit
82ae7d7bca
6 changed files with 36 additions and 8 deletions
27
splitline.py
27
splitline.py
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# This file is part of the cashbook-module from m-ds for Tryton.
|
||||
# This file is part of the cashbook-module from m-ds.de for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains the
|
||||
# full copyright notices and license terms.
|
||||
|
||||
|
@ -84,6 +84,8 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
|||
cashbook = fields.Function(fields.Many2One(string='Cashbook',
|
||||
readonly=True, states={'invisible': True}, model_name='cashbook.book'),
|
||||
'on_change_with_cashbook')
|
||||
feature = fields.Function(fields.Char(string='Feature', readonly=True,
|
||||
states={'invisible': True}), 'on_change_with_feature')
|
||||
state_cashbook = fields.Function(fields.Selection(string='State of Cashbook',
|
||||
readonly=True, states={'invisible': True}, selection=sel_state_book),
|
||||
'on_change_with_state_cashbook')
|
||||
|
@ -187,6 +189,13 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
|||
if self.line:
|
||||
return self.line.bookingtype
|
||||
|
||||
@fields.depends('line', '_parent_line.cashbook')
|
||||
def on_change_with_feature(self, name=None):
|
||||
""" get feature-set
|
||||
"""
|
||||
if self.line:
|
||||
return self.line.cashbook.btype.feature
|
||||
|
||||
@fields.depends('line', '_parent_line.cashbook')
|
||||
def on_change_with_currency(self, name=None):
|
||||
""" currency of cashbook
|
||||
|
@ -203,6 +212,17 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
|||
else:
|
||||
return 2
|
||||
|
||||
@classmethod
|
||||
def add_2nd_unit_values(cls, values):
|
||||
""" extend create-values
|
||||
"""
|
||||
Line2 = Pool().get('cashbook.line')
|
||||
line = Line2(values.get('line', None))
|
||||
|
||||
if line:
|
||||
values.update(cls.add_2nd_currency(values, line.cashbook.currency))
|
||||
return values
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
""" add debit/credit
|
||||
|
@ -211,10 +231,7 @@ class SplitLine(SecondCurrencyMixin, ModelSQL, ModelView):
|
|||
|
||||
vlist = [x.copy() for x in vlist]
|
||||
for values in vlist:
|
||||
line = Line2(values.get('line', None))
|
||||
if line:
|
||||
values.update(cls.add_2nd_currency(values, line.cashbook.currency))
|
||||
|
||||
values.update(cls.add_2nd_unit_values(values))
|
||||
records = super(SplitLine, cls).create(vlist)
|
||||
|
||||
to_update_line = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue