콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3436 화면
      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}
아바타
취소