def default_get(self, fields): """ In case someone clicked on 'invite others' wizard in the followers widget, transform virtual ids in real ids """ if 'default_res_id' in self._context: self = self.with_context(default_res_id=get_real_ids(self._context['default_res_id'])) result = super(MailInvite, self).default_get(fields) if 'res_id' in result: result['res_id'] = get_real_ids(result['res_id']) return result
def search(self, args, offset=0, limit=0, order=None, count=False): """ Convert the search on real ids in the case it was asked on virtual ids, then call super() """ args = list(args) for index in range(len(args)): if args[index][0] == "res_id": if isinstance(args[index][2], basestring): args[index] = (args[index][0], args[index][1], get_real_ids(args[index][2])) elif isinstance(args[index][2], list): args[index] = (args[index][0], args[index][1], map(lambda x: get_real_ids(x), args[index][2])) return super(Message, self).search(args, offset=offset, limit=limit, order=order, count=count)
def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None): """ Convert the search on real ids in the case it was asked on virtual ids, then call super() """ args = list(args) for index in range(len(args)): if args[index][0] == "res_id": if isinstance(args[index][2], str): args[index] = (args[index][0], args[index][1], get_real_ids(args[index][2])) elif isinstance(args[index][2], list): args[index] = (args[index][0], args[index][1], [get_real_ids(x) for x in args[index][2]]) return super(Message, self)._search(args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid)
def search(self, args, offset=0, limit=0, order=None, count=False): """ Convert the search on real ids in the case it was asked on virtual ids, then call super() """ args = list(args) if any([leaf for leaf in args if leaf[0] == "res_model" and leaf[2] == 'calendar.event']): for index in range(len(args)): if args[index][0] == "res_id" and isinstance(args[index][2], pycompat.string_types): args[index] = (args[index][0], args[index][1], get_real_ids(args[index][2])) return super(Attachment, self).search(args, offset=offset, limit=limit, order=order, count=count)
def unlink(self, can_be_deleted=True): # Keeping track of the events that are deleted from odoo calendar real_events = self.env['calendar.event'].browse(set(get_real_ids(self.ids))) for event in real_events: if self.env.user.ks_sync_deleted_event: self.env['ks.deleted'].create({ 'name': event.name, 'ks_odoo_id': event.id, 'ks_office_id': event.ks_office_event_id, 'ks_module': 'calendar', 'ks_user_id': self.env.user.id, }) return super(KsOdooCalendar, self).unlink(can_be_deleted)
def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None): """ Convert the search on real ids in the case it was asked on virtual ids, then call super() """ args = list(args) for index in range(len(args)): if args[index][0] == "res_id": if isinstance(args[index][2], pycompat.string_types): args[index] = (args[index][0], args[index][1], get_real_ids(args[index][2])) elif isinstance(args[index][2], list): args[index] = (args[index][0], args[index][1], [get_real_ids(x) for x in args[index][2]]) return super(Message, self)._search(args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid)
def search(self, args, offset=0, limit=0, order=None, count=False): """ Convert the search on real ids in the case it was asked on virtual ids, then call super() """ args = list(args) if any([ leaf for leaf in args if leaf[0] == "res_model" and leaf[2] == 'calendar.event' ]): for index in range(len(args)): if args[index][0] == "res_id" and isinstance( args[index][2], pycompat.string_types): args[index] = (args[index][0], args[index][1], get_real_ids(args[index][2])) return super(Attachment, self).search(args, offset=offset, limit=limit, order=order, count=count)
def get_attendee_detail(self, meeting_id): """ Return a list of tuple (id, name, status) Used by base_calendar.js : Many2ManyAttendee """ datas = [] meeting = None if meeting_id: meeting = self.env['calendar.event'].browse(get_real_ids(meeting_id)) for partner in self: data = partner.name_get()[0] data = [data[0], data[1], False, partner.color] if meeting: for attendee in meeting.attendee_ids: if attendee.partner_id.id == partner.id: data[2] = attendee.state datas.append(data) return datas
def write(self, vals): """ When posting an attachment (new or not), convert the virtual ids in real ids. """ if isinstance(vals.get('res_id'), pycompat.string_types): vals['res_id'] = get_real_ids(vals.get('res_id')) return super(Attachment, self).write(vals)
def _find_allowed_model_wise(self, doc_model, doc_dict): if doc_model == "calendar.event": order = self._context.get("order", self._order) for virtual_id in self.env[doc_model].browse(doc_dict.keys()).get_recurrent_ids([], order=order): doc_dict.setdefault(virtual_id, doc_dict[get_real_ids(virtual_id)]) return super(Message, self)._find_allowed_model_wise(doc_model, doc_dict)
def _find_allowed_model_wise(self, doc_model, doc_dict): if doc_model == 'calendar.event': order = self._context.get('order', self.env[doc_model]._order) for virtual_id in self.env[doc_model].browse(doc_dict).get_recurrent_ids([], order=order): doc_dict.setdefault(virtual_id, doc_dict[get_real_ids(virtual_id)]) return super(Message, self)._find_allowed_model_wise(doc_model, doc_dict)
def _find_allowed_model_wise(self, doc_model, doc_dict): if doc_model == 'calendar.event': order = self._context.get('order', self.env[doc_model]._order) for virtual_id in self.env[doc_model].with_context(active_test=False).search([('id', 'in', list(doc_dict))], order=order).ids: doc_dict.setdefault(virtual_id, doc_dict[get_real_ids(virtual_id)]) return super(Message, self)._find_allowed_model_wise(doc_model, doc_dict)