From e65d156693ff5e8985ee443e36fe691dd1fbfd3e Mon Sep 17 00:00:00 2001 From: Bertrand Chenal Date: Thu, 18 Sep 2008 17:07:35 +0200 Subject: [PATCH] Improvement when looping on companies for cron: * update both company and main_company feilds * reset those fields at the end. --- cron.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cron.py b/cron.py index ee5baec279..c5387d64f3 100644 --- a/cron.py +++ b/cron.py @@ -13,7 +13,10 @@ class Cron(OSV): cursor.execute("SELECT company,cron from cron_company_rel " "WHERE cron = %s", (job_id,)) for company, cron in cursor.fetchall(): - cursor.execute("UPDATE res_user SET company = %s " - "WHERE id = %s", (company,user)) + cursor.execute("UPDATE res_user SET company = %s, main_company = %s " + "WHERE id = %s", (company, company, user)) super(Cron, self)._callback(cursor, user, job_id, model, func, args) + cursor.execute("UPDATE res_user SET company = NULL, main_company = NULL " + "WHERE id = %s", (user,)) + Cron()