[FIX] hr_holidays: delete holiday from calendar view

Reason:
Since the change to RelationalModel, the id is no longer present in the
record data by default.

Steps to reproduce the bug:
1. Create a new leave and save it (and keep it unapproved)
2. Click on your newly created leave, click delete and confirm
> Odoo Client Error
(unlinkRecord is called with an undefined value for recordId)

closes odoo/odoo#134885

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
FrancoisGe
2023-09-11 07:59:54 +00:00
parent 0b3e8c3934
commit 19fe730b3b
2 changed files with 7 additions and 6 deletions
@@ -78,18 +78,18 @@ export class TimeOffCalendarController extends CalendarController {
}
deleteRecord(record) {
if (!record.can_cancel) {
if (!record.data.can_cancel) {
this.displayDialog(ConfirmationDialog, {
title: _t("Confirmation"),
body: _t("Are you sure you want to delete this record?"),
confirm: async () => {
await this.model.unlinkRecord(record.id);
await this.model.unlinkRecord(record.resId);
this.env.timeOffBus.trigger('update_dashboard');
},
cancel: () => {},
});
} else {
this.leaveCancelWizard(record.id, () => {
this.leaveCancelWizard(record.resId, () => {
this.model.load();
this.env.timeOffBus.trigger('update_dashboard');
});
@@ -125,5 +125,6 @@ TimeOffCalendarController.components = {
Dropdown,
DropdownItem,
FilterPanel: TimeOffCalendarFilterPanel,
}
TimeOffCalendarController.template = "hr_holidays.CalendarController"
};
TimeOffCalendarController.template = "hr_holidays.CalendarController";
@@ -40,7 +40,7 @@ export class TimeOffDialogFormController extends FormController {
}
deleteRecord() {
this.props.onRecordDeleted(this.record.data)
this.props.onRecordDeleted(this.record);
this.props.onCancelLeave();
if (this.record.data.can_cancel) {
this.leaveCancelWizard(this.record.resId, () => {