diff --git a/__init__.py b/__init__.py index e889d774f8..df31a3bad1 100644 --- a/__init__.py +++ b/__init__.py @@ -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 * diff --git a/__tryton__.py b/__tryton__.py index d8bfed373a..cbac41c1fa 100644 --- a/__tryton__.py +++ b/__tryton__.py @@ -15,6 +15,7 @@ ], 'xml': [ 'company.xml', + 'cron.xml', ], 'translation': [ 'fr_FR.csv', diff --git a/cron.py b/cron.py new file mode 100644 index 0000000000..ee5baec279 --- /dev/null +++ b/cron.py @@ -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() diff --git a/cron.xml b/cron.xml new file mode 100644 index 0000000000..f735baa31f --- /dev/null +++ b/cron.xml @@ -0,0 +1,23 @@ + + + + + + + ir.cron + + + + + + + + + ]]> + + + +