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, }