From c14544fe29fb71bfd66cbc9d484c9af4689f9b35 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Fri, 13 Aug 2010 16:37:27 +0530 Subject: [PATCH] [FIX]: make a general method to convert string period_id to integer [FIX]: fix problem toolbar in form view for account move line bzr revid: mga@tinyerp.com-20100813110727-uhw2nwufbcjyx9jb --- addons/account/account_move_line.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index e575fbd3f78..33c33390030 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -144,10 +144,9 @@ class account_move_line(osv.osv): del(data['account_tax_id']) return data - def _default_get(self, cr, uid, fields, context={}): - + def convert_to_period(self, cr, uid, context={}): period_obj = self.pool.get('account.period') - + #check if the period_id changed in the context from client side if context.get('period_id', False): period_id = context.get('period_id') @@ -156,6 +155,14 @@ class account_move_line(osv.osv): context.update({ 'period_id':ids[0] }) + + return context + + def _default_get(self, cr, uid, fields, context={}): + + period_obj = self.pool.get('account.period') + + context = self.convert_to_period(cr, uid, context) # Compute simple values data = super(account_move_line, self).default_get(cr, uid, fields, context) @@ -793,6 +800,7 @@ class account_move_line(osv.osv): return r_id def view_header_get(self, cr, user, view_id, view_type, context): + context = self.convert_to_period(cr, user, context) if context.get('account_id', False): cr.execute('select code from account_account where id=%s', (context['account_id'],)) res = cr.fetchone() @@ -836,6 +844,9 @@ class account_move_line(osv.osv): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context={}, toolbar=False, submenu=False): result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) if view_type != 'tree': + #Remove the toolbar from the form view + if view_type == 'form': + result['toolbar']['action'] = [] return result fld = []