Use context manager to correctly set the company

review372001
This commit is contained in:
Nicolas Évrard committed 2012-09-21 15:20:25 +02:00
1 parent fc1dbfef38
commit 6596def033
1 file changed
+3 -1
+3 -1
View File
@@ -2,6 +2,7 @@
#this repository contains the full copyright notices and license terms.
from trytond.model import ModelView, ModelSQL, fields
from trytond.pool import Pool
from trytond.transaction import Transaction
class Cron(ModelSQL, ModelView):
@@ -20,7 +21,8 @@ class Cron(ModelSQL, ModelView):
'company': company.id,
'main_company': company.id,
})
super(Cron, self)._callback(cron)
with Transaction().set_context(company=company.id):
super(Cron, self)._callback(cron)
user_obj.write(cron.user.id, {
'company': None,
'main_company': None,