From 2f07acb9e850aee728bcb1024b878eb13bd3c76e Mon Sep 17 00:00:00 2001 From: Bernat Brunet Date: Thu, 13 May 2021 16:47:36 +0200 Subject: [PATCH] Remove not used user and remove duplicated cron calls that produce extra calls to the same cron function. The 'company' module has the loop removed here. --- __init__.py | 2 -- cron.py | 33 --------------------------------- 2 files changed, 35 deletions(-) delete mode 100644 cron.py diff --git a/__init__.py b/__init__.py index f7f16f3..b2307f0 100644 --- a/__init__.py +++ b/__init__.py @@ -4,7 +4,6 @@ from trytond.pool import Pool from . import activity from . import bank -from . import cron from . import employee from . import carrier from . import party @@ -12,7 +11,6 @@ from . import party def register(): Pool.register( - cron.Cron, employee.Employee, party.PartyCompany, party.Party, diff --git a/cron.py b/cron.py deleted file mode 100644 index 7380213..0000000 --- a/cron.py +++ /dev/null @@ -1,33 +0,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. -from trytond.model import ModelView, dualmethod -from trytond.pool import Pool, PoolMeta -from trytond.transaction import Transaction - - -class Cron(metaclass=PoolMeta): - __name__ = "ir.cron" - - @dualmethod - @ModelView.button - def run_once(cls, crons): - pool = Pool() - User = pool.get('res.user') - ModelData = pool.get('ir.model.data') - - user = User(ModelData.get_id('party_company', 'user_party_company')) - - for cron in crons: - if not cron.companies: - super(Cron, cls).run_once([cron]) - else: - # TODO replace with context - for company in cron.companies: - User.write([user], { - 'company': company.id, - }) - with Transaction().set_context(company=company.id): - super(Cron, cls).run_once([cron]) - User.write([user], { - 'company': None, - })