[WIP] add proper search for period.

This commit is contained in:
Ronald Portier (Therp BV)
2015-02-26 16:34:23 +01:00
committed by Stefan Rijnhart
parent 98fb49aea2
commit 6ef58a47e7

View File

@@ -28,13 +28,15 @@ class AccountMoveLine(orm.Model):
def create(self, cr, uid, vals, context=None, check=True):
"""If requested, override period from date."""
ctx = context.copy() or {}
if (('override_period_from_date' in ctx or
'period_id' not in vals) and 'date' in vals):
period_model = self.pool['account.period']
period_ids = period_search
## BE CAREFULL, ALSO CHECK COMPANY
vals['period_id'] = period_ids[0]
ctx = context.copy() or {}
if (('override_period_from_date' in ctx or
'period_id' not in vals) and 'date' in vals):
period_model = self.pool['account.period']
search_date = 'date' in vals and vals['date'] or None
period_ids = period_model.find(
cr, uid, dt=search_date, context=ctx)
if period_ids:
vals['period_id'] = period_ids[0]
return super(AccountMoveLine, self).create(
cr, uid, vals, context=context, check=check)