Hello all,
I have created many2one field for category in my object. Based on my object value, I want to set default value for 'type' field of Category.
Can anybody help me how to do it?
Thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello all,
I have created many2one field for category in my object. Based on my object value, I want to set default value for 'type' field of Category.
Can anybody help me how to do it?
Thanks
Define default Method Code
def _get_default_category(self, cr, uid, context=None):
res = self.pool.get('model.category').search(cr, uid, [('name','=',categroy_name)], context=context)
return return res and res[0] or False
_defaults = {
'category_id':_get_default_category,
}
This is not what I want exactly, Your method will give category_id by default based on function. But I want to set type of model.category based on active object(e.g. test.test).
so you can try on_change function based on the change object(test.test) field value model.category value set in the on change method
on change method will be called while I enter some value in some field. If I directly create record, and then create category from test.test default type should come. Is it possible to do ? For example: Create product, then create Contract from product form, by default employee should come as Administrator.
Thanks Prakash, great example!
Создайте аккаунт сегодня, чтобы получить доступ к эксклюзивным функциям и стать частью нашего замечательного сообщества!
Регистрация| Похожие посты | Ответы | Просмотры | Активность | |
|---|---|---|---|---|
|
3
сент. 25
|
2259 | |||
|
2
февр. 25
|
6860 | |||
|
3
авг. 22
|
14250 | |||
|
2
авг. 22
|
5196 | |||
|
0
июл. 22
|
836 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.