[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
This commit is contained in:
Mantavya Gajjar 2010-08-13 16:37:27 +05:30
parent 039648d14c
commit c14544fe29
1 changed files with 14 additions and 3 deletions

View File

@ -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 = []