diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 28264bea759..69baf57c1a9 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -1357,7 +1357,15 @@ rule or repeating pattern of time to exclude from the recurring rule."), new_arg = (arg[0], arg[1], new_id) new_args.append(new_arg) - return super(calendar_event, self).search(cr, uid, new_args, offset=offset, limit=limit, order=order, context=context, count=count) + #offset, limit and count must be treated separately as we may need to deal with virtual ids + res = super(calendar_event, self).search(cr, uid, new_args, offset=0, limit=0, order=order, context=context, count=False) + if context.get('virtual_id', True): + res = self.get_recurrent_ids(cr, uid, res, new_args, limit, context=context) + if count: + return len(res) + elif limit: + return res[offset:offset+limit] + return res def _get_data(self, cr, uid, id, context=None): return self.read(cr, uid, id,['date', 'date_deadline']) diff --git a/addons/base_calendar/crm_meeting.py b/addons/base_calendar/crm_meeting.py index 4745d6c5896..e9fe70f19ff 100644 --- a/addons/base_calendar/crm_meeting.py +++ b/addons/base_calendar/crm_meeting.py @@ -142,6 +142,12 @@ class mail_message(osv.osv): args[index][2] = get_real_ids(args[index][2]) return super(mail_message, self).search(cr, uid, args, offset=offset, limit=limit, order=order, context=context, count=count) + def _find_allowed_model_wise(self, cr, uid, doc_model, doc_dict, context=None): + if doc_model == 'crm.meeting': + for virtual_id in self.pool.get(doc_model).get_recurrent_ids(cr, uid, doc_dict.keys(), [], context=context): + doc_dict.setdefault(virtual_id, doc_dict[get_real_ids(virtual_id)]) + return super(mail_message, self)._find_allowed_model_wise(cr, uid, doc_model, doc_dict, context=context) + class ir_attachment(osv.osv): _inherit = "ir.attachment" diff --git a/addons/base_calendar/test/base_calendar_test.yml b/addons/base_calendar/test/base_calendar_test.yml index c84f3ce36c3..7afd2e49551 100644 --- a/addons/base_calendar/test/base_calendar_test.yml +++ b/addons/base_calendar/test/base_calendar_test.yml @@ -26,7 +26,7 @@ - !python {model: calendar.event}: | ids = self.search(cr, uid, [('date', '>=', '2011-04-30 16:00:00'), ('date', '<=', '2011-05-31 00:00:00')], context={'virtual_id': True} ) - assert len(ids) == 9 + assert len(ids) == 9, 'Wrong number of events found' - Now I will make All day event and test it - diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 069e0118ec4..d0a73385f7f 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -550,6 +550,20 @@ class mail_message(osv.Model): if not cr.fetchone(): cr.execute("""CREATE INDEX mail_message_model_res_id_idx ON mail_message (model, res_id)""") + def _find_allowed_model_wise(self, cr, uid, doc_model, doc_dict, context=None): + doc_ids = doc_dict.keys() + allowed_doc_ids = self.pool.get(doc_model).search(cr, uid, [('id', 'in', doc_ids)], context=context) + return set([message_id for allowed_doc_id in allowed_doc_ids for message_id in doc_dict[allowed_doc_id]]) + + def _find_allowed_doc_ids(self, cr, uid, model_ids, context=None): + model_access_obj = self.pool.get('ir.model.access') + allowed_ids = set() + for doc_model, doc_dict in model_ids.iteritems(): + if not model_access_obj.check(cr, uid, doc_model, 'read', False): + continue + allowed_ids |= self._find_allowed_model_wise(cr, uid, doc_model, doc_dict, context=context) + return allowed_ids + def _search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False, access_rights_uid=None): """ Override that adds specific access rights of mail.message, to remove @@ -587,13 +601,7 @@ class mail_message(osv.Model): elif message.get('model') and message.get('res_id'): model_ids.setdefault(message.get('model'), {}).setdefault(message.get('res_id'), set()).add(message.get('id')) - model_access_obj = self.pool.get('ir.model.access') - for doc_model, doc_dict in model_ids.iteritems(): - if not model_access_obj.check(cr, uid, doc_model, 'read', False): - continue - doc_ids = doc_dict.keys() - allowed_doc_ids = self.pool.get(doc_model).search(cr, uid, [('id', 'in', doc_ids)], context=context) - allowed_ids |= set([message_id for allowed_doc_id in allowed_doc_ids for message_id in doc_dict[allowed_doc_id]]) + allowed_ids = self._find_allowed_doc_ids(cr, uid, model_ids, context=context) final_ids = author_ids | partner_ids | allowed_ids if count: diff --git a/addons/product/security/ir.model.access.csv b/addons/product/security/ir.model.access.csv index b5cd20854d9..d4c4261bb8c 100644 --- a/addons/product/security/ir.model.access.csv +++ b/addons/product/security/ir.model.access.csv @@ -17,3 +17,4 @@ access_product_pricelist_partner_manager,product.pricelist partner manager,model access_product_product_employee,product.product employee,model_product_product,base.group_user,1,0,0,0 access_product_template_sale_manager,product.template salemanager,model_product_template,base.group_sale_manager,1,1,1,1 access_product_product_sale_manager,product.product salemanager,model_product_product,base.group_sale_manager,1,1,1,1 +access_product_category_sale_manager,product.category salemanager,product.model_product_category,base.group_sale_manager,1,1,1,1 diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 853dac4e20c..424034f1104 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -457,14 +457,14 @@
-
+ 7 7 7 -
+