From 39aa2bd391025246e4520e8e7d3b2dc0af23ec3d Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 12 Oct 2010 13:41:18 +0300 Subject: [PATCH] base_calendar, caldav: fixes for the queries. bzr revid: p_christ@hol.gr-20101012104118-o02tug6x3t9gewaa --- addons/base_calendar/base_calendar.py | 18 +++++++----------- addons/caldav/calendar.py | 3 ++- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 2a0b0cc60ad..a37630f8d96 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -1017,7 +1017,8 @@ class calendar_event(osv.osv): elif int(val.get('interval')) > 1: #If interval is other than 1 rule is custom rrule_type = 'custom' - qry = "UPDATE %(table)s set rrule_type=\'%(rule_type)s\' " + qry = "UPDATE \"%s\" set rrule_type=%%s " % self._table + qry_args = [ rrule_type, ] if rrule_type == 'custom': new_val = val.copy() @@ -1055,17 +1056,12 @@ class calendar_event(osv.osv): new_val.pop('bymonth') for k, v in new_val.items(): - temp = ", %s='%s'" % (k, v) - qry += temp + qry += ", %s=%%s" % k + qry_args.append(v) - whr = " where id=%(id)s" - qry = qry + whr - val.update({ - 'table': self._table, - 'rule_type': rrule_type, - 'id': id, - }) - cr.execute(qry, val) # Hopefully psycopg2 works with dicts. But, FIXME + qry = qry + " where id=%s" + qry_args.append(id) + cr.execute(qry, qry_args) return True def _get_rulestring(self, cr, uid, ids, name, arg, context=None): diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py index 276f08c5f51..ae9aa909642 100644 --- a/addons/caldav/calendar.py +++ b/addons/caldav/calendar.py @@ -71,7 +71,8 @@ def uid2openobjectid(cr, uidval, oomodel, rdate): r_id = cr.fetchone() if r_id: return (id, r_id[0]) - + else: + return (False, None) cr.execute(qry) ids = map(lambda x: str(x[0]), cr.fetchall()) if id in ids: