[FIX] calendar: To avoid duplicate contacts
Before the fix dda8e2211a, the duplicate
records were erased thanks to the index used in the dictionary(id of the partner).
After this fix, to avoid this this problem, the label of each record is used as
key in the dictionary.
This commit is contained in:
@@ -5,13 +5,11 @@ from openerp.osv import fields, osv
|
||||
|
||||
class calendar_contacts(osv.osv):
|
||||
_name = 'calendar.contacts'
|
||||
_order = "name"
|
||||
|
||||
_columns = {
|
||||
'user_id': fields.many2one('res.users','Me'),
|
||||
'partner_id': fields.many2one('res.partner','Employee',required=True, domain=[]),
|
||||
'active':fields.boolean('active'),
|
||||
'name': fields.related('partner_id', 'display_name', type='char', string='Partner Contact Name', readonly=True),
|
||||
}
|
||||
_defaults = {
|
||||
'user_id': lambda self, cr, uid, ctx: uid,
|
||||
|
||||
@@ -38,8 +38,8 @@ function reload_favorite_list(result) {
|
||||
is_checked: true,
|
||||
is_remove: false,
|
||||
};
|
||||
sidebar_items[0] = filter_item ;
|
||||
|
||||
sidebar_items[1] = filter_item ;
|
||||
|
||||
filter_item = {
|
||||
value: -1,
|
||||
label: _lt("Everybody's calendars"),
|
||||
@@ -50,7 +50,7 @@ function reload_favorite_list(result) {
|
||||
sidebar_items[-1] = filter_item ;
|
||||
//Get my coworkers/contacts
|
||||
new Model("calendar.contacts").query(["partner_id"]).filter([["user_id", "=",self.dataset.context.uid]]).all().then(function(result) {
|
||||
var i = 1;
|
||||
var unsorted_res = {};
|
||||
_.each(result, function(item) {
|
||||
filter_value = item.partner_id[0];
|
||||
filter_item = {
|
||||
@@ -60,8 +60,13 @@ function reload_favorite_list(result) {
|
||||
avatar_model: self.avatar_model,
|
||||
is_checked: true
|
||||
};
|
||||
sidebar_items[i++] = filter_item ;
|
||||
unsorted_res[filter_item.label + " " +filter_value] = filter_item;
|
||||
});
|
||||
var i = 2;
|
||||
_.keys(unsorted_res).sort().forEach(function(key){
|
||||
sidebar_items[i++] = unsorted_res[key];
|
||||
});
|
||||
|
||||
self.all_filters = sidebar_items;
|
||||
self.now_filter_ids = $.map(self.all_filters, function(o) { return o.value; });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user