[IMP] account: performance improvement on the creation of new account.move (opw #597719)

bzr revid: mat@openerp.com-20130918143146-bnmoje96alatdyc1
This commit is contained in:
Martin Trigaux 2013-09-18 16:31:46 +02:00
parent d30f5e8be6
commit f37b2a0db4
2 changed files with 6 additions and 3 deletions

View File

@ -1425,14 +1425,17 @@ class account_move(osv.osv):
l[2]['period_id'] = default_period
context['period_id'] = default_period
if 'line_id' in vals:
if vals.get('line_id', False):
c = context.copy()
c['novalidate'] = True
c['period_id'] = vals['period_id'] if 'period_id' in vals else self._get_period(cr, uid, context)
c['journal_id'] = vals['journal_id']
if 'date' in vals: c['date'] = vals['date']
result = super(account_move, self).create(cr, uid, vals, c)
self.validate(cr, uid, [result], context)
tmp = self.validate(cr, uid, [result], context)
journal = self.pool.get('account.journal').browse(cr, uid, vals['journal_id'], context)
if journal.entry_posted and tmp:
self.button_validate(cr,uid, [result], context)
else:
result = super(account_move, self).create(cr, uid, vals, context)
return result

View File

@ -1284,7 +1284,7 @@ class account_move_line(osv.osv):
self.create(cr, uid, data, context)
del vals['account_tax_id']
if check and ((not context.get('no_store_function')) or journal.entry_posted):
if check and not context.get('novalidate') and ((not context.get('no_store_function')) or journal.entry_posted):
tmp = move_obj.validate(cr, uid, [vals['move_id']], context)
if journal.entry_posted and tmp:
move_obj.button_validate(cr,uid, [vals['move_id']], context)