From 9f193df0fa3a575c6718ad0c7cc1b6f6c8ce9ece Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Wed, 16 Nov 2022 09:17:55 +0000 Subject: [PATCH] [FIX] hr_holidays: delete time off from calendar view Steps to reproduce: - logged in as user with admin or officer permissions; - create time off request with config for sick time off request; - try to delete partially approved time off request from calendar view by pressing delete button. (The button is in the window that opens when you select a time off) Issue: Partially approved time off request are not deleted when using delete button in calendar view. (It can only be deleted via the list view) Cause: The function which deletes the element is not called. opw-3061570 closes odoo/odoo#106023 X-original-commit: b9d01d30474303747f65376b0abf4cde3d2400e7 Signed-off-by: Kevin Baptiste Signed-off-by: Lefebvre Thomas (thle) --- .../static/src/views/calendar/calendar_controller.js | 3 ++- .../static/src/views/view_dialog/form_view_dialog.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/hr_holidays/static/src/views/calendar/calendar_controller.js b/addons/hr_holidays/static/src/views/calendar/calendar_controller.js index 7d765c488d3..2c8505f1a85 100644 --- a/addons/hr_holidays/static/src/views/calendar/calendar_controller.js +++ b/addons/hr_holidays/static/src/views/calendar/calendar_controller.js @@ -68,7 +68,7 @@ export class TimeOffCalendarController extends CalendarController { } deleteRecord(record) { - if (!record.rawRecord.can_cancel) { + if (!record.can_cancel) { return super.deleteRecord(record); } @@ -88,6 +88,7 @@ export class TimeOffCalendarController extends CalendarController { title: record.title, viewId: this.model.formViewId, onRecordSaved: () => this.model.load(), + onRecordDeleted: (record) => this.deleteRecord(record), onLeaveCancelled: () => { this.model.load(); this.env.timeOffBus.trigger('update_dashboard'); diff --git a/addons/hr_holidays/static/src/views/view_dialog/form_view_dialog.js b/addons/hr_holidays/static/src/views/view_dialog/form_view_dialog.js index 551dc676993..695c6c37ada 100644 --- a/addons/hr_holidays/static/src/views/view_dialog/form_view_dialog.js +++ b/addons/hr_holidays/static/src/views/view_dialog/form_view_dialog.js @@ -16,11 +16,12 @@ export class TimeOffDialogFormController extends FormController { } deleteRecord() { - const leaveId = this.model.root.data.id; + const record = this.model.root.data + this.props.onRecordDeleted(record) this.props.onCancelLeave(); - if (this.model.root.data.can_cancel) { - this.leaveCancelWizard(leaveId, () => { + if (record.can_cancel) { + this.leaveCancelWizard(record.id, () => { this.props.onLeaveCancelled(); }); } @@ -35,6 +36,7 @@ export class TimeOffDialogFormController extends FormController { TimeOffDialogFormController.props = { ...FormController.props, onCancelLeave: Function, + onRecordDeleted: Function, onLeaveCancelled: Function, } @@ -54,11 +56,15 @@ export class TimeOffFormViewDialog extends FormViewDialog { onCancelLeave: () => { this.props.close(); }, + onRecordDeleted: (record) => { + this.props.onRecordDeleted(record) + }, onLeaveCancelled: this.props.onLeaveCancelled.bind(this), }) } } TimeOffFormViewDialog.props = { ...TimeOffFormViewDialog.props, + onRecordDeleted: Function, onLeaveCancelled: Function, }