Improvement when looping on companies for cron:

* update both company and main_company feilds
* reset those fields at the end.
This commit is contained in:
Bertrand Chenal
2008-09-18 17:07:35 +02:00
parent f1770593dc
commit e65d156693
+5 -2
View File
@@ -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()