[IMP]: improve onchange_tye for the journal

bzr revid: mga@tinyerp.com-20100708131755-vovhfnyt2i8u7y9o
This commit is contained in:
Mantavya Gajjar 2010-07-08 18:47:55 +05:30
parent 4ce21feabe
commit fa56e44dcb
1 changed files with 28 additions and 7 deletions

View File

@ -638,6 +638,7 @@ class account_journal(osv.osv):
'user_id': lambda self,cr,uid,context: uid,
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
}
def write(self, cr, uid, ids, vals, context=None):
obj=[]
if 'company_id' in vals:
@ -720,13 +721,33 @@ class account_journal(osv.osv):
return self.name_get(cr, user, ids, context=context)
def onchange_type(self, cr, uid, ids, type):
res={}
for line in self.browse(cr, uid, ids):
if type == 'situation':
res= {'value':{'centralisation': True}}
else:
res= {'value':{'centralisation': False}}
return res
data_pool = self.pool.get('ir.model.data')
type_map = {
'sale':'account_sp_journal_view',
'sale_refund':'account_sp_refund_journal_view',
'purchase':'account_sp_journal_view',
'purchase_refund':'account_sp_refund_journal_view',
'expense':'account_sp_journal_view',
'cash':'account_journal_bank_view',
'bank':'account_journal_bank_view',
'general':'account_journal_view',
'situation':'account_journal_view'
}
res = {}
view_id = type_map.get(type, 'general')
data_id = data_pool.search(cr, uid, [('model','=','account.journal.view'), ('name','=',view_id)])
data = data_pool.browse(cr, uid, data_id[0])
res.update({
'centralisation':type == 'situation',
'view_id':data.res_id,
})
return {
'value':res
}
account_journal()