From aa255ab632f21b41a8dc3e650853c5ed5c98a0d1 Mon Sep 17 00:00:00 2001 From: Iryna Vushnevska Date: Tue, 7 Jul 2020 18:49:21 +0300 Subject: [PATCH 1/3] [12.0][ADD] account_mass_reconcile_as_job [FIX] lint --- account_mass_reconcile_as_job/README.rst | 0 account_mass_reconcile_as_job/__init__.py | 1 + account_mass_reconcile_as_job/__manifest__.py | 20 ++++++++++ .../data/ir_config_parameter.xml | 8 ++++ .../models/__init__.py | 1 + .../models/mass_reconcile.py | 40 +++++++++++++++++++ .../readme/CONTRIBUTORS.rst | 2 + .../readme/DESCRIPTION.rst | 2 + .../readme/USAGE.rst | 2 + 9 files changed, 76 insertions(+) create mode 100644 account_mass_reconcile_as_job/README.rst create mode 100644 account_mass_reconcile_as_job/__init__.py create mode 100644 account_mass_reconcile_as_job/__manifest__.py create mode 100644 account_mass_reconcile_as_job/data/ir_config_parameter.xml create mode 100644 account_mass_reconcile_as_job/models/__init__.py create mode 100644 account_mass_reconcile_as_job/models/mass_reconcile.py create mode 100644 account_mass_reconcile_as_job/readme/CONTRIBUTORS.rst create mode 100644 account_mass_reconcile_as_job/readme/DESCRIPTION.rst create mode 100644 account_mass_reconcile_as_job/readme/USAGE.rst 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. From 46b15a5b545d5f2551106943318479ec3bed45f8 Mon Sep 17 00:00:00 2001 From: Diep Huu Hoang Date: Tue, 7 Dec 2021 12:43:15 +0700 Subject: [PATCH 2/3] [IMP] account_mass_reconcile_as_job: black, isort, prettier --- account_mass_reconcile_as_job/__manifest__.py | 27 +++++++++---------- .../data/ir_config_parameter.xml | 2 +- .../models/mass_reconcile.py | 14 +++++----- .../odoo/addons/account_mass_reconcile_as_job | 1 + setup/account_mass_reconcile_as_job/setup.py | 6 +++++ 5 files changed, 29 insertions(+), 21 deletions(-) create mode 120000 setup/account_mass_reconcile_as_job/odoo/addons/account_mass_reconcile_as_job create mode 100644 setup/account_mass_reconcile_as_job/setup.py diff --git a/account_mass_reconcile_as_job/__manifest__.py b/account_mass_reconcile_as_job/__manifest__.py index 5480bc02..3ccc48f0 100644 --- a/account_mass_reconcile_as_job/__manifest__.py +++ b/account_mass_reconcile_as_job/__manifest__.py @@ -1,20 +1,19 @@ # 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', + "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', + "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, + "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 index 5fe6b79f..028ad72f 100644 --- a/account_mass_reconcile_as_job/data/ir_config_parameter.xml +++ b/account_mass_reconcile_as_job/data/ir_config_parameter.xml @@ -1,4 +1,4 @@ - + account.mass.reconcile.as.job diff --git a/account_mass_reconcile_as_job/models/mass_reconcile.py b/account_mass_reconcile_as_job/models/mass_reconcile.py index 70ee014a..7bdcaca4 100644 --- a/account_mass_reconcile_as_job/models/mass_reconcile.py +++ b/account_mass_reconcile_as_job/models/mass_reconcile.py @@ -11,30 +11,32 @@ _logger = logging.getLogger(__name__) try: from odoo.addons.queue_job.job import job except ImportError: - _logger.debug('Can not `import queue_job`.') + _logger.debug("Can not `import queue_job`.") class AccountMassReconcile(models.Model): - _inherit = 'account.mass.reconcile' + _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 + 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): + 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') + @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/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, +) From 8abdbfa086aa318c593b199dd318f4f299b2ecdd Mon Sep 17 00:00:00 2001 From: Diep Huu Hoang Date: Thu, 9 Dec 2021 11:08:11 +0700 Subject: [PATCH 3/3] [14.0][MIG] account_mass_reconcile_as_job: Migration to 14.0 --- account_mass_reconcile_as_job/README.rst | 88 ++++ account_mass_reconcile_as_job/__manifest__.py | 6 +- ...meter.xml => ir_config_parameter_data.xml} | 0 .../data/queue_job_channel_data.xml | 6 + .../data/queue_job_function_data.xml | 13 + .../models/mass_reconcile.py | 11 +- .../readme/CONTRIBUTORS.rst | 2 + .../readme/CREDITS.rst | 1 + .../static/description/index.html | 440 ++++++++++++++++++ .../tests/__init__.py | 1 + .../tests/test_mass_reconcile_as_job.py | 33 ++ 11 files changed, 590 insertions(+), 11 deletions(-) rename account_mass_reconcile_as_job/data/{ir_config_parameter.xml => ir_config_parameter_data.xml} (100%) create mode 100644 account_mass_reconcile_as_job/data/queue_job_channel_data.xml create mode 100644 account_mass_reconcile_as_job/data/queue_job_function_data.xml create mode 100644 account_mass_reconcile_as_job/readme/CREDITS.rst create mode 100644 account_mass_reconcile_as_job/static/description/index.html create mode 100644 account_mass_reconcile_as_job/tests/__init__.py create mode 100644 account_mass_reconcile_as_job/tests/test_mass_reconcile_as_job.py diff --git a/account_mass_reconcile_as_job/README.rst b/account_mass_reconcile_as_job/README.rst index e69de29b..1ff22787 100644 --- a/account_mass_reconcile_as_job/README.rst +++ 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/__manifest__.py b/account_mass_reconcile_as_job/__manifest__.py index 3ccc48f0..3e2eec86 100644 --- a/account_mass_reconcile_as_job/__manifest__.py +++ b/account_mass_reconcile_as_job/__manifest__.py @@ -2,7 +2,7 @@ # 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", + "version": "14.0.1.0.0", "category": "Accounting", "depends": [ "queue_job", @@ -12,7 +12,9 @@ "license": "AGPL-3", "website": "https://github.com/OCA/account-reconcile", "data": [ - "data/ir_config_parameter.xml", + "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.xml b/account_mass_reconcile_as_job/data/ir_config_parameter_data.xml similarity index 100% rename from account_mass_reconcile_as_job/data/ir_config_parameter.xml rename to account_mass_reconcile_as_job/data/ir_config_parameter_data.xml 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/mass_reconcile.py b/account_mass_reconcile_as_job/models/mass_reconcile.py index 7bdcaca4..3d959f00 100644 --- a/account_mass_reconcile_as_job/models/mass_reconcile.py +++ b/account_mass_reconcile_as_job/models/mass_reconcile.py @@ -4,20 +4,14 @@ import ast import logging -from odoo import api, models +from odoo import 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"] @@ -36,7 +30,6 @@ class AccountMassReconcile(models.Model): 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() + 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 index 45067cdd..12dfee9f 100644 --- a/account_mass_reconcile_as_job/readme/CONTRIBUTORS.rst +++ b/account_mass_reconcile_as_job/readme/CONTRIBUTORS.rst @@ -1,2 +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/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")