mirror of
https://github.com/NaN-tic/tryton-gtk2.git
synced 2023-12-14 03:12:58 +01:00
Use converter from TimeDeltaField when evaluate sum
TimeDelta converter take group as parameter instead record. issue6946 review41691002
This commit is contained in:
parent
d8391de0b6
commit
bd2bf2c1fe
2 changed files with 7 additions and 7 deletions
|
@ -276,19 +276,20 @@ class TimeDeltaField(Field):
|
|||
def _is_empty(self, record):
|
||||
return self.get(record) is None
|
||||
|
||||
def converter(self, record):
|
||||
# TODO allow local context converter
|
||||
return rpc.CONTEXT.get(self.attrs.get('converter'))
|
||||
def converter(self, group):
|
||||
ctx = rpc.CONTEXT.copy()
|
||||
ctx.update(group.context)
|
||||
return ctx.get(self.attrs.get('converter'))
|
||||
|
||||
def set_client(self, record, value, force_change=False):
|
||||
if isinstance(value, basestring):
|
||||
value = common.timedelta.parse(value, self.converter(record))
|
||||
value = common.timedelta.parse(value, self.converter(record.group))
|
||||
super(TimeDeltaField, self).set_client(
|
||||
record, value, force_change=force_change)
|
||||
|
||||
def get_client(self, record):
|
||||
value = super(TimeDeltaField, self).get_client(record)
|
||||
return common.timedelta.format(value, self.converter(record))
|
||||
return common.timedelta.format(value, self.converter(record.group))
|
||||
|
||||
|
||||
class FloatField(Field):
|
||||
|
|
|
@ -1141,8 +1141,7 @@ class ViewTree(View):
|
|||
|
||||
if loaded:
|
||||
if field.attrs['type'] == 'timedelta':
|
||||
converter = self.screen.context.get(
|
||||
field.attrs.get('converter'))
|
||||
converter = field.converter(self.screen.group)
|
||||
selected_sum = common.timedelta.format(
|
||||
selected_sum, converter)
|
||||
sum_ = common.timedelta.format(sum_, converter)
|
||||
|
|
Loading…
Reference in a new issue