Skip to Content
Menu
This question has been flagged

Hello dear

 I am trying to inherit filed under new tab in sale module's product section. I try and code is working fine but it's just showing tab not showing filed under that tab. Let me share my code with you. Please help me to find where i am missing 

Here is my module code

class ProductTemplate (models.Model): 
_inherit = 'product.template'
field_name1 = fields.Char (string = "label for the field")

Here is my view code is

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

<field name = "name"> product.tamplate.tab </field>
<field name = "model"> product.template </field>
< field name = "inherit_id" ref = "product.product_template_only_form_view" />
<field name = "arch" type = "xml">
<notebook>
<page string = "Barcode">
<filed name = "field_name1" />
</ page>
</notebook>
</field>
</record>
There is showing new tab Barcode which i want to develop but filed is not showing there. 
Why it's not showing and what i did wrong please help me to find it.
Avatar
Discard
Best Answer

        <notebook> 
<page string = "Barcode">
<filed name = "field_name1" />
</ page>
</notebook> 
of course you cant show it, your tag is <filed when it should <field

Avatar
Discard
Author

I did stupid mistake. but after correcting it. it's not working fine

ofc it wont work, you should use <xpath> tag for insert your new tab

in your case you should do this

and stop using space on your xml it's not python, please follow the standard

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

<field name="name">product.template.form.parent.inherit</field>

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

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

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

<xpath expr="//notebook" position="inside">

<page string="Barcode">

<field name="field_name1"/>

</page>

</xpath>

</field>

</record>

Author

Let me try it.

Author

Yes it's working now Thanks Man you did alot help of me. But i got other small issue. Now field has start to appear but. taxt along with field which is called label it's not appeared. here is my module field code

class ProductTemplate(models.Model):

_inherit = 'product.template'

field_name1 = fields.Char(string="Barcode")

I want it must show output Barcode along with checkbox Please help me in it Thanks

then add this on your xml

<page string="Barcode">

<label for="field_name1"/>

<field name="field_name1"/>

</page>

Author

Let me try it.

Author

Yes it's Working 100% Alot of Thanks. I want to show other checkbox instead of field how can i do .?

you need to create boolean field for that and do the same with your field_name1

in python:

field_checkbox = fields.Boolean()

on your xml then define it again

<field name="field_checkbox "/>

<label for="field_checkbox "/>

Author

yes i did but it's not working

Author

it's showing me this error raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e)))

odoo.tools.convert.ParseError: "Error while validating constraint

Field `field_checkbox` does not exist

Here is my python code

class ProductTemplate(models.Model):

_inherit = 'product.template'

field_checkbox = fields.Boolean()

Here is the xml

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

<field name="name">product.template.form.parent.inherit</field>

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

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

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

<xpath expr="//notebook" position="inside">

<page string="Product Barcode Generator">

<field name="field_checkbox" />

<label for="field_checkbox"/>

</page>

</xpath>

</field>

</record>

dude, are you really new in odoo? it's not like that, i mean you should add that checkbox in the same xml as your field_name1

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

<field name="name">product.template.form.parent.inherit</field>

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

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

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

<xpath expr="//notebook" position="inside">

<page string="Barcode">

<field name="field_name1"/>

<label for="field_name1"/>

<field name="field_checkbox" />

<label for="field_checkbox"/>

</page>

</xpath>

</field>

</record>

Author

I did same as you mentioned but still not working.

Related Posts Replies Views Activity
1
Nov 19
8317
4
Mar 19
3099
0
Apr 24
328
2
Sep 22
3057
1
Dec 19
4651