mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
36 lines
1005 B
Python
36 lines
1005 B
Python
# 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()
|