[FIX] account: check journal centralization performances
This revision is related to 99d8cd6
Avoid to check the journal centralization
mutliple times, for each move lines.
Checking the journal centralization
for each journal for each period just
before the call to `super` is enough.
Before this revision,
if a large number of move lines
was passed in the `ids` parameter
of the `write` method, with all
the same journal / period, this
could lead to huge performances issues,
the `_check_moves` being called
a large number of times for the same
journal and period couple, uselessly.
opw-672797
This commit is contained in:
parent
9752aedb4e
commit
d8d1681a13
|
@ -1221,6 +1221,7 @@ class account_move_line(osv.osv):
|
||||||
todo_date = vals['date']
|
todo_date = vals['date']
|
||||||
del vals['date']
|
del vals['date']
|
||||||
|
|
||||||
|
centralized_journals = []
|
||||||
for line in self.browse(cr, uid, ids, context=context):
|
for line in self.browse(cr, uid, ids, context=context):
|
||||||
ctx = context.copy()
|
ctx = context.copy()
|
||||||
if not ctx.get('journal_id'):
|
if not ctx.get('journal_id'):
|
||||||
|
@ -1235,8 +1236,10 @@ class account_move_line(osv.osv):
|
||||||
ctx['period_id'] = line.period_id.id
|
ctx['period_id'] = line.period_id.id
|
||||||
#Check for centralisation
|
#Check for centralisation
|
||||||
journal = journal_obj.browse(cr, uid, ctx['journal_id'], context=ctx)
|
journal = journal_obj.browse(cr, uid, ctx['journal_id'], context=ctx)
|
||||||
if journal.centralisation:
|
if journal.centralisation and (ctx['journal_id'], ctx['period_id']) not in centralized_journals:
|
||||||
self._check_moves(cr, uid, context=ctx)
|
centralized_journals.append((ctx['journal_id'], ctx['period_id']))
|
||||||
|
for journal_period in centralized_journals:
|
||||||
|
self._check_moves(cr, uid, context=dict(ctx, journal_id=journal_period[0], period_id=journal_period[1]))
|
||||||
result = super(account_move_line, self).write(cr, uid, ids, vals, context)
|
result = super(account_move_line, self).write(cr, uid, ids, vals, context)
|
||||||
|
|
||||||
if affects_move and check and not context.get('novalidate'):
|
if affects_move and check and not context.get('novalidate'):
|
||||||
|
|
Loading…
Reference in New Issue