Skip to Content
Menu
This question has been flagged
1 Reply
3355 Views

Hi. When we open calendar, the default calendar is the "Administrator", and i want to set "Everybody's calendar".

the code to this i think is in :

_loadFilter: function (filter) {
if (!filter.write_model) {
return;
}

var field = this.fields[filter.fieldName];
return this._rpc({
model: filter.write_model,
method: 'search_read',
domain: [["user_id", "=", session.uid]],
fields: [filter.write_field],
})
.then(function (res) {
var records = _.map(res, function (record) {
var _value = record[filter.write_field];
var value = _.isArray(_value) ? _value[0] : _value;
var f = _.find(filter.filters, function (f) {return f.value === value;});
var formater = fieldUtils.format[_.contains(['many2many', 'one2many'], field.type) ? 'many2one' : field.type];
return {
'id': record.id,
'value': value,
'label': formater(_value, field),
'active': !f || f.active,
};
});
records.sort(function (f1,f2) {
return _.string.naturalCmp(f2.label, f1.label);
});

// add my profile
if (field.relation === 'res.partner' || field.relation === 'res.users') {
var value = field.relation === 'res.partner' ? session.partner_id : session.uid;
var me = _.find(records, function (record) {
return record.value === value;
});
if (me) {
records.splice(records.indexOf(me), 1);
} else {
var f = _.find(filter.filters, function (f) {return f.value === value;});
me = {
'value': value,
'label': session.name + _t(" [Me]"),
'active': !f || f.active,
};
}
records.unshift(me);
}
// add all selection
records.push({
'value': value,
'label': field.relation === 'res.partner' || field.relation === 'res.users' ? _t("Everybody's calendars") : _t("Everything"),
'active': filter.all,
});

filter.filters = records;
});
},

Does anyone knows where can i change the default calendar in this code? Thanks


Avatar
Discard
Author Best Answer
    <record id="view_l10n_cu_calendar_event_calendar" model="ir.ui.view">
<field name="name">calendar.event.calendar</field>
<field name="model">calendar.event</field>
<field name="inherit_id" ref="calendar.view_calendar_event_calendar"/>
<field name="arch" type="xml">
<data>
<field name="partner_ids" position="replace" >
<field name="partner_ids"/>
</field>
</data>
</field>
</record>


Avatar
Discard

Hi Rick. Does the answer you've given here result 'Everybody's calendars' being selected by default? The inherited view you've presented just seems to replace the "partner_ids" field with the same field, so I'm not sure how this would achieve anything??

I just tried using the above and in a simple custom view inheritance module, and it doesn't do anything as I suspected. Thought it might save someone else the time trying it.

Related Posts Replies Views Activity
4
Jul 24
8943
0
Aug 19
1948
1
Jul 19
267
1
May 21
14557
1
Apr 21
3178