TImeDelta widget output customization


(Darius) #1

I need to not display seconds in TimeDelta widget.
I try to look at converter parameter, but but don’t find the way how to remove seconds.

If I remove ‘s’ from converter dictionary I get error:

Traceback (most recent call last):
File “tryton/gui/window/view_form/view/form_gtk/timedelta.pyc”, line 19, in
File “tryton/gui/window/view_form/view/form_gtk/widget.pyc”, line 143, in _focus_out
File “tryton/gui/window/view_form/view/form_gtk/timedelta.pyc”, line 35, in set_value
File “tryton/gui/window/view_form/model/field.pyc”, line 282, in set_client
File “tryton/common/timedelta.pyc”, line 87, in parse
KeyError: ‘h’


(Darius) #2

I found solution.
instead of changing format, I can round to minutes on input, and make migration for existing data.

@fields.depends('time')
def on_change_production_time(self):
    self.time = datetime.timedelta(minutes=self.time.total_seconds() // 60)