This question has been flagged
3 Replies
8689 Views

what i want to do is add a column to product.product table so i create a new object inheriting from product.product , and i also create a new view inheriting from product.product_normal_form_view but the field i have added to product.product not showing in the form view. i can see the itemid field in product_product table. it is so strange , anyone can help me?? many thanks.

here is the code my_product.py

# -*- coding: utf-8 -*-
from openerp.osv import fields, osv
from datetime import datetime 

class ebayerp_product(osv.osv):
    _name = 'product.product'
    _inherit = "product.product"
    _columns = {
        'itemid' : fields.char('eBay ItemID', size=32, readonly=True, invisible=False),
        }
ebayerp_product()

my_product_view.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="product_normal_form_view" model="ir.ui.view">
            <field name="name">product.normal.form.inherit1</field>
            <field name="model">product.product</field>
            <field name="type">form</field>
            <field name="priority" eval="1"/>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                 <sheet position="inside">
                    <label for="ebayitemid"/>
                    <div name="ean">
                        <field name="itemid"/>
                    </div>
                 </sheet>
            </field>
       </record>
    </data>
</openerp>

product_normal_form_view form view (not all code, because not neccessary)

<record id="product_normal_form_view" model="ir.ui.view">
            <field name="name">product.normal.form</field>
            <field name="model">product.product</field>
            <field eval="7" name="priority"/>
            <field name="arch" type="xml">
                <form string="Product" version="7.0">
                    <sheet>
                        <field name="image_medium" widget="image" class="oe_avatar oe_left"/>
                        <div class="oe_title">
                            <div class="oe_edit_only">
                                <label for="name" string="Product Name"/>
                            </div>
                            <h1>
                                <field name="name"/>
                            </h1>
                            <label for="categ_id" class="oe_edit_only"/>
                            <h2><field name="categ_id"/></h2>
                            <div name="options" groups="base.group_user">
                                <field name="sale_ok"/>
                                <label for="sale_ok"/>
                            </div>
                        </div>
                        <div class="oe_right oe_button_box" name="buttons">
                        </div>
Avatar
Discard

Hi , can you put all your codes so I can test and correct the error so the problem will solved quickly

Author

ok , i will post the code soon.

Author

the problem has been resolved . delete 'readonly=True' will be ok

Ok @figol New .... if there is no problem can you send me all codes

Best Answer

Hi you define wrong field name in your view

 <field name="ebayitemid"/>

replace it with

 <field name="itemid"/>

and plz be remember you should use same whither same class name (product_product) or place a new field in class label _table=product_product other wise this field will not be added in the product table

Thanks Sandeep

Avatar
Discard
Author

I have changed ,but there is no luck

Best Answer

Hi,

replace <field name="ebayitemid"/> to <field name="itemid"/> in form and view.

Avatar
Discard
Author

i have changed it , but there is no luck

Best Answer

Hello,

your field is wrong

<field name="ebayitemid"/>

to replace it <field name="itemid"/>

Avatar
Discard