This question has been flagged

Hello !

 
Here is my structure : I have my main model that is linked to product.product thanks to a many2many field.

 

I can already link products to my main model from my model but now i would like to create this link starting from a list of selected products in a tree view (or one product from form view). This means i would like to call a ir_values structure linked to product model. When i click on this action it would show me list of all the records from my main model and i would select one to erase any products that is already link to it to replace by the previously selected ones.
 
I hope i'm clear enough on my needs.

 

I know the existence of workflows and wizard but i don't understand in which situation i should use one or the other.
I already have my button/smart button present on product's form and tree view, i just don't know what to put in the action function to display all records of the model to link with.

If you could enlighten me on these points i would be very thankful !
 

Avatar
Discard
Best Answer

In your action just make a domain to filter out with the related field. In the case of products you should have a relation with the product_id Many2one field, and in the domain just make condition satisfies with your current product Id.

eg:

'domain': [('product_id', '=', active_id)],
or you can use context as like for sales info on partner view.
<field name="context">{'search_default_partner_id': active_id, 'show_sale': True}</field>
for this you have to make a search view.



Avatar
Discard