Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
3323 Prikazi
      case 'float_time':
            var pattern = '%02d:%02d';
            if (value < 0) {
                value = Math.abs(value);
                pattern = '-' + pattern;
            }
            var hour = Math.floor(value);
            var min = Math.round((value % 1) * 60);
            if (min == 60){
                min = 0;
                hour = hour + 1;
            }
            return _.str.sprintf(pattern, hour, min);

In openerp 7 custom module on_change function used based on difference between two time (float). Actual requirement if the output negative value not shows in the text box user can manually enter the value or change the format 00:00 into 0:0

def onchange_time(self, cr, uid, ids, start_time, end_time, context=None):
          if diff_time < 0: 
               diff_time = 0.0
               # how to call js method _.str.sprintf(pattern, hour, min);   
               # and change the  pattern = '%01d:%01d'; or shows output None for Negative value only
          v['diff'] = diff_time
 return {'value': v}
Avatar
Opusti