[MERGE] staging branch with fixes, again, on base_calendar and virtual ids
bzr revid: qdp-launchpad@openerp.com-20121212183807-7197dwwml3m93fs4
This commit is contained in:
@@ -30,6 +30,7 @@ import pytz
|
||||
import re
|
||||
import time
|
||||
import tools
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
months = {
|
||||
1: "January", 2: "February", 3: "March", 4: "April", \
|
||||
@@ -1001,12 +1002,15 @@ class calendar_event(osv.osv):
|
||||
if not isinstance(ids, list):
|
||||
ids = [ids]
|
||||
|
||||
for data in self.read(cr, uid, ids, ['id','byday','recurrency', 'month_list','end_date', 'rrule_type', 'select1', 'interval', 'count', 'end_type', 'mo', 'tu', 'we', 'th', 'fr', 'sa', 'su', 'exrule', 'day', 'week_list' ], context=context):
|
||||
event = data['id']
|
||||
for id in ids:
|
||||
#read these fields as SUPERUSER because if the record is private a normal search could return False and raise an error
|
||||
data = self.read(cr, SUPERUSER_ID, id, ['interval', 'count'], context=context)
|
||||
if data.get('interval', 0) < 0:
|
||||
raise osv.except_osv(_('Warning!'), _('Interval cannot be negative.'))
|
||||
if data.get('count', 0) <= 0:
|
||||
raise osv.except_osv(_('Warning!'), _('Count cannot be negative or 0.'))
|
||||
data = self.read(cr, uid, id, ['id','byday','recurrency', 'month_list','end_date', 'rrule_type', 'select1', 'interval', 'count', 'end_type', 'mo', 'tu', 'we', 'th', 'fr', 'sa', 'su', 'exrule', 'day', 'week_list' ], context=context)
|
||||
event = data['id']
|
||||
if data['recurrency']:
|
||||
result[event] = self.compute_rule_string(data)
|
||||
else:
|
||||
@@ -1339,40 +1343,32 @@ rule or repeating pattern of time to exclude from the recurring rule."),
|
||||
return data
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=0, order=None, context=None, count=False):
|
||||
context = context or {}
|
||||
args_without_date = []
|
||||
filter_date = []
|
||||
if context is None:
|
||||
context = {}
|
||||
new_args = []
|
||||
|
||||
for arg in args:
|
||||
if arg[0] == "id":
|
||||
new_id = self.remove_virtual_id(arg[2])
|
||||
new_arg = arg
|
||||
if arg[0] in ('date', unicode('date'), 'date_deadline', unicode('date_deadline')):
|
||||
if context.get('virtual_id', True):
|
||||
new_args += ['|','&',('recurrency','=',1),('recurrent_id_date', arg[1], arg[2])]
|
||||
elif arg[0] == "id":
|
||||
new_id = get_real_ids(arg[2])
|
||||
new_arg = (arg[0], arg[1], new_id)
|
||||
args_without_date.append(new_arg)
|
||||
elif arg[0] not in ('date', unicode('date'), 'date_deadline', unicode('date_deadline')):
|
||||
args_without_date.append(arg)
|
||||
else:
|
||||
if context.get('virtual_id', True):
|
||||
args_without_date.append('|')
|
||||
args_without_date.append(arg)
|
||||
if context.get('virtual_id', True):
|
||||
args_without_date.append(('recurrency','=',1))
|
||||
filter_date.append(arg)
|
||||
new_args.append(new_arg)
|
||||
|
||||
res = super(calendar_event, self).search(cr, uid, args_without_date, \
|
||||
0, 0, order, context, count=False)
|
||||
#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, args, limit, context=context)
|
||||
|
||||
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]
|
||||
else:
|
||||
return res
|
||||
return res
|
||||
|
||||
def _get_data(self, cr, uid, id, context=None):
|
||||
res = self.read(cr, uid, [id],['date', 'date_deadline'])
|
||||
return res[0]
|
||||
return self.read(cr, uid, id,['date', 'date_deadline'])
|
||||
|
||||
def need_to_update(self, event_id, vals):
|
||||
split_id = str(event_id).split("-")
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -10,4 +10,6 @@ access_crm_meeting,crm.meeting,model_crm_meeting,base.group_sale_salesman,1,1,1,
|
||||
access_crm_meeting_all,crm.meeting_allll,model_crm_meeting,base.group_user,1,0,0,0
|
||||
access_crm_meeting_partner_manager,crm.meeting.partner.manager,model_crm_meeting,base.group_partner_manager,1,1,1,1
|
||||
access_crm_meeting_type_sale_manager,crm.meeting.type.manager,model_crm_meeting_type,base.group_sale_manager,1,1,1,0
|
||||
access_crm_meeting_type_sale_user,crm.meeting.type.user,model_crm_meeting_type,base.group_user,1,0,0,0
|
||||
access_crm_meeting_type_sale_user,crm.meeting.type.salesman,model_crm_meeting_type,base.group_sale_salesman,1,0,0,0
|
||||
access_crm_meeting_type_manager,crm.meeting.type.manager,model_crm_meeting_type,base.group_system,1,1,1,1
|
||||
|
||||
|
@@ -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
|
||||
-
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user