Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4361 Lượt xem

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


Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất
    <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>


Ảnh đại diện
Huỷ bỏ

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 7 24
10933
0
thg 8 19
3073
1
thg 7 19
267
1
thg 5 21
16048
1
thg 4 21
4812