diff --git a/account_mass_reconcile_as_job/README.rst b/account_mass_reconcile_as_job/README.rst new file mode 100644 index 00000000..e69de29b diff --git a/account_mass_reconcile_as_job/__init__.py b/account_mass_reconcile_as_job/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/account_mass_reconcile_as_job/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/account_mass_reconcile_as_job/__manifest__.py b/account_mass_reconcile_as_job/__manifest__.py new file mode 100644 index 00000000..5480bc02 --- /dev/null +++ b/account_mass_reconcile_as_job/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2017 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) +{ + 'name': 'Account Mass Reconcile as Jobs', + 'version': '12.0.0.1.0', + 'category': 'Accounting', + 'depends': [ + 'queue_job', + 'account_mass_reconcile', + ], + 'author': 'Camptocamp, ' + 'Odoo Community Association (OCA)', + 'license': 'AGPL-3', + 'website': 'https://github.com/OCA/account-reconcile', + 'data': [ + 'data/ir_config_parameter.xml', + ], + 'installable': True, + 'application': False, +} diff --git a/account_mass_reconcile_as_job/data/ir_config_parameter.xml b/account_mass_reconcile_as_job/data/ir_config_parameter.xml new file mode 100644 index 00000000..5fe6b79f --- /dev/null +++ b/account_mass_reconcile_as_job/data/ir_config_parameter.xml @@ -0,0 +1,8 @@ + + + + account.mass.reconcile.as.job + + False + + diff --git a/account_mass_reconcile_as_job/models/__init__.py b/account_mass_reconcile_as_job/models/__init__.py new file mode 100644 index 00000000..5fe2f827 --- /dev/null +++ b/account_mass_reconcile_as_job/models/__init__.py @@ -0,0 +1 @@ +from . import mass_reconcile diff --git a/account_mass_reconcile_as_job/models/mass_reconcile.py b/account_mass_reconcile_as_job/models/mass_reconcile.py new file mode 100644 index 00000000..70ee014a --- /dev/null +++ b/account_mass_reconcile_as_job/models/mass_reconcile.py @@ -0,0 +1,40 @@ +# Copyright 2017 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +import ast +import logging + +from odoo import api, models + +_logger = logging.getLogger(__name__) + +try: + from odoo.addons.queue_job.job import job +except ImportError: + _logger.debug('Can not `import queue_job`.') + + +class AccountMassReconcile(models.Model): + _inherit = 'account.mass.reconcile' + + @api.multi + def run_reconcile(self): + as_job = self.env['ir.config_parameter'].sudo().get_param( + 'account.mass.reconcile.as.job', default=False + ) + try: + as_job = ast.literal_eval(as_job) if as_job else False + except ValueError: + as_job = False + + if as_job and self.env.context.get('mass_reconcile_as_job', True): + for rec in self: + rec.with_delay().reconcile_as_job() + return True + else: + return super().run_reconcile() + + @job(default_channel='root.mass_reconcile') + def reconcile_as_job(self): + """Run reconciliation on a single account""" + self.with_context(mass_reconcile_as_job=False).run_reconcile() diff --git a/account_mass_reconcile_as_job/readme/CONTRIBUTORS.rst b/account_mass_reconcile_as_job/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..45067cdd --- /dev/null +++ b/account_mass_reconcile_as_job/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Guewen Baconnier +* Iryna Vyshnevska diff --git a/account_mass_reconcile_as_job/readme/DESCRIPTION.rst b/account_mass_reconcile_as_job/readme/DESCRIPTION.rst new file mode 100644 index 00000000..ea9dd242 --- /dev/null +++ b/account_mass_reconcile_as_job/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Modify the mass reconcile to do only the search (create the groups to +reconcile), but process them asynchronously as jobs. diff --git a/account_mass_reconcile_as_job/readme/USAGE.rst b/account_mass_reconcile_as_job/readme/USAGE.rst new file mode 100644 index 00000000..143a1eef --- /dev/null +++ b/account_mass_reconcile_as_job/readme/USAGE.rst @@ -0,0 +1,2 @@ +The feature can be enabled by setting the ir.config_parameter +"account.mass.reconcile.as.job" to True.