line: name änderbar
This commit is contained in:
parent
71ad546b21
commit
9ea8702b08
1 changed files with 33 additions and 15 deletions
48
line.py
48
line.py
|
@ -44,13 +44,25 @@ class EvaluationLine(ModelSQL, ModelView):
|
||||||
currency_digits = fields.Function(fields.Integer(string='Currency Digits',
|
currency_digits = fields.Function(fields.Integer(string='Currency Digits',
|
||||||
readonly=True), 'on_change_with_currency_digits')
|
readonly=True), 'on_change_with_currency_digits')
|
||||||
|
|
||||||
name = fields.Function(fields.Char(string='Name', readonly=True),
|
name = fields.Function(fields.Char(string='Name'),
|
||||||
'on_change_with_name')
|
'on_change_with_name', setter='set_name_data')
|
||||||
|
name_line = fields.Char(string='Name', states={'invisible': True})
|
||||||
balance = fields.Function(fields.Numeric(string='Balance',
|
balance = fields.Function(fields.Numeric(string='Balance',
|
||||||
readonly=True, digits=(16, Eval('currency_digits', 2)),
|
readonly=True, digits=(16, Eval('currency_digits', 2)),
|
||||||
depends=['currency_digits']),
|
depends=['currency_digits']),
|
||||||
'on_change_with_balance')
|
'on_change_with_balance')
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_name_data(cls, lines, name, value):
|
||||||
|
""" store updated name
|
||||||
|
"""
|
||||||
|
print('\n## set_name_data', lines, name, value)
|
||||||
|
cls.write(*[
|
||||||
|
lines,
|
||||||
|
{
|
||||||
|
'name_line': value,
|
||||||
|
}])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fields_view_get(cls, view_id, view_type='form'):
|
def fields_view_get(cls, view_id, view_type='form'):
|
||||||
""" replace form-view-id
|
""" replace form-view-id
|
||||||
|
@ -100,6 +112,25 @@ class EvaluationLine(ModelSQL, ModelView):
|
||||||
else:
|
else:
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
|
@fields.depends('eval_dtype', 'cashbook', 'dtype', 'currency', 'name_line')
|
||||||
|
def on_change_with_name(self, name=None):
|
||||||
|
""" get name of Type
|
||||||
|
"""
|
||||||
|
# prefer to use local stored name of line
|
||||||
|
if self.name_line:
|
||||||
|
if len(self.name_line) > 0:
|
||||||
|
return self.name_line
|
||||||
|
|
||||||
|
# otherwise use rec_name of linked record
|
||||||
|
if self.eval_dtype:
|
||||||
|
return getattr(
|
||||||
|
getattr(self, {
|
||||||
|
'cashbooks': 'cashbook',
|
||||||
|
'types': 'dtype',
|
||||||
|
'currencies': 'currency',
|
||||||
|
}[self.eval_dtype], None),
|
||||||
|
'rec_name', None)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def validate(cls, records):
|
def validate(cls, records):
|
||||||
""" check parent record
|
""" check parent record
|
||||||
|
@ -125,19 +156,6 @@ class EvaluationLine(ModelSQL, ModelView):
|
||||||
typename = gettext('cashbook_report.msg_dtype_currency'),
|
typename = gettext('cashbook_report.msg_dtype_currency'),
|
||||||
))
|
))
|
||||||
|
|
||||||
@fields.depends('eval_dtype', 'cashbook', 'dtype', 'currency')
|
|
||||||
def on_change_with_name(self, name=None):
|
|
||||||
""" get name of Type
|
|
||||||
"""
|
|
||||||
if self.eval_dtype:
|
|
||||||
return getattr(
|
|
||||||
getattr(self, {
|
|
||||||
'cashbooks': 'cashbook',
|
|
||||||
'types': 'dtype',
|
|
||||||
'currencies': 'currency',
|
|
||||||
}[self.eval_dtype], None),
|
|
||||||
'rec_name', None)
|
|
||||||
|
|
||||||
def get_value_cashbooks(self):
|
def get_value_cashbooks(self):
|
||||||
""" balance of cashbooks
|
""" balance of cashbooks
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue