[RFR] voucher's _get_period

This commit is contained in:
Stefan Rijnhart
2013-04-07 23:36:35 +02:00
parent 097bf9ae60
commit 2b5673fe3f

View File

@@ -447,17 +447,13 @@ class account_voucher(orm.Model):
_inherit = 'account.voucher'
def _get_period(self, cr, uid, context=None):
if context is None: context = {}
if context is None:
context = {}
if not context.get('period_id') and context.get('move_line_ids'):
res = self.pool.get('account.move.line').browse(cr, uid , context.get('move_line_ids'))[0].period_id.id
context['period_id'] = res
return self.pool.get('account.move.line').browse(
cr, uid , context.get('move_line_ids'))[0].period_id.id
return super(account_voucher, self)._get_period(cr, uid, context)
def create(self, cr, uid, values, context=None):
if values.get('period_id') == False and context.get('move_line_ids'):
values['period_id'] = self._get_period(cr, uid, context)
return super(account_voucher, self).create(cr, uid, values, context)
account_voucher()