This question has been flagged
2 Replies
1598 Views

hi guys 
I m working on mrp.repair and mrp.repair.line


I would like to filter the list of product_id available on mrp.repair.line depending of the choice of the product id on mrp.repair.


So i tried to use an @api.onchange('repair_id.product_id') on the mrp.repair.line

but it doesn't work . 


I can do a compute on mrp.repair.line.product_id like this product_id = fields.Many2one('product.product', 'Product', required=True, domain=_compute_nomenc_product_ids) but it's not enough.
i really need to recompute when product_id on mrp.repair change. This 2 models are on the same view.
Does anybody have the solution? :)


Thanks a lot 

Thomas        

Avatar
Discard
Author Best Answer

Thanks Paresh for your answer.
Infact it s a just filter a list of product depending of the choice of a field attached to another model (product_id on mrp.repair) and others parameters (filter the list if the category is accessorie or square part, stock available .... )  . 


Depending of the choice , a different request need to be executed (if the product_id on mrp.repair has bom_ids , i need to list only bods_ids products.

That s why i need to use a method . 
So I can t use domain=[()] on xml if think isn t it?

Also if the product_id on the mrp.repair change i need to refresh the list


I hope it s more clear for you . Don t hesitate if you have more questions :)

Cheers




Avatar
Discard

Hi Thomas:

It would help much if you provide a sample scenario and the expected outcome.

Cheers.

Best Answer

Hi Thomas:

Did you mean "recompute" or just "filter" the list of product ids that the user can select ?

If it is just to filter the list of products, you can use a domain="[(....)]" attribute of the field in the view definition.

Avatar
Discard