I added new settings for user by inheriting "res.users" model:
calendar_scale_type = fields.Selection([
('day', 'Day'),
('week', 'Week'),
('month', 'Month'),
('year', 'Year')],
'Type of calendar scaling', default='week')
in calendar view i want to read this field and set scale_type when opening this form here in calendar_model.js file i want to read this setting from current user
and also rewrite current user setting if he chooses diferent type of scale here
how can i do this? i tried to use rpc, but i do something wrong and it didn`t work.
You can override the session_info and add calendar_scale_type
to use it later in the calendar model (You will need to override the setScale function).
Example:
Add calendar_scale_type
to the session info:
class Http(models.AbstractModel):
_inherit = 'ir.http'
def session_info(self):
session_info = super(Http, self).session_info()
session_info['calendar_scale_type'] = self.env.user.calendar_scale_type
return session_info
Override setScale
function:
/* @odoo-module */
import CalendarModel from '@calendar/js/calendar_model';
import { session } from "@web/session";
CalendarModel.include({
setScale: function (scale) {
if (!_.contains(this.scales, scale)) {
scale = session.calendar_scale_type;
}
this._super(scale);
},
});