Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
4151 Lượt xem

Hi,

I am using odoo15 community edition, and I am trying to launch a wizard from purchase order based on changes on purchase order lines when I use the function below, it does return nothing:

_inherit = 'purchase.order.line'

@api.onchange('product_id')
def open_wizard(self):
if self.product_id.is_kits:

return {
'name': 'Add components',
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'add.components.wizard',
'target': 'new'
}

I would like to know if it is possible to do this without using a button

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello Kahina,

@api.onchange decorated methods are not supposed to return anything. They just edit a "in memory" version of the object you're creating or editing. Odoo does not expect that method to return anything and will not take actions depending on the result of the method.

Best way to achieve what you're doing is to put a 'components' field next to the 'product_id' field. and using onchange of 'product_id' you can update the 'components'.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Odoo current ORM doesn't allow opening wizard with on change method.  You can use a button and call the wizard.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 10 22
5210
0
thg 1 23
2034
0
thg 9 22
1909
0
thg 7 22
2206
0
thg 2 22
5160