Skip to content
Snippets Groups Projects
Commit 9c53d4f2 authored by jbm-odoo's avatar jbm-odoo
Browse files

[FIX] hr_timesheet: Remove unused file

Remove file that was removed from assets file in commit https://github.com/odoo/odoo/pull/52585/commits/d6a23144d5c5b85c2a02097bcbb3e006a9c2c52a



closes odoo/odoo#57832

Taskid: 2327552
X-original-commit: 171a17420b12b8ea3712b58e89b6e2bd0b377a4a
Related: odoo/enterprise#13271
Signed-off-by: default avatarYannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: default avatarjbm-odoo <jbm-odoo@users.noreply.github.com>
parent e126cd3b
No related branches found
No related tags found
No related merge requests found
odoo.define('hr_timesheet.timesheet_uom_timer', function (require) {
"use strict";
const fieldRegistry = require('web.field_registry');
const fieldUtils = require('web.field_utils');
const TimesheetUom = require('hr_timesheet.timesheet_uom');
const { _lt } = require('web.core');
const session = require('web.session');
/**
* Extend float time widget to add the using of a timer for duration
* (unit_amount) field.
*/
const FieldTimesheetTimeTimer = TimesheetUom.FieldTimesheetTime.extend({
init: function () {
this._super.apply(this, arguments);
this.isTimerRunning = this.record.data.is_timer_running;
},
_render: async function () {
await this._super.apply(this, arguments);
const my_timesheets = this.record.getContext().my_timesheet_display_timer;
const display_timer = this.record.data.display_timer;
if (my_timesheets && display_timer) {
const title = this.isTimerRunning ? _lt('Stop') : _lt('Play');
const name = this.isTimerRunning ? 'action_timer_stop' : 'action_timer_start';
const label = this.isTimerRunning ? _lt('Stop') : _lt('Start');
const button = $('<button>', {
'class': 'o_icon_button o-timer-button mr8',
'title': title,
'name': name,
'aria-label': label,
'aria-pressed': this.isTimerRunning,
'type': 'button',
'role': 'button',
});
button.html('<i/>');
button.find('i')
.addClass('fa')
.toggleClass('fa-stop-circle o-timer-stop-button', this.isTimerRunning)
.toggleClass('fa-play-circle o-timer-play-button', !this.isTimerRunning)
.attr('title', title);
button.on('click', this._onToggleButton.bind(this));
this.$el.prepend(button);
}
},
_onToggleButton: async function (event) {
const context = this.record.getContext();
event.stopPropagation();
const result = await this._rpc({
model: this.model,
method: this._getActionButton(),
context: context,
args: [this.res_id]
});
this.trigger_up('field_changed', {
dataPointID: this.dataPointID,
changes: {
'is_timer_running': !this.isTimerRunning,
},
});
this.trigger_up('timer_changed', {
id: this.res_id,
is_timer_running: !this.isTimerRunning
});
},
_getActionButton: function () {
return this.isTimerRunning ? 'action_timer_stop' : 'action_timer_start';
}
});
/**
* Binding depending on Company Preference
*
* determine wich widget will be the timesheet one.
* Simply match the 'timesheet_uom' widget key with the correct
* implementation (float_time, float_toggle, ...). The default
* value will be 'float_factor'.
**/
const widgetName = 'timesheet_uom' in session ?
session.timesheet_uom.timesheet_widget : 'float_factor';
let FieldTimesheetUom = null;
if (widgetName === 'float_toggle') {
FieldTimesheetUom = TimesheetUom.FieldTimesheetToggle;
} else if (widgetName === 'float_time') {
FieldTimesheetUom = FieldTimesheetTimeTimer;
} else {
FieldTimesheetUom = (
fieldRegistry.get(widgetName) &&
fieldRegistry.get(widgetName).extend({})
) || TimesheetUom.FieldTimesheetFactor;
}
fieldRegistry.add('timesheet_uom_timer', FieldTimesheetUom);
// bind the formatter and parser method, and tweak the options
const _tweak_options = function(options) {
if (!_.contains(options, 'factor')) {
options.factor = session.timesheet_uom_factor;
}
return options;
};
fieldUtils.format.timesheet_uom_timer = function(value, field, options) {
options = _tweak_options(options || {});
const formatter = fieldUtils.format[FieldTimesheetUom.prototype.formatType];
return formatter(value, field, options);
};
fieldUtils.parse.timesheet_uom_timer = function(value, field, options) {
options = _tweak_options(options || {});
const parser = fieldUtils.parse[FieldTimesheetUom.prototype.formatType];
return parser(value, field, options);
};
return {
FieldTimesheetTimeTimer,
};
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment