Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Add new field to the product form:

By
Nigel Butler
on 2/22/16, 10:11 AM 279 views

I have created a new module which adds a field to the product form called 'Drawing Number'

I have created the field 'drawing' in the models file and inherited the data from product.template.


class HIP_product_template(models.Model):

_name = 'product.template'

_inherit = 'product.template'

drawing = fields.Char('Drawing Number', required = False)


I have then edited the view in the xml file as follows:


<record model="ir.ui.view" id="HIP_product_template">

<field name="inherit_id" ref="product.product_template_only_form_view"/>

<field name="model">product.template</field>

<field name="arch" type="xml">

<field name="list_price" position="after">

<field name="drawing" placeholder="Drawing no./issue" required="False"/>

</field>

</field>

</record>


This works great, and I can add this new field to all my products. I can also display the field in quotes etc. 

However, if you click Quotation, then click Add an Item, and 'Create and Edit' this brings up the new product form, but it does not contain my adjustments. I cannot find where this alternative form view is coming from as the pop up has no debug options to edit or view the form. 


I have searched all XML documents on addons for <field name="default_code" which also appears on this for, and also <field name="barcode" but I cant locate this strange pop up products form. 

Did you check the 'product_template_form_view' in product module.

Gopakumar N G
on 2/25/16, 1:08 AM

Thanks Gopakumar N G. It was actually product.product_normal_form_view, and the model had to be product.product, not product.template. The following code seems to have worked: product.product Part Number Part No. Barcode for D-Note

Nigel Butler
on 2/25/16, 8:41 AM
product.product Part Number Part No. Barcode for D-Note
Nigel Butler
on 2/25/16, 8:42 AM

I cant paste the code in here, but its same as in the original question but with name="inherit_id" ref="product.product_normal_form_view" and name="model">product.product

Nigel Butler
on 2/25/16, 8:43 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/22/16, 10:11 AM
Seen: 279 times
Last updated: 2/22/16, 10:17 AM