def onchange_stage_id(self, cr, uid, ids, stage_id, context=None):
# open a new act window to display
if stage.name == 'Proposal':
print stage.name
return {
'type': 'ir.actions.act_window',
'res_model': 'sale.order',
'view_type': 'form',
'view_mode': 'form',
'target': 'new',
}
when i do this onchange i got an erroronchange_stage_values = self.onchange_stage_id(cr, uid, ids, vals.get('stage_id'), context=context)['value']
KeyError: 'value'
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- Müşteri İlişkileri Yönetimi
- e-Commerce
- Muhasebe
- Envanter
- PoS
- Project
- MRP
Bu soru işaretlendi
You are getting such error because of this code
self.onchange_stage_id(cr, uid, ids, vals.get('stage_id'), context=context)['value']
onchange_stage_id is not returning any dict having "value" as its key/item hence you got that error,
so you can handle it in 2 ways:
1. declare/initialize "value" in the return dict of the onchange function to ensure that it always returns "value" least dummy value.
Something like this
def onchange_stage_id...
res['value'] = {} # initialize res at the start of the function
2. Or you could rewrite your code like
x = self.onchange_stage_id(cr, uid, ids, vals.get('stage_id'), context=context)
onchange_stage_values = x.get('value', {})
x.get('value', {}), this syntax will first try to fetch the key "value" from the dictionary "x", if none found it will return second param i.e {}
I will check that.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Üye Ol
FYI I think you may be missing browse wiith the stage_id to get the stage.