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:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
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.
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký
FYI I think you may be missing browse wiith the stage_id to get the stage.