Add cron job to reconcile move lines

Closes #14468
This commit is contained in:
Cédric Krier
2026-01-06 11:38:37 +01:00
parent 1f702e7151
commit 74e7690c04
6 changed files with 42 additions and 4 deletions
+1
View File
@@ -1,3 +1,4 @@
* Add cron job to reconcile move lines
Version 7.8.0 - 2025-12-15
--------------------------
@@ -15,6 +15,9 @@ account move line's :guilabel:`Reconciliation` field.
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
+16
View File
@@ -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"),
])
+15
View File
@@ -1864,6 +1864,21 @@ class Line(DescriptionOriginMixin, MoveLineMixin, ModelSQL, ModelView):
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'
@@ -6,7 +6,7 @@ Imports::
>>> 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 @@ Activate modules::
>>> 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 @@ Create Moves to reconcile::
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)
+1
View File
@@ -25,6 +25,7 @@ xml:
[register]
model:
ir.Cron
fiscalyear.FiscalYear
fiscalyear.BalanceNonDeferralStart
company.Company