diff --git a/account_mass_reconcile_as_job/README.rst b/account_mass_reconcile_as_job/README.rst new file mode 100644 index 00000000..1ff22787 --- /dev/null +++ b/account_mass_reconcile_as_job/README.rst @@ -0,0 +1,88 @@ +============================== +Account Mass Reconcile as Jobs +============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github + :target: https://github.com/OCA/account-reconcile/tree/14.0/account_mass_reconcile_as_job + :alt: OCA/account-reconcile +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/account-reconcile-14-0/account-reconcile-14-0-account_mass_reconcile_as_job + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/98/14.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Modify the mass reconcile to do only the search (create the groups to +reconcile), but process them asynchronously as jobs. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +The feature can be enabled by setting the ir.config_parameter +"account.mass.reconcile.as.job" to True. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Camptocamp + +Contributors +~~~~~~~~~~~~ + +* Guewen Baconnier +* Iryna Vyshnevska +* `Trobz `_: + * Hoang Diep + +Other credits +~~~~~~~~~~~~~ + +The migration of this module from 12.0 to 14.0 was financially supported by Camptocamp + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/account-reconcile `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. 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..3e2eec86 --- /dev/null +++ b/account_mass_reconcile_as_job/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2017 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) +{ + "name": "Account Mass Reconcile as Jobs", + "version": "14.0.1.0.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_data.xml", + "data/queue_job_channel_data.xml", + "data/queue_job_function_data.xml", + ], + "installable": True, + "application": False, +} diff --git a/account_mass_reconcile_as_job/data/ir_config_parameter_data.xml b/account_mass_reconcile_as_job/data/ir_config_parameter_data.xml new file mode 100644 index 00000000..028ad72f --- /dev/null +++ b/account_mass_reconcile_as_job/data/ir_config_parameter_data.xml @@ -0,0 +1,8 @@ + + + + account.mass.reconcile.as.job + + False + + diff --git a/account_mass_reconcile_as_job/data/queue_job_channel_data.xml b/account_mass_reconcile_as_job/data/queue_job_channel_data.xml new file mode 100644 index 00000000..1f5da56c --- /dev/null +++ b/account_mass_reconcile_as_job/data/queue_job_channel_data.xml @@ -0,0 +1,6 @@ + + + mass.reconcile.job + + + diff --git a/account_mass_reconcile_as_job/data/queue_job_function_data.xml b/account_mass_reconcile_as_job/data/queue_job_function_data.xml new file mode 100644 index 00000000..5e69f25b --- /dev/null +++ b/account_mass_reconcile_as_job/data/queue_job_function_data.xml @@ -0,0 +1,13 @@ + + + + + reconcile_as_job + + 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..3d959f00 --- /dev/null +++ b/account_mass_reconcile_as_job/models/mass_reconcile.py @@ -0,0 +1,35 @@ +# Copyright 2017 Camptocamp SA +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +import ast +import logging + +from odoo import models + +_logger = logging.getLogger(__name__) + + +class AccountMassReconcile(models.Model): + _inherit = "account.mass.reconcile" + + 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() + + def reconcile_as_job(self): + """Run reconciliation on a single account""" + return 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..12dfee9f --- /dev/null +++ b/account_mass_reconcile_as_job/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Guewen Baconnier +* Iryna Vyshnevska +* `Trobz `_: + * Hoang Diep diff --git a/account_mass_reconcile_as_job/readme/CREDITS.rst b/account_mass_reconcile_as_job/readme/CREDITS.rst new file mode 100644 index 00000000..ca6e4f9c --- /dev/null +++ b/account_mass_reconcile_as_job/readme/CREDITS.rst @@ -0,0 +1 @@ +The migration of this module from 12.0 to 14.0 was financially supported by Camptocamp 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. diff --git a/account_mass_reconcile_as_job/static/description/index.html b/account_mass_reconcile_as_job/static/description/index.html new file mode 100644 index 00000000..cf437fa2 --- /dev/null +++ b/account_mass_reconcile_as_job/static/description/index.html @@ -0,0 +1,440 @@ + + + + + + +Account Mass Reconcile as Jobs + + + +
+

Account Mass Reconcile as Jobs

+ + +

Beta License: AGPL-3 OCA/account-reconcile Translate me on Weblate Try me on Runbot

+

Modify the mass reconcile to do only the search (create the groups to +reconcile), but process them asynchronously as jobs.

+

Table of contents

+ +
+

Usage

+

The feature can be enabled by setting the ir.config_parameter +“account.mass.reconcile.as.job” to True.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The migration of this module from 12.0 to 14.0 was financially supported by Camptocamp

+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/account-reconcile project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_mass_reconcile_as_job/tests/__init__.py b/account_mass_reconcile_as_job/tests/__init__.py new file mode 100644 index 00000000..111a97bc --- /dev/null +++ b/account_mass_reconcile_as_job/tests/__init__.py @@ -0,0 +1 @@ +from . import test_mass_reconcile_as_job diff --git a/account_mass_reconcile_as_job/tests/test_mass_reconcile_as_job.py b/account_mass_reconcile_as_job/tests/test_mass_reconcile_as_job.py new file mode 100644 index 00000000..a238fafb --- /dev/null +++ b/account_mass_reconcile_as_job/tests/test_mass_reconcile_as_job.py @@ -0,0 +1,33 @@ +from odoo.tests.common import TransactionCase + +from odoo.addons.queue_job.job import Job + + +class TestReconcileAsJob(TransactionCase): + def test_reconcile_as_job(self): + self.cr.execute("delete from queue_job") + + # set param to run reconcile as job + self.env["ir.config_parameter"].sudo().set_param( + "account.mass.reconcile.as.job", True + ) + as_job = ( + self.env["ir.config_parameter"] + .sudo() + .set_param("account.mass.reconcile.as.job", True) + ) + self.assertTrue(as_job) + + model = self.env["account.mass.reconcile"] + job_1 = model.with_delay().reconcile_as_job() + self.assertEqual(job_1.db_record().state, "pending") + job = Job.load(self.env, job_1.uuid) + job.perform() + job.set_done() + job.store() + + job_domain = [ + ("uuid", "=", job_1.uuid), + ] + job_1 = self.env["queue.job"].search(job_domain) + self.assertEqual(job_1.state, "done") diff --git a/setup/account_mass_reconcile_as_job/odoo/addons/account_mass_reconcile_as_job b/setup/account_mass_reconcile_as_job/odoo/addons/account_mass_reconcile_as_job new file mode 120000 index 00000000..ca4f544a --- /dev/null +++ b/setup/account_mass_reconcile_as_job/odoo/addons/account_mass_reconcile_as_job @@ -0,0 +1 @@ +../../../../account_mass_reconcile_as_job \ No newline at end of file diff --git a/setup/account_mass_reconcile_as_job/setup.py b/setup/account_mass_reconcile_as_job/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/account_mass_reconcile_as_job/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)