[12.0][ADD] account_mass_reconcile_as_job

[FIX] lint
This commit is contained in:
Iryna Vushnevska
2020-07-07 18:49:21 +03:00
committed by Diep Huu Hoang
parent 6f643c7b58
commit aa255ab632
9 changed files with 76 additions and 0 deletions

View File

View File

@@ -0,0 +1 @@
from . import models

View File

@@ -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,
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<record id="config_param_mass_reconcile_as_job" model="ir.config_parameter">
<field name="key">account.mass.reconcile.as.job</field>
<!-- keep key creation with False to avoid test conflicts -->
<field name="value">False</field>
</record>
</odoo>

View File

@@ -0,0 +1 @@
from . import mass_reconcile

View File

@@ -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()

View File

@@ -0,0 +1,2 @@
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
* Iryna Vyshnevska <i.vyshnevska@mobilunity.com>

View File

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

View File

@@ -0,0 +1,2 @@
The feature can be enabled by setting the ir.config_parameter
"account.mass.reconcile.as.job" to True.