Skip to Content
Menu
This question has been flagged
1 Atsakyti
236 Rodiniai

Hi guys

Please i want to add some fields in existing class in odoo which is product.template.

Here is my code:


class product_template(models.Model):

#Inhertis the model product.template

_inherit = 'product.template'

_name = 'product.template'

_columns = { 

'CostPrice' : fields.float('Buy price'),

'ShippingCost' : fields.float('Shipping Cost'),

'FieldAfterGroup' : fields.char(string='Field After Group'),

'FieldNewPage' : fields.char(string='Field New Page'),

}

--------------------------------------


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

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

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

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

<xpath expr="//page[@string='Information']" position="after">

<page name="Sample" string="Custom page">

<group>

<field name="FieldNewPage"/>

</group>

</page>

</xpath>

<xpath expr="//page[@string='Information']/group" position="after">

<group>

<field name="FieldAfterGroup"/>

</group>

</xpath>

</record>

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

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

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

<field name="type">tree</field>

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

<tree string="Services" >

<field name="FieldNewPage"/>

<field name="FieldAfterGroup"/>

</tree>

</field>

</record>

--------------------- I have this error 


2015-06-15 09:12:05,111 5222 CRITICAL see-teck openerp.modules.module: 'module' object has no attribute 'integer'

Please help please


Portretas
Atmesti
Best Answer


hi try this

class product_template(models.Model):

#Inhertis the model product.template

_inherit = 'product.template'

_name = 'product.template' //its not necessary it creates another table of that name in db

_columns = {

'CostPrice' : fields.float('Buy price'),

'ShippingCost' : fields.float('Shipping Cost'),

'FieldAfterGroup' : fields.char(string='Field After Group'),

'FieldNewPage' : fields.char(string='Field New Page'),

}


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

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

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

<field name="type">form</field>

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

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

 

<xpath expr="//page[@string='Information']" position="after"> 

<page string="Custom page">

<group colspan="4">

//put your all field here example:<field name="CostPrice"/>

</group>

</page>

</xpath>

</field>

</record>


<!--Main Menu-->

<menuitem name="Namel" id="product.root menu name" sequence="60"/>

ex: <menuitem name="Academic Details" id="menu_academic_models_root" parent="base.academic_models_root"  sequence="1"/>

thank you


Portretas
Atmesti
Autorius

Thanks a lot for your answer sir but i want to know what am i going to put in the menuitem please

check edited answer

Related Posts Replies Rodiniai Veikla
2
rugp. 25
2808
1
liep. 25
1134
1
rugp. 25
1152
0
geg. 25
1545
2
bal. 25
3750