[IMP] account_mass_reconcile_as_job: black, isort, prettier

This commit is contained in:
Diep Huu Hoang
2021-12-07 12:43:15 +07:00
parent aa255ab632
commit 46b15a5b54
5 changed files with 29 additions and 21 deletions

View File

@@ -1,20 +1,19 @@
# Copyright 2017 Camptocamp SA # Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
{ {
'name': 'Account Mass Reconcile as Jobs', "name": "Account Mass Reconcile as Jobs",
'version': '12.0.0.1.0', "version": "12.0.0.1.0",
'category': 'Accounting', "category": "Accounting",
'depends': [ "depends": [
'queue_job', "queue_job",
'account_mass_reconcile', "account_mass_reconcile",
], ],
'author': 'Camptocamp, ' "author": "Camptocamp, " "Odoo Community Association (OCA)",
'Odoo Community Association (OCA)', "license": "AGPL-3",
'license': 'AGPL-3', "website": "https://github.com/OCA/account-reconcile",
'website': 'https://github.com/OCA/account-reconcile', "data": [
'data': [ "data/ir_config_parameter.xml",
'data/ir_config_parameter.xml',
], ],
'installable': True, "installable": True,
'application': False, "application": False,
} }

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1"> <odoo noupdate="1">
<record id="config_param_mass_reconcile_as_job" model="ir.config_parameter"> <record id="config_param_mass_reconcile_as_job" model="ir.config_parameter">
<field name="key">account.mass.reconcile.as.job</field> <field name="key">account.mass.reconcile.as.job</field>

View File

@@ -11,30 +11,32 @@ _logger = logging.getLogger(__name__)
try: try:
from odoo.addons.queue_job.job import job from odoo.addons.queue_job.job import job
except ImportError: except ImportError:
_logger.debug('Can not `import queue_job`.') _logger.debug("Can not `import queue_job`.")
class AccountMassReconcile(models.Model): class AccountMassReconcile(models.Model):
_inherit = 'account.mass.reconcile' _inherit = "account.mass.reconcile"
@api.multi @api.multi
def run_reconcile(self): def run_reconcile(self):
as_job = self.env['ir.config_parameter'].sudo().get_param( as_job = (
'account.mass.reconcile.as.job', default=False self.env["ir.config_parameter"]
.sudo()
.get_param("account.mass.reconcile.as.job", default=False)
) )
try: try:
as_job = ast.literal_eval(as_job) if as_job else False as_job = ast.literal_eval(as_job) if as_job else False
except ValueError: except ValueError:
as_job = False 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: for rec in self:
rec.with_delay().reconcile_as_job() rec.with_delay().reconcile_as_job()
return True return True
else: else:
return super().run_reconcile() return super().run_reconcile()
@job(default_channel='root.mass_reconcile') @job(default_channel="root.mass_reconcile")
def reconcile_as_job(self): def reconcile_as_job(self):
"""Run reconciliation on a single account""" """Run reconciliation on a single account"""
self.with_context(mass_reconcile_as_job=False).run_reconcile() self.with_context(mass_reconcile_as_job=False).run_reconcile()

View File

@@ -0,0 +1 @@
../../../../account_mass_reconcile_as_job

View File

@@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)