diff --git a/golem_activity/models/golem_activity.py b/golem_activity/models/golem_activity.py index f9168ce..b2103eb 100644 --- a/golem_activity/models/golem_activity.py +++ b/golem_activity/models/golem_activity.py @@ -168,6 +168,60 @@ class GolemActivity(models.Model): 'after end of the period.')) + ########################################### + ########################################## + @api.multi + def read(self, fields=None, load='_classic_read'): + print '________________________' + print self.ids + fields2 = fields and fields[:] or None + select = map(lambda x: (x, self.calendar_id2real_id(x)), self.ids) + print select + real_events = self.browse([real_id for calendar_id, real_id in select]) + real_data = super(GolemActivity, real_events).read(fields=fields2, load=load) + real_data = dict((d['id'], d) for d in real_data) + print real_data + print real_events + for calendar_id, real_id in select: + print calendar_id + print real_id + + #for id in self.ids: + # print self.env['golem.activity'].browse(id) + #return super(GolemActivity, self).read(self, fields=None, load='_classic_read') + + @api.multi + def calendar_id2real_id(self, calendar_id=None): + if calendar_id and isinstance(calendar_id, (basestring)): + res = filter(None, calendar_id.split('-')) + if len(res) == 2: + real_id = res[0] + return int(real_id) + return calendar_id and int(calendar_id) or calendar_id + + @api.multi + def real_id2calendar_id(self, record_id, date): + return '%s-%s' % (record_id, date) + + @api.multi + def get_recurrent_ids(self): + result = [] + for activity in self: + #if not meeting.recurrency or not meeting.rrule: + result.append(activity.id) + result.append(activity.real_id2calendar_id(activity.id, activity.date_start)) + return result + + @api.model + def search(self, args, offset=0, limit=0, order=None, count=False): + activities = super(GolemActivity, self).search(args, offset=0, limit=0, order=None, count=False) + activities = self.browse(activities.get_recurrent_ids()) + return activities + + + + + class ProductTemplate(models.Model): """ GOLEM Activity Product adaptations """ _inherit = 'product.template'