Sanjay Gohel (Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-caldav_synch_fix-sgo into 
lp:openobject-addons.

Requested reviews:
  Atul Patel(OpenERP) (atp-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-caldav_synch_fix-sgo/+merge/94085

Hello,

   In caldav synchronization if any recurrent event edited it will b readonly 
recurrent event created.

Thank You,
SGO 
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-caldav_synch_fix-sgo/+merge/94085
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-caldav_synch_fix-sgo.
=== modified file 'base_calendar/base_calendar.py'
--- base_calendar/base_calendar.py	2012-02-03 12:42:14 +0000
+++ base_calendar/base_calendar.py	2012-02-22 05:16:21 +0000
@@ -1010,15 +1010,15 @@
                 result[event] = ""
         return result
 
-    def _rrule_write(self, obj, cr, uid, ids, field_name, field_value, args, context=None):
+    def _rrule_write(self, cr, uid, ids, field_name, field_value, args, context=None):
         data = self._get_empty_rrule_data()
         if field_value:
             data['recurrency'] = True
-            for event in self.browse(cr, uid, ids, context=context):
-                rdate = rule_date or event.date
-                update_data = self._parse_rrule(field_value, dict(data), rdate)
-                data.update(update_data)
-                super(calendar_event, obj).write(cr, uid, ids, data, context=context)
+            event = self.browse(cr, uid, ids, context=context)
+            rdate = event.date
+            update_data = self._parse_rrule(field_value, dict(data), rdate)
+            data.update(update_data)
+            super(calendar_event, self).write(cr, uid, ids, data, context=context)
         return True
 
 
@@ -1121,7 +1121,6 @@
         @param limit: The Number of Results to Return """
         if not context:
             context = {}
-
         result = []
         for data in super(calendar_event, self).read(cr, uid, select, context=context):
             if not data['rrule']:
@@ -1170,9 +1169,7 @@
 
         if isinstance(select, (str, int, long)):
             return ids and ids[0] or False
-        else:
-            ids = list(set(result))
-        return ids
+        return result
 
     def compute_rule_string(self, datas):
         """
@@ -1353,6 +1350,7 @@
 
 
     def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
+        
         context = context or {}
         if isinstance(ids, (str, int, long)):
             ids = [ids]
@@ -1382,7 +1380,6 @@
                     })
 
                 new_id = self.copy(cr, uid, real_event_id, default=data, 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"))
@@ -1419,7 +1416,27 @@
                     del re[groupname + "_count"]
             re.get('__context', {}).update({'virtual_id' : virtual_id})
         return res
+    def browse(self, cr, uid, ids, context=None, list_class=None, fields_process=None):
+        """
+        Overrides orm browse method.
+        @param self: the object pointer
+        @param cr: the current row, from the database cursor,
+        @param uid: the current user’s ID for security checks,
+        @param ids: List of crm meeting's ids
+        @param context: A standard dictionary for contextual values
+        @return: the object list.
+        """
+        if isinstance(ids, (str, int, long)):
+            select = [ids]
+        else:
+            select = ids
+        select = map(lambda x: base_calendar_id2real_id(x), select)
+        res = super(calendar_event, self).browse(cr, uid, select, context, \
+                                                    list_class, fields_process)
+        if isinstance(ids, (str, int, long)):
+            return res and res[0] or False
 
+        return res
     def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
         # FIXME This whole id mangling has to go!
         if context is None:
@@ -1512,18 +1529,15 @@
     def create(self, cr, uid, vals, context=None):
         if context is None:
             context = {}
-
+        if vals.get('rrule'):
+            data = self._get_empty_rrule_data()
+            update_data = self._parse_rrule(vals.get('rrule'), dict(data), vals.get('date'))
+            vals.update(update_data)  
+            vals['recurrency'] = True
+                           
         if vals.get('vtimezone', '') and vals.get('vtimezone', '').startswith('/freeassociation.sourceforge.net/tzfile/'):
             vals['vtimezone'] = vals['vtimezone'][40:]
-
-        #updated_vals = self.onchange_dates(cr, uid, [],
-        #    vals.get('date', False),
-        #    vals.get('duration', False),
-        #    vals.get('date_deadline', False),
-        #    vals.get('allday', False),
-        #    context=context)
-        #vals.update(updated_vals.get('value', {}))
-
+            
         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)
@@ -1807,4 +1821,4 @@
 res_users()
 
 
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== modified file 'caldav/calendar.py'
--- caldav/calendar.py	2011-10-27 21:11:24 +0000
+++ caldav/calendar.py	2012-02-22 05:16:21 +0000
@@ -372,7 +372,8 @@
                         model_obj = self.pool.get(model)
                         r_ids = []
                         if model_obj._columns.get('recurrent_uid', None):
-                            cr.execute('SELECT id FROM %s WHERE recurrent_uid=%%s' % model_obj._table,
+                            if (map_field == "recurrent_ids"): 
+                                cr.execute('SELECT id FROM %s WHERE recurrent_uid=%%s' % model_obj._table,
                                         (data[map_field],))
                             r_ids = map(lambda x: x[0], cr.fetchall())
                         if r_ids:
@@ -1297,4 +1298,4 @@
 
 Attendee()
 
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== modified file 'crm_caldav/crm_caldav.py'
--- crm_caldav/crm_caldav.py	2012-01-31 13:36:57 +0000
+++ crm_caldav/crm_caldav.py	2012-02-22 05:16:21 +0000
@@ -102,9 +102,13 @@
                         if wematch:
                             model, recur_id, dbname = wematch.groups()
                             val.update({'recurrent_uid': recur_id})
-                        event_id = model_obj.create(cr, uid, val)
-                        recur_pool[u_id] = event_id
-                        ids.append(event_id)
+                        if val.get('recurrent_id') or not context.get('res_id'):
+                            event_id = model_obj.create(cr, uid, val)
+                            recur_pool[u_id] = event_id
+                            ids.append(event_id)
+                        else:    
+                            recur_pool[u_id] = context.get('res_id') 
+                            ids.append(context.get('res_id'))
         except Exception:
             raise
         return ids

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to