openerp-expert-production team mailing list archive
-
openerp-expert-production team
-
Mailing list archive
-
Message #00498
[Bug 794207] Re: MRP operations time precission to seconds
I am not sure what you are asking? Do you mean digits=(16,2,2).
Anyway I am working with this code now. It creates a widget
float_time_secs.
If this is acceptable please add to trunk.
For example in your XML:
<field name="hour" widget="float_time_secs"/>
Example code create module_name/static/src/js/float_time_secs.js and be sure to include in __openerp__.py
'js': ['static/src/js/foat_time_secs.js'],
openerp.module_name = function(openerp) {
// ---------------------------------------------------------------------------------------------------------------------
// Added float_time_secs translation to hh:mm:ss
var old_format_value = openerp.web.format_value;
openerp.web.format_value = function (value, descriptor,
value_if_empty) {
switch (descriptor.widget || descriptor.type) {
case 'float_time_secs':
pattern = "%02d:%02d:%02d";
if (value < 0) {
value = Math.abs(value);
pattern = '-' + pattern;
}
hrs = Math.floor(value);
mins = (value % 1) * 60
mins = Math.round((mins + 0.0001)*1000)/1000;
if (mins >= 60) {
hrs = hrs + 1;
mins = 0;
}
secs = (mins % 1) * 60;
secs = Math.round((secs + .0001)*10000)/10000;
if (secs >= 60) {
mins = mins + 1;
secs = 0;
}
s = _.str.sprintf(pattern, hrs, mins, secs);
return old_format_value(s, descriptor, value_if_empty);
case 'many2one':
if (value[1]) {
return value[1];
}
default:
return old_format_value(value, descriptor, value_if_empty);
}
return old_format_value(value, descriptor, value_if_empty);
};
// ---------------------------------------------------------------------------------------------------------------------
// Added float_time_secs translation back to float value
var old_web_parse_value = openerp.web.parse_value;
openerp.web.parse_value = function (value, descriptor, value_if_empty) {
switch (descriptor.widget || descriptor.type) {
case 'float_time_secs':
var factor = 1;
if (value[0] === '-') {
value = value.slice(1);
factor = -1;
}
var float_time_split = value.split(":");
if (float_time_split.length != 3)
return factor * old_web_parse_value(value, {type: "float"});
var hours = old_web_parse_value(float_time_split[0], {type: "integer"});
var minutes = old_web_parse_value(float_time_split[1], {type: "integer"});
var seconds = old_web_parse_value(float_time_split[2], {type: "integer"});
return factor * (hours + (minutes / 60) + ((seconds / 60 / 60) + .0001));
}
return old_web_parse_value(value, descriptor, value_if_empty);
};
}
--
You received this bug notification because you are a member of OpenERP
Manufacturing Experts, which is subscribed to the bug report.
https://bugs.launchpad.net/bugs/794207
Title:
MRP operations time precission to seconds
Status in OpenERP Addons (modules):
Opinion
Bug description:
MRP operations time precision to seconds
In our industry we need to estimate time for one cycle in seconds, in
fact we do have several operations for one second.
Please make possible to use time with seconds in all manufacture
process.
I would gladly help if I knew how.
I tried to make the field nbr_hours in work center definition as field.time, it does display seconds but then it does not compute.
I need help please,
Thanks
Mihai
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/794207/+subscriptions