diff --git a/addons/web/static/src/views/calendar/calendar_common/calendar_common_renderer.js b/addons/web/static/src/views/calendar/calendar_common/calendar_common_renderer.js
index 98487de5d7b..b8c178c593a 100644
--- a/addons/web/static/src/views/calendar/calendar_common/calendar_common_renderer.js
+++ b/addons/web/static/src/views/calendar/calendar_common/calendar_common_renderer.js
@@ -96,6 +96,7 @@ export class CalendarCommonRenderer extends Component {
unselectAuto: false,
weekLabel:
this.props.model.scale === "month" && this.env.isSmall ? "" : this.env._t("Week"),
+ weekends: this.props.isWeekendVisible,
weekNumberCalculation: "ISO",
weekNumbers: true,
weekNumbersWithinDays: !this.env.isSmall,
@@ -158,7 +159,7 @@ export class CalendarCommonRenderer extends Component {
this.popover.open(
target,
this.getPopoverProps(record),
- `o_cw_popover o_calendar_color_${typeof(color) === "number" ? color : 0}`
+ `o_cw_popover o_calendar_color_${typeof color === "number" ? color : 0}`
);
}
updateSize() {
diff --git a/addons/web/static/src/views/calendar/calendar_controller.js b/addons/web/static/src/views/calendar/calendar_controller.js
index c24085a148f..ef1e61ca5e5 100644
--- a/addons/web/static/src/views/calendar/calendar_controller.js
+++ b/addons/web/static/src/views/calendar/calendar_controller.js
@@ -16,6 +16,7 @@ import { SearchBar } from "@web/search/search_bar/search_bar";
import { useSearchBarToggler } from "@web/search/search_bar/search_bar_toggler";
import { ViewScaleSelector } from "@web/views/view_components/view_scale_selector";
import { CogMenu } from "@web/search/cog_menu/cog_menu";
+import { browser } from "@web/core/browser/browser";
import { Component, useState } from "@odoo/owl";
@@ -43,20 +44,28 @@ export class CalendarController extends Component {
this.orm = useService("orm");
this.displayDialog = useUniqueDialog();
- this.model = useModelWithSampleData(this.props.Model, {
- ...this.props.archInfo,
- resModel: this.props.resModel,
- domain: this.props.domain,
- fields: this.props.fields,
- }, {
- onWillStart: this.onWillStartModel.bind(this),
- });
+ this.model = useModelWithSampleData(
+ this.props.Model,
+ {
+ ...this.props.archInfo,
+ resModel: this.props.resModel,
+ domain: this.props.domain,
+ fields: this.props.fields,
+ },
+ {
+ onWillStart: this.onWillStartModel.bind(this),
+ }
+ );
useSetupView({
getLocalState: () => this.model.exportedState,
});
this.state = useState({
+ isWeekendVisible:
+ browser.localStorage.getItem("calendar.isWeekendVisible") != null
+ ? JSON.parse(browser.localStorage.getItem("calendar.isWeekendVisible"))
+ : true,
showSideBar: !this.env.isSmall,
});
@@ -66,6 +75,7 @@ export class CalendarController extends Component {
get rendererProps() {
return {
model: this.model,
+ isWeekendVisible: this.model.scale === "day" || this.state.isWeekendVisible,
createRecord: this.createRecord.bind(this),
deleteRecord: this.deleteRecord.bind(this),
editRecord: this.editRecord.bind(this),
@@ -216,7 +226,7 @@ export class CalendarController extends Component {
}
onWillStartModel() {}
-
+
async setDate(move) {
let date = null;
switch (move) {
@@ -242,6 +252,11 @@ export class CalendarController extends Component {
async setScale(scale) {
await this.model.load({ scale });
}
+
+ toggleWeekendVisibility() {
+ this.state.isWeekendVisible = !this.state.isWeekendVisible;
+ browser.localStorage.setItem("calendar.isWeekendVisible", this.state.isWeekendVisible);
+ }
}
CalendarController.components = {
DatePicker: CalendarDatePicker,
diff --git a/addons/web/static/src/views/calendar/calendar_controller.xml b/addons/web/static/src/views/calendar/calendar_controller.xml
index 358bd0c09b0..b72cffcd308 100644
--- a/addons/web/static/src/views/calendar/calendar_controller.xml
+++ b/addons/web/static/src/views/calendar/calendar_controller.xml
@@ -33,7 +33,7 @@
aria-label="Previous"
t-on-click.stop="() => this.setDate('previous')"
>
-
+