diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py
index 8e490c911c3..2910f81e590 100644
--- a/addons/base_calendar/base_calendar.py
+++ b/addons/base_calendar/base_calendar.py
@@ -19,7 +19,7 @@
#
##############################################################################
-from datetime import datetime, timedelta
+from datetime import datetime, timedelta, date
from dateutil import parser
from dateutil import rrule
from osv import fields, osv
@@ -30,7 +30,6 @@ import re
import time
import tools
-
months = {
1: "January", 2: "February", 3: "March", 4: "April", \
5: "May", 6: "June", 7: "July", 8: "August", 9: "September", \
@@ -1199,6 +1198,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
'active': 1,
'user_id': lambda self, cr, uid, ctx: uid,
'organizer': default_organizer,
+ 'edit_all' : True,
}
def onchange_edit_all(self, cr, uid, ids, rrule_type,edit_all, context=None):
@@ -1266,8 +1266,6 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
until_date = base_until_date and datetime.strptime(base_until_date[:10]+ ' 23:59:59', "%Y-%m-%d %H:%M:%S") or False
if count > limit:
break
- if not data['date']:
- continue
event_date = datetime.strptime(data['date'], "%Y-%m-%d %H:%M:%S")
# To check: If the start date is replace by event date .. the event date will be changed by that of calendar code
start_date = event_date
@@ -1401,9 +1399,25 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
continue
until_date = arg[2]
res = super(calendar_event, self).search(cr, uid, args_without_date, \
- offset, limit, order, context, count=False)
+ offset, limit, order, context, count)
+
res = self.get_recurrent_ids(cr, uid, res, start_date, until_date, limit)
- return len(res) if count else res
+ return res
+
+
+ def get_edit_all(self, cr, uid, id, vals=None):
+ """
+ return true if we have to edit all meeting from the same recurrent
+ or only on occurency
+ """
+ meeting = self.read(cr,uid, id, ['edit_all', 'recurrency'] )
+ if(vals and 'edit_all' in vals): #we jsut check edit_all
+ return vals['edit_all']
+ else: #it's a recurrent event and edit_all is already check
+ return meeting['recurrency'] and meeting['edit_all']
+
+
+
def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
"""
@@ -1415,17 +1429,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
@param vals: Dictionary of field value.
@param context: A standard dictionary for contextual values
@return: True
- """
- #removing useless value
- if type(ids) == int or (type(ids) == list and len(ids) > 0):
- old_vals = self.read(cr, uid, ids[0] if type(ids) == list else ids, ['rrule'], context)
- if not old_vals:
- old_vals = {}
- if not 'rrule' in old_vals:
- old_vals["rrule"] = ""
- if 'rrule' in vals and not vals['rrule'] and not old_vals['rrule']:
- del vals['rrule']
-
+ """
if context is None:
context = {}
if isinstance(ids, (str, int, long)):
@@ -1435,26 +1439,35 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
new_ids = []
res = False
for event_id in select:
- real_event_id = base_calendar_id2real_id(event_id)
+ real_event_id = base_calendar_id2real_id(event_id)
- event = self.browse(cr,uid, event_id, context=context)
- if('edit_all' in vals):
- edit_all = vals['edit_all']
- else:
- edit_all = event.edit_all or not event.recurrency
- if not edit_all:
+ if(self.get_edit_all(cr, uid, event_id, vals=vals)):
+ event_id = real_event_id
+
+
+ if len(str(event_id).split('-')) > 1:
data = self.read(cr, uid, event_id, ['date', 'date_deadline', \
- 'rrule', 'duration'])
+ 'rrule', 'duration', 'exdate'])
if data.get('rrule'):
data.update(vals)
data.update({
+ 'recurrent_uid': real_event_id,
+ 'recurrent_id': data.get('date'),
'rrule_type': 'none',
- 'rrule': ''
+ 'rrule': '',
+ 'edit_all': False,
+ 'recurrency' : False,
})
new_id = self.copy(cr, uid, real_event_id, default=data, context=context)
- self.unlink(cr, uid, [event_id], context=context)
+
+ date_new = event_id.split('-')[1]
+ date_new = time.strftime("%Y%m%dT%H%M%S", \
+ time.strptime(date_new, "%Y%m%d%H%M%S"))
+ exdate = (data['exdate'] and (data['exdate'] + ',') or '') + date_new
+ res = self.write(cr, uid, [real_event_id], {'exdate': exdate})
+
context.update({'active_id': new_id, 'active_ids': [new_id]})
continue
if not real_event_id in new_ids:
@@ -1471,7 +1484,6 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
context=context)
vals.update(updated_vals.get('value', {}))
-
if new_ids:
res = super(calendar_event, self).write(cr, uid, new_ids, vals, context=context)
@@ -1533,8 +1545,8 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
for base_calendar_id, real_id in select:
#REVET: Revision ID: olt@tinyerp.com-20100924131709-cqsd1ut234ni6txn
res = super(calendar_event, self).read(cr, uid, real_id, fields=fields, context=context, load=load)
- if not res:
- res = {}
+ if not res :
+ continue
ls = base_calendar_id2real_id(base_calendar_id, with_date=res and res.get('duration', 0) or 0)
if not isinstance(ls, (str, int, long)) and len(ls) >= 2:
res['date'] = ls[1]
@@ -1573,30 +1585,25 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
@return: True
"""
res = False
- for event_datas in self.read(cr, uid, ids, ['date', 'rrule', 'exdate', 'edit_all'], context=context):
+ for event_datas in self.read(cr, uid, ids, ['date', 'rrule', 'exdate'], context=context):
event_id = event_datas['id']
- edit_all = event_datas.get('edit_all', False)
+
+ if self.get_edit_all(cr, uid, event_id, vals=None):
+ event_id = base_calendar_id2real_id(event_id)
+
if isinstance(event_id, (int, long)):
res = super(calendar_event, self).unlink(cr, uid, event_id, context=context)
self.pool.get('res.alarm').do_alarm_unlink(cr, uid, [event_id], self._name)
self.unlink_events(cr, uid, [event_id], context=context)
else:
- select = event_id.split('-')
- if(len(select) < 2):
- str_event = event_id
- date_new = time.strftime("%Y%m%d%H%M%S", \
- time.strptime(event_datas['date'], "%Y-%m-%d %H:%M:%S"))
- else:
- str_event, date_new = select
-
-
+ str_event, date_new = event_id.split('-')
event_id = int(str_event)
- if event_datas['rrule'] and not edit_all:
+ if event_datas['rrule']:
# Remove one of the recurrent event
date_new = time.strftime("%Y%m%dT%H%M%S", \
time.strptime(date_new, "%Y%m%d%H%M%S"))
exdate = (event_datas['exdate'] and (event_datas['exdate'] + ',') or '') + date_new
- res = super(calendar_event, self).write(cr, uid, [event_id], {'exdate': exdate})
+ res = self.write(cr, uid, [event_id], {'exdate': exdate})
else:
res = super(calendar_event, self).unlink(cr, uid, [event_id], context=context)
self.pool.get('res.alarm').do_alarm_unlink(cr, uid, [event_id], self._name)
@@ -1630,9 +1637,7 @@ e.g.: Every other month on the last Sunday of the month for 10 occurrences:\
res = super(calendar_event, self).create(cr, uid, vals, context)
alarm_obj = self.pool.get('res.alarm')
alarm_obj.do_alarm_create(cr, uid, [res], self._name, 'date', context=context)
- records = self.browse(cr, uid, [res], context=context)
- #return real_id2base_calendar_id(records[0].id, records[0].date)
- return base_calendar_id2real_id(records[0].id)
+ return res
def do_tentative(self, cr, uid, ids, context=None, *args):
""" Makes event invitation as Tentative
@@ -1735,6 +1740,14 @@ class ir_attachment(osv.osv):
for arg in args:
args1.append(map(lambda x:str(x).split('-')[0], arg))
return super(ir_attachment, self).search_count(cr, user, args1, context)
+
+
+
+ def create(self, cr, uid, vals, context=None):
+ if context:
+ id = context.get('default_res_id', False)
+ context.update({'default_res_id' : base_calendar_id2real_id(id)})
+ return super(ir_attachment, self).create(cr, uid, vals, context=context)
def search(self, cr, uid, args, offset=0, limit=None, order=None,
context=None, count=False):
@@ -1751,24 +1764,10 @@ class ir_attachment(osv.osv):
new_args = args
for i, arg in enumerate(new_args):
if arg[0] == 'res_id':
- ids = arg[2]
- if arg[1].lower() in ('in', 'not in'):
- if not isinstance(ids, (tuple, list)):
- ids = [ids]
+ new_args[i] = (arg[0], arg[1], base_calendar_id2real_id(arg[2]))
- ids = map(base_calendar_id2real_id, ids)
-
- new_args[i] = (arg[0], arg[1], ids)
return super(ir_attachment, self).search(cr, uid, new_args, offset=offset,
- limit=limit, order=order,
- context=context, count=False)
-
- def create(self, cr, uid, vals, context=None):
- if context:
- id = context.get('default_res_id', False)
- context.update({'default_res_id' : base_calendar_id2real_id(id)})
- return super(ir_attachment, self).create(cr, uid, vals, context=context)
-
+ limit=limit, order=order, context=context, count=False)
ir_attachment()
class ir_values(osv.osv):
diff --git a/addons/crm/crm_meeting_view.xml b/addons/crm/crm_meeting_view.xml
index 960f83e43c9..2524277b3a2 100644
--- a/addons/crm/crm_meeting_view.xml
+++ b/addons/crm/crm_meeting_view.xml
@@ -43,7 +43,7 @@
-
+
@@ -70,7 +70,7 @@
-
+
@@ -165,7 +165,7 @@
-
+
@@ -205,14 +205,13 @@
+ 'invisible' : [('select1','=','day')]}" />
-
+
+ attrs="{'required' : [('select1','=','day'), ('rrule_type','=','monthly')], 'invisible' : [('select1','=','date')]}" />
+ attrs="{'required' : [('select1','=','day'), ('rrule_type','=','monthly')], 'invisible' : [('select1','=','date')]}" />