I am trying to add a new column of product data (product.template model) to purchase.order.form view.
The column should contain a custom attribute like x_bla.
When using just the "usual way" by adding: <field name="x_bla"/> I am getting an error:
Field(s) `arch` failed against a constraint: Ungültige Ansichtendefinition
Error details:
The field `x_bla` doesn't exist.
Fehler Kontext:
Ansicht `purchase.order.form`
[view_id: 789, xml_id: purchase.purchase_order_form, model: purchase.order, parent_id: k. A.]
So I need to add a field into purchase.order model and connect it to my custom attribute... but how does that work?
Any hints in the right direction?
@Frederico. The attribute is from product.template model. I assume you added the attribute to purchase.order model? So my next question would be how to link an attribute from purchase.order to product.template...?
Then you create a field just using the Odoo GUI. I'm afraid, but you need a little bit of python to inherit the fields list, using fields.related on product.py and/ or on purchase.py. What kind of field is your "x_bla"? Is already populated or can be substitute with a field created on model .py? I'm not the best expert around here but tomorrow I'll test the code on my dev-server.
Unfortunately yes. I looked into the purchase.py and found the product_id field with related info to product.product and tried to do the same for my custom attribute but it didn't work. I also think that a custom module for adding an attribute and relations to the models there would be more promising... I'm looking forward to any help with this. Would be my first module to write "by myself"... so any help appreciated...
Thomas, if the field is already populated you can easily resolve with a simple export and a batch input. I'm not a big fan of creation of fields inside odoo, it's better to create a new module for inherit the models and views you need. If you don't know, you could create an empty module ready to be filled with your information with the command [code] python odoo.py scaffold addons [/code]. In that way you will have a correct layout. I'll have a look on server and then I'll update my post.
thank you akhil, I just tried to do so. check out here: https://github.com/thomasklosinsky/product_kunstler But still having errors. I think the related field in .py is not correctly set and the view in .xml also... Help appreciated!