Merge lp:~openerp-dev/openobject-addons/trunk-bug-caldav_synch_fix-sgo into lp:openobject-addons

Proposed by Sanjay Gohel (Open ERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-caldav_synch_fix-sgo
Merge into: lp:openobject-addons
Diff against target: 217 lines (+58/-34)
3 files modified
base_calendar/base_calendar.py (+48/-29)
caldav/calendar.py (+3/-2)
crm_caldav/crm_caldav.py (+7/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-caldav_synch_fix-sgo
Reviewer Review Type Date Requested Status
Roberto López López (community) Approve
Atul Patel(OpenERP) Pending
Review via email: mp+94085@code.launchpad.net

This proposal supersedes a proposal from 2012-02-21.

Description of the change

Hello,

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

Thank You,
SGO

To post a comment you must log in.
Revision history for this message
Roberto López López (bergensk) wrote : Posted in a previous version of this proposal

For me it doesn't seem to work (error 403 while creating an event).

In the link below, the stacktrace:

http://paste.ubuntu.com/851073/

Kind regards,

Roberto (rlo)

Revision history for this message
Atul Patel(OpenERP) (atp-openerp) wrote : Posted in a previous version of this proposal

Hello,
Recurrent event was not created properly.

can you check it..

Thanks

review: Needs Fixing
Revision history for this message
Roberto López López (bergensk) wrote :

After new test, the current fix seems ok to me. Thanks.

Revision history for this message
Roberto López López (bergensk) :
review: Approve
Revision history for this message
Roberto López López (bergensk) wrote :

I forgot to mention that my tests were done on thunderbird.

6551. By Sanjay Gohel (Open ERP)

[IMP]Resolve delete recurrent problem

6552. By Sanjay Gohel (Open ERP)

[MERGE]merge with latest trunk

Unmerged revisions

6552. By Sanjay Gohel (Open ERP)

[MERGE]merge with latest trunk

6551. By Sanjay Gohel (Open ERP)

[IMP]Resolve delete recurrent problem

6550. By Sanjay Gohel (Open ERP)

[IMP]add missing code

6549. By Sanjay Gohel (Open ERP)

[IMP]crm_caldav:event create prob

6548. By Sanjay Gohel (Open ERP)

[MERGE]: merge with parent branch

6547. By Sanjay Gohel (Open ERP)

[IMP]crm_caldav:solve edit one record of reccurence

6546. By Sanjay Gohel (Open ERP)

[IMP]caldav create recurrent prob solved

6545. By Sanjay Gohel (Open ERP)

[IMP]:fix problem for write n create recurrent data from thunderbird to openerp

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_calendar/base_calendar.py'
2--- base_calendar/base_calendar.py 2012-08-10 10:22:57 +0000
3+++ base_calendar/base_calendar.py 2012-08-27 05:28:31 +0000
4@@ -1012,15 +1012,15 @@
5 result[event] = ""
6 return result
7
8- def _rrule_write(self, obj, cr, uid, ids, field_name, field_value, args, context=None):
9+ def _rrule_write(self, cr, uid, ids, field_name, field_value, args, context=None):
10 data = self._get_empty_rrule_data()
11 if field_value:
12 data['recurrency'] = True
13- for event in self.browse(cr, uid, ids, context=context):
14- rdate = rule_date or event.date
15- update_data = self._parse_rrule(field_value, dict(data), rdate)
16- data.update(update_data)
17- super(calendar_event, obj).write(cr, uid, ids, data, context=context)
18+ event = self.browse(cr, uid, ids, context=context)
19+ rdate = event.date
20+ update_data = self._parse_rrule(field_value, dict(data), rdate)
21+ data.update(update_data)
22+ super(calendar_event, self).write(cr, uid, ids, data, context=context)
23 return True
24
25
26@@ -1124,7 +1124,6 @@
27 @param limit: The Number of Results to Return """
28 if not context:
29 context = {}
30-
31 result = []
32 for data in super(calendar_event, self).read(cr, uid, select, context=context):
33 if not data['rrule']:
34@@ -1173,9 +1172,7 @@
35
36 if isinstance(select, (str, int, long)):
37 return ids and ids[0] or False
38- else:
39- ids = list(set(result))
40- return ids
41+ return result
42
43 def compute_rule_string(self, datas):
44 """
45@@ -1356,11 +1353,12 @@
46
47
48 def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True):
49+
50 context = context or {}
51 if isinstance(ids, (str, int, long)):
52 ids = [ids]
53 res = False
54-
55+ new_ids = []
56 # Special write of complex IDS
57 for event_id in ids[:]:
58 if len(str(event_id).split('-')) == 1:
59@@ -1385,7 +1383,6 @@
60 })
61
62 new_id = self.copy(cr, uid, real_event_id, default=data, context=context)
63-
64 date_new = event_id.split('-')[1]
65 date_new = time.strftime("%Y%m%dT%H%M%S", \
66 time.strptime(date_new, "%Y%m%d%H%M%S"))
67@@ -1394,12 +1391,14 @@
68
69 context.update({'active_id': new_id, 'active_ids': [new_id]})
70 continue
71+ if not real_event_id in new_ids:
72+ new_ids.append(real_event_id)
73
74 if vals.get('vtimezone', '') and vals.get('vtimezone', '').startswith('/freeassociation.sourceforge.net/tzfile/'):
75 vals['vtimezone'] = vals['vtimezone'][40:]
76-
77- res = super(calendar_event, self).write(cr, uid, ids, vals, context=context)
78-
79+ if new_ids:
80+ res = super(calendar_event, self).write(cr, uid, new_ids, vals, context=context)
81+
82 if ('alarm_id' in vals or 'base_calendar_alarm_id' in vals)\
83 or ('date' in vals or 'duration' in vals or 'date_deadline' in vals):
84 alarm_obj = self.pool.get('res.alarm')
85@@ -1422,7 +1421,27 @@
86 del re[groupname + "_count"]
87 re.get('__context', {}).update({'virtual_id' : virtual_id})
88 return res
89+ def browse(self, cr, uid, ids, context=None, list_class=None, fields_process=None):
90+ """
91+ Overrides orm browse method.
92+ @param self: the object pointer
93+ @param cr: the current row, from the database cursor,
94+ @param uid: the current user’s ID for security checks,
95+ @param ids: List of crm meeting's ids
96+ @param context: A standard dictionary for contextual values
97+ @return: the object list.
98+ """
99+ if isinstance(ids, (str, int, long)):
100+ select = [ids]
101+ else:
102+ select = ids
103+ select = map(lambda x: base_calendar_id2real_id(x), select)
104+ res = super(calendar_event, self).browse(cr, uid, select, context, \
105+ list_class, fields_process)
106+ if isinstance(ids, (str, int, long)):
107+ return res and res[0] or False
108
109+ return res
110 def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
111 # FIXME This whole id mangling has to go!
112 if context is None:
113@@ -1489,11 +1508,11 @@
114 if not isinstance(ids, list):
115 ids = [ids]
116 res = False
117+ new_ids = []
118 attendee_obj=self.pool.get('calendar.attendee')
119 for event_id in ids[:]:
120 if len(str(event_id).split('-')) == 1:
121 continue
122-
123 real_event_id = base_calendar_id2real_id(event_id)
124 data = self.read(cr, uid, real_event_id, ['exdate'], context=context)
125 date_new = event_id.split('-')[1]
126@@ -1502,11 +1521,14 @@
127 exdate = (data['exdate'] and (data['exdate'] + ',') or '') + date_new
128 self.write(cr, uid, [real_event_id], {'exdate': exdate})
129 ids.remove(event_id)
130+ if not real_event_id in new_ids:
131+ new_ids.append(real_event_id)
132+
133 for event in self.browse(cr, uid, ids, context=context):
134 if event.attendee_ids:
135 attendee_obj.unlink(cr, uid, [x.id for x in event.attendee_ids], context=context)
136-
137- res = super(calendar_event, self).unlink(cr, uid, ids, context=context)
138+ if new_ids:
139+ res = super(calendar_event, self).unlink(cr, uid, new_ids, context=context)
140 self.pool.get('res.alarm').do_alarm_unlink(cr, uid, ids, self._name)
141 self.unlink_events(cr, uid, ids, context=context)
142 return res
143@@ -1515,18 +1537,15 @@
144 def create(self, cr, uid, vals, context=None):
145 if context is None:
146 context = {}
147-
148+ if vals.get('rrule'):
149+ data = self._get_empty_rrule_data()
150+ update_data = self._parse_rrule(vals.get('rrule'), dict(data), vals.get('date'))
151+ vals.update(update_data)
152+ vals['recurrency'] = True
153+
154 if vals.get('vtimezone', '') and vals.get('vtimezone', '').startswith('/freeassociation.sourceforge.net/tzfile/'):
155 vals['vtimezone'] = vals['vtimezone'][40:]
156-
157- #updated_vals = self.onchange_dates(cr, uid, [],
158- # vals.get('date', False),
159- # vals.get('duration', False),
160- # vals.get('date_deadline', False),
161- # vals.get('allday', False),
162- # context=context)
163- #vals.update(updated_vals.get('value', {}))
164-
165+
166 res = super(calendar_event, self).create(cr, uid, vals, context)
167 alarm_obj = self.pool.get('res.alarm')
168 alarm_obj.do_alarm_create(cr, uid, [res], self._name, 'date', context=context)
169@@ -1794,4 +1813,4 @@
170 res_users()
171
172
173-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
174+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
175\ No newline at end of file
176
177=== modified file 'caldav/calendar.py'
178--- caldav/calendar.py 2012-08-07 11:34:14 +0000
179+++ caldav/calendar.py 2012-08-27 05:28:31 +0000
180@@ -372,7 +372,8 @@
181 model_obj = self.pool.get(model)
182 r_ids = []
183 if model_obj._columns.get('recurrent_uid', None):
184- cr.execute('SELECT id FROM %s WHERE recurrent_uid=%%s' % model_obj._table,
185+ if (map_field == "recurrent_ids"):
186+ cr.execute('SELECT id FROM %s WHERE recurrent_uid=%%s' % model_obj._table,
187 (data[map_field],))
188 r_ids = map(lambda x: x[0], cr.fetchall())
189 if r_ids:
190@@ -1297,4 +1298,4 @@
191
192 Attendee()
193
194-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
195+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
196\ No newline at end of file
197
198=== modified file 'crm_caldav/crm_caldav.py'
199--- crm_caldav/crm_caldav.py 2012-01-31 13:36:57 +0000
200+++ crm_caldav/crm_caldav.py 2012-08-27 05:28:31 +0000
201@@ -102,9 +102,13 @@
202 if wematch:
203 model, recur_id, dbname = wematch.groups()
204 val.update({'recurrent_uid': recur_id})
205- event_id = model_obj.create(cr, uid, val)
206- recur_pool[u_id] = event_id
207- ids.append(event_id)
208+ if val.get('recurrent_id') or not context.get('res_id'):
209+ event_id = model_obj.create(cr, uid, val)
210+ recur_pool[u_id] = event_id
211+ ids.append(event_id)
212+ else:
213+ recur_pool[u_id] = context.get('res_id')
214+ ids.append(context.get('res_id'))
215 except Exception:
216 raise
217 return ids

Subscribers

People subscribed via source and target branches

to all changes: