Odoo Help

Welcome!

This community 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.

0

JS method call in openerp

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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