From 2b5673fe3f796554dac3508fb1322f421d933516 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Sun, 7 Apr 2013 23:36:35 +0200 Subject: [PATCH] [RFR] voucher's _get_period --- account_banking/account_banking.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/account_banking/account_banking.py b/account_banking/account_banking.py index 6dfa9c932..41aecb875 100644 --- a/account_banking/account_banking.py +++ b/account_banking/account_banking.py @@ -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()