details:   https://code.tryton.org/tryton/commit/79fc43326a34
branch:    default
user:      Cédric Krier <[email protected]>
date:      Tue Jan 06 11:38:37 2026 +0100
description:
        Add cron job to reconcile move lines

        Closes #14468
diffstat:

 modules/account/CHANGELOG                                      |   1 +
 modules/account/doc/usage/process.inc.rst                      |   3 +
 modules/account/ir.py                                          |  16 ++++++++++
 modules/account/move.py                                        |  15 +++++++++
 modules/account/tests/scenario_account_reconcile_automatic.rst |  10 +++--
 modules/account/tryton.cfg                                     |   1 +
 6 files changed, 42 insertions(+), 4 deletions(-)

diffs (111 lines):

diff -r 3bb659ccd03c -r 79fc43326a34 modules/account/CHANGELOG
--- a/modules/account/CHANGELOG Mon Jan 05 12:15:49 2026 +0100
+++ b/modules/account/CHANGELOG Tue Jan 06 11:38:37 2026 +0100
@@ -1,3 +1,4 @@
+* Add cron job to reconcile move lines
 
 Version 7.8.0 - 2025-12-15
 --------------------------
diff -r 3bb659ccd03c -r 79fc43326a34 modules/account/doc/usage/process.inc.rst
--- a/modules/account/doc/usage/process.inc.rst Mon Jan 05 12:15:49 2026 +0100
+++ b/modules/account/doc/usage/process.inc.rst Tue Jan 06 11:38:37 2026 +0100
@@ -15,6 +15,9 @@
 The `Reconcile Accounts <wizard-account.reconcile>` wizard is used to manually
 run this account reconciliation.
 
+You may want to define some :guilabel:`Reconcile Move Lines Automatically`
+`scheduled tasks <trytond:model-ir.cron>` to automate the reconciliation.
+
 .. note::
 
    Some other processes in Tryton will automatically reconcile account move
diff -r 3bb659ccd03c -r 79fc43326a34 modules/account/ir.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/account/ir.py     Tue Jan 06 11:38:37 2026 +0100
@@ -0,0 +1,16 @@
+# The COPYRIGHT file at the top level of this repository contains the full
+# copyright notices and license terms.
+
+from trytond.pool import PoolMeta
+
+
+class Cron(metaclass=PoolMeta):
+    __name__ = 'ir.cron'
+
+    @classmethod
+    def __setup__(cls):
+        super().__setup__()
+        cls.method.selection.extend([
+                ('account.move.line|reconcile_automatic',
+                    "Reconcile Move Lines Automatically"),
+                ])
diff -r 3bb659ccd03c -r 79fc43326a34 modules/account/move.py
--- a/modules/account/move.py   Mon Jan 05 12:15:49 2026 +0100
+++ b/modules/account/move.py   Tue Jan 06 11:38:37 2026 +0100
@@ -1864,6 +1864,21 @@
     def _reconciliation_sort_key(self):
         return self.maturity_date or self.date
 
+    @classmethod
+    def reconcile_automatic(cls, data=None):
+        pool = Pool()
+        Reconcile = pool.get('account.reconcile', type='wizard')
+
+        data = data.copy() if data is not None else {}
+        data['start'] = {
+            'automatic': True,
+            'only_balanced': True,
+            }
+
+        session_id, _, _ = Reconcile.create()
+        Reconcile.execute(session_id, data, 'setup')
+        Reconcile.delete(session_id)
+
 
 class LineReceivablePayableContext(ModelView):
     __name__ = 'account.move.line.receivable_payable.context'
diff -r 3bb659ccd03c -r 79fc43326a34 
modules/account/tests/scenario_account_reconcile_automatic.rst
--- a/modules/account/tests/scenario_account_reconcile_automatic.rst    Mon Jan 
05 12:15:49 2026 +0100
+++ b/modules/account/tests/scenario_account_reconcile_automatic.rst    Tue Jan 
06 11:38:37 2026 +0100
@@ -6,7 +6,7 @@
 
     >>> from decimal import Decimal
 
-    >>> from proteus import Model, Wizard
+    >>> from proteus import Model
     >>> from trytond.modules.account.tests.tools import (
     ...     create_chart, create_fiscalyear, get_accounts)
     >>> from trytond.modules.company.tests.tools import create_company
@@ -16,6 +16,7 @@
 
     >>> config = activate_modules('account', create_company, create_chart)
 
+    >>> Cron = Model.get('ir.cron')
     >>> Journal = Model.get('account.journal')
     >>> Line = Model.get('account.move.line')
     >>> Move = Model.get('account.move')
@@ -73,9 +74,10 @@
 
 Run Reconcile wizard::
 
-    >>> reconcile = Wizard('account.reconcile')
-    >>> reconcile.form.automatic = True
-    >>> reconcile.execute('setup')
+    >>> reconcile = Cron(
+    ...     method='account.move.line|reconcile_automatic',
+    ...     interval_number=1, interval_type='days')
+    >>> reconcile.click('run_once')
 
     >>> lines = Line.find([('account', '=', accounts['receivable'].id)])
     >>> len(lines)
diff -r 3bb659ccd03c -r 79fc43326a34 modules/account/tryton.cfg
--- a/modules/account/tryton.cfg        Mon Jan 05 12:15:49 2026 +0100
+++ b/modules/account/tryton.cfg        Tue Jan 06 11:38:37 2026 +0100
@@ -25,6 +25,7 @@
 
 [register]
 model:
+    ir.Cron
     fiscalyear.FiscalYear
     fiscalyear.BalanceNonDeferralStart
     company.Company

Reply via email to