From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- .../hr_timesheet/static/src/js/task_with_hours.js | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 addons/hr_timesheet/static/src/js/task_with_hours.js (limited to 'addons/hr_timesheet/static/src/js/task_with_hours.js') diff --git a/addons/hr_timesheet/static/src/js/task_with_hours.js b/addons/hr_timesheet/static/src/js/task_with_hours.js new file mode 100644 index 00000000..d2ed5a64 --- /dev/null +++ b/addons/hr_timesheet/static/src/js/task_with_hours.js @@ -0,0 +1,36 @@ +odoo.define('hr_timesheet.task_with_hours', function (require) { +"use strict"; + +var field_registry = require('web.field_registry'); +var relational_fields = require('web.relational_fields'); +var FieldMany2One = relational_fields.FieldMany2One; + +var TaskWithHours = FieldMany2One.extend({ + /** + * @override + */ + init: function () { + this._super.apply(this, arguments); + this.additionalContext.hr_timesheet_display_remaining_hours = true; + }, + /** + * @override + */ + _getDisplayNameWithoutHours: function (value) { + return value.split(' ‒ ')[0]; + }, + /** + * @override + * @private + */ + _renderEdit: function (){ + this.m2o_value = this._getDisplayNameWithoutHours(this.m2o_value); + this._super.apply(this, arguments); + }, +}); + +field_registry.add('task_with_hours', TaskWithHours); + +return TaskWithHours; + +}); \ No newline at end of file -- cgit v1.2.3