Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
3 Ответы
4242 Представления

Hi,

I'm working for the first time with wizard in Odoo.

My goal is to add tree view in my wizard.

So my wizard is created and working, but I can't figured out how to display my selected records in this tree view.

I created a function in my wizard python where I get these ids but I don't know how to call it when the wizards opens in order to use them.

Can someone help me ? 

Thanks.

Аватар
Отменить
Лучший ответ

Hi,

Using the default get method of model defined for the wizard, you can achieve this.

Thanks

Аватар
Отменить
Автор

Thanks for your reply.
So I just need to create a function named "get"in my wizard's model to achieve what I want ?
Can I have more details please ?
Thanks.

the method is default_get
please refer this video https://www.youtube.com/watch?v=BSL4iOHZ-Rc for How To Load Default Values For One2many Fields in Odoo

Автор

I'll get a look at it.
Thanks.

Автор

Ok so I try some things but nothing seams to do what I really want.

The function in my wizard's model is this one :
@api.model
def default_get(self):
selected_ids = self.env.context.get('active_ids', [])
selected_records =
self.env['account.move'].browse(selected_ids)
return selected_records

I get ids of the records that I selected when I open my wizard from the action menu and I return the records.

But when I try to display the in my wizard with <field name="..."> I get an error Field doesn't exist in model.

Автор Лучший ответ

Hi, several days later, I steal didn't manage to fix my issue.

Can someone help me ?

Thanks.

Аватар
Отменить
Лучший ответ

Hi,

Try write your function for bringing the wizard like below.

def wizard_function(self):
return {
'name': _('Items'),
'view_mode': 'tree',
'res_model': 'test.test', # your custom model
'type': 'ir.actions.act_window',
'domain': [('id', 'in', [list of ids])], # instead of [list of ids] you can use your fetched ids
'target': 'new'
}

Hope it helps

Аватар
Отменить
Автор

Thanks for your reply.
In order to open the wizard from the action menu, I used the model "ir.actions.act_window".
If I understand good, it doesn't call any function to open the wizard.
So I don't know how the wizard can call the function you show me...
Can I have more details please ?
Thanks.

Related Posts Ответы Просмотры Активность
1
июн. 25
1535
3
июл. 25
3211
1
мая 25
1360
1
мая 25
1608
4
мая 25
2762