Handle multi-companies for cron jobs

This commit is contained in:
Bertrand Chenal committed 2008-09-18 16:20:13 +02:00
1 parent 26af8b90b5
commit f1770593dc
4 files changed
+44

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms.
from company import *
from cron import *
+1
View File
@@ -15,6 +15,7 @@
],
'xml': [
'company.xml',
'cron.xml',
],
'translation': [
'fr_FR.csv',
+19
View File
@@ -0,0 +1,19 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
from trytond.osv import fields, OSV
class Cron(OSV):
"Cron"
_name = "ir.cron"
companies = fields.Many2Many(
'company.company', 'cron_company_rel', 'cron', 'company', 'Companies',
help='Companies registered for this cron')
def _callback(self, cursor, user, job_id, model, func, args):
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))
super(Cron, self)._callback(cursor, user, job_id, model, func, args)
Cron()
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
<tryton>
<data>
<record model="ir.ui.view" id="cron_view_form">
<field name="model">ir.cron</field>
<field name="inherit" ref="ir.cron_view_form"/>
<field name="arch" type="xml">
<![CDATA[
<data>
<xpath
expr="/form/field[@name=&quot;args&quot;]"
position="after">
<separator name="companies" colspan="6"/>
<field name="companies" colspan="6"/>
</xpath>
</data>
]]>
</field>
</record>
</data>
</tryton>