Skip to content
Snippets Groups Projects
Commit 6bfc5bd8 authored by Nisha patel's avatar Nisha patel Committed by Barad Mahendra
Browse files

[FIX] hr_timesheet, timer: Fix traceback in kanban view when using the timer


Currently, when the unit amount of line is zero and the timer time
spent on entry is less than one minutes then entries are unlinked
once the timer is stopped and due to that the entry disappear from the
kanban view and traceback is generated.

After this commit, we fix the issue by preventing the deletion of
entries by setting options 'prevent_deletion' on widget so we should
no allow to delete the entry if the option is set on widget.

closes odoo/odoo#50395

Taskid: 2230155
Closes: #49128
X-original-commit: 64b9a9b4deaee5a8139b0afbe3f222a476a038f9
Signed-off-by: default avatarYannick Tivisse (yti) <yti@odoo.com>
parent db957181
No related branches found
No related tags found
No related merge requests found
......@@ -219,7 +219,7 @@ class AccountAnalyticLine(models.Model):
self._add_timesheet_time(minutes_spent)
def _add_timesheet_time(self, minutes_spent):
if self.unit_amount == 0 and minutes_spent < 1:
if self.unit_amount == 0 and minutes_spent < 1 and not self._context.get('prevent_deletion', False):
# Check if unit_amount equals 0 and minutes_spent is less than 1 minute,
# if yes, then remove the timesheet
self.unlink()
......
......@@ -183,7 +183,7 @@
<t t-esc="record.name.value"/>
</span>
<div class="float-right">
<field name="is_timer_running" widget="timer_toggle_button" attrs="{ 'invisible': [('display_timer', '=', False)] }" />
<field name="is_timer_running" widget="timer_toggle_button" options="{'prevent_deletion': True}" attrs="{ 'invisible': [('display_timer', '=', False)] }" />
</div>
</div>
</div>
......
......@@ -50,10 +50,13 @@ const TimerToggleButton = FieldToggleBoolean.extend({
* @param {MouseEvent} event
*/
_onToggleButton: async function (event) {
const context = this.record.getContext();
const prevent_deletion = this.attrs.options && this.attrs.options.prevent_deletion || false;
event.stopPropagation();
const result = await this._rpc({
model: this.model,
method: this._getActionButton(),
context: $.extend({}, context, {prevent_deletion: prevent_deletion}),
args: [this.res_id]
});
......
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