示例#1
0
    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
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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)
示例#7
0
 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)
示例#8
0
    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
示例#9
0
    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
示例#10
0
 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)
示例#11
0
 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)
示例#12
0
 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)
示例#13
0
 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)
示例#14
0
 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)