mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
[12.0][ADD] account_mass_reconcile_as_job
[FIX] lint
This commit is contained in:
committed by
Diep Huu Hoang
parent
6f643c7b58
commit
aa255ab632
0
account_mass_reconcile_as_job/README.rst
Normal file
0
account_mass_reconcile_as_job/README.rst
Normal file
1
account_mass_reconcile_as_job/__init__.py
Normal file
1
account_mass_reconcile_as_job/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
20
account_mass_reconcile_as_job/__manifest__.py
Normal file
20
account_mass_reconcile_as_job/__manifest__.py
Normal 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,
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
1
account_mass_reconcile_as_job/models/__init__.py
Normal file
1
account_mass_reconcile_as_job/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import mass_reconcile
|
||||||
40
account_mass_reconcile_as_job/models/mass_reconcile.py
Normal file
40
account_mass_reconcile_as_job/models/mass_reconcile.py
Normal 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()
|
||||||
2
account_mass_reconcile_as_job/readme/CONTRIBUTORS.rst
Normal file
2
account_mass_reconcile_as_job/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
* Guewen Baconnier <guewen.baconnier@camptocamp.com>
|
||||||
|
* Iryna Vyshnevska <i.vyshnevska@mobilunity.com>
|
||||||
2
account_mass_reconcile_as_job/readme/DESCRIPTION.rst
Normal file
2
account_mass_reconcile_as_job/readme/DESCRIPTION.rst
Normal 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.
|
||||||
2
account_mass_reconcile_as_job/readme/USAGE.rst
Normal file
2
account_mass_reconcile_as_job/readme/USAGE.rst
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
The feature can be enabled by setting the ir.config_parameter
|
||||||
|
"account.mass.reconcile.as.job" to True.
|
||||||
Reference in New Issue
Block a user