Odoo Help

0

JS method call in openerp

By
Prakash
on 11/5/13, 7:42 AM 977 views
      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}

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 11/5/13, 7:42 AM
Seen: 977 times
Last updated: 3/16/15, 8:10 AM