[IMP] Time-off : Add 5 precision digits to added_value in hr_leave_accrual_plan_level.py
task - 3147639 Adding precision digits and displaying the number without unnecessary trailing zeros using JS closes odoo/odoo#115944 X-original-commit: b6c715cc5b39e28b4f40803a5f161845f5b407ab Signed-off-by: Kevin Baptiste <kba@odoo.com>
This commit is contained in:
@@ -42,7 +42,7 @@ class AccrualPlanLevel(models.Model):
|
||||
|
||||
# Accrue of
|
||||
added_value = fields.Float(
|
||||
"Rate", required=True,
|
||||
"Rate", digits=(16, 5), required=True,
|
||||
help="The number of hours/days that will be incremented in the specified Time Off Type for every period")
|
||||
added_value_type = fields.Selection(
|
||||
[('days', 'Days'),
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/** @odoo-module **/
|
||||
import FieldRegistry from 'web.field_registry';
|
||||
import basic_fields from 'web.basic_fields';
|
||||
|
||||
var FieldFloat = basic_fields.FieldFloat;
|
||||
|
||||
var FloatWithoutTrailingZeros = FieldFloat.extend({
|
||||
_renderReadonly: function () {
|
||||
var value = this._formatValue(this.value);
|
||||
var parsed_value = parseFloat(value);
|
||||
value = parsed_value.toString().replace(/\.0+$/, '');
|
||||
this.$el.text(value);
|
||||
}
|
||||
});
|
||||
|
||||
FieldRegistry.add('float_without_trailing_zeros', FloatWithoutTrailingZeros);
|
||||
|
||||
@@ -157,7 +157,7 @@
|
||||
</t>
|
||||
</div>
|
||||
<div>
|
||||
Adds <field name="added_value"/> <field name="added_value_type"/>
|
||||
Adds <field name="added_value" widget="float_without_trailing_zeros"/> <field name="added_value_type"/>
|
||||
<t t-if="record.is_based_on_worked_time.raw_value">(based on worked time)</t>
|
||||
</div>
|
||||
<div>
|
||||
@@ -179,7 +179,7 @@
|
||||
</t>
|
||||
</div>
|
||||
<div t-if="record.maximum_leave.value">
|
||||
Limit of <field name="maximum_leave"/> <field name="added_value_type"/>
|
||||
Limit of <field name="maximum_leave" widget="float_without_trailing_zeros"/> <field name="added_value_type"/>
|
||||
</div>
|
||||
<div t-if="record.action_with_unused_accruals.raw_value">
|
||||
At the end of the year, unused accruals will be <t t-if="record.action_with_unused_accruals.raw_value == 'postponed'">postponed</t><t t-else="">lost</t>
|
||||
|
||||
Reference in New Issue
Block a user