Fix for new cron design

codereview39002
This commit is contained in:
Cédric Krier committed 2011-06-14 11:31:31 +02:00
1 parent 2e31656db8
commit 3d11627f54
2 files changed
+15 -12

No files matched your search

+13 -10
View File
@@ -10,17 +10,20 @@ class Cron(ModelSQL, ModelView):
'Companies', help='Companies registered for this cron')
def _callback(self, cron):
cursor = Transaction().cursor
cursor.execute("SELECT company from cron_company_rel "
"WHERE cron = %s", (cron['id'],))
for company, in cursor.fetchall():
cursor.execute(
"UPDATE res_user SET company = %s, main_company = %s "
"WHERE id = %s", (company, company, cron['user']))
user_obj = self.pool.get('res.user')
if not cron.companies:
return super(Cron, self)._callback(cron)
# TODO replace with context
for company in cron.companies:
user_obj.write(cron.user.id, {
'company': company.id,
'main_company': company.id,
})
super(Cron, self)._callback(cron)
cursor.execute(
"UPDATE res_user SET company = NULL, main_company = NULL "
"WHERE id = %s", (cron['user'],))
user_obj.write(cron.user.id, {
'company': False,
'main_company': False,
})
def default_companies(self):
company_obj = self.pool.get('company.company')
+2 -2
View File
@@ -13,8 +13,8 @@ this repository contains the full copyright notices and license terms. -->
<xpath
expr="/form/field[@name=&quot;args&quot;]"
position="after">
<separator name="companies" colspan="6"/>
<field name="companies" colspan="6"/>
<separator name="companies" colspan="4"/>
<field name="companies" colspan="4"/>
</xpath>
</data>
]]>