Hello,
I want to have a tab to fill the default BOM.
How can I have, when I add a line to have "Parent Product Template" automatic filled with my product?
Denis
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello,
I want to have a tab to fill the default BOM.
How can I have, when I add a line to have "Parent Product Template" automatic filled with my product?
Denis
Hi,
In your One2many field, add attribute context like this:
name="O2M" context={'default_X': active_id}
X is your Parent product_template technical name.
hope this helps.
Thx Ibrahim for you reply, but that doesn't work (I try with Studio):
I don't see where the context i mentioned was added if your screens.. and i don't know how to add context with studio..
But it's working once it's done.
You can do it via Developer Mode though.
For v15.0+:
In this case the product_template field seems to be the foreign key - if submitted as default-value passed with your context it will be written when the new record is saved. (see https://github.com/odoo/odoo/issues/82366).
So in this case you should think about a dedicated form to enter new records instead of list-editing. Just define your view like e.g.:
Or it may be easier in the Studio to use "edit form".
Thx Dental,
I think that there is missing words in your reply...
Hi Denis,
what part is not clear to you?
Basically for 15.0 or later it is impossible to pre-set a key-value (reference to parental record). The reference will be automatically set when saving the new child-record when not changed in the edit-form.
For our modules this made it necessary to duplicate each form (we do not edit/create inline) and remove the field "parent_id" so it could not be changed by accident.
Many greetings
Olaf
Ok thanks Olaf,
Is it possible to make that with Studio?
Denis
I'm not familiar with the Studio so I can only guess based on your screenshot. Try the "edit form view" button.
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up