Am trying to create a module that add some fields to product module .
i did the structure very well which i create " init .py , openerp .py , product_rolls_code.py , product_rolls_code_view.xml " .
After i run the Odoo , i get error : Field product_rolls
does not exist ,if i go to database structure > fields , i can find product_rolls field is created .
Check out my code bellow
__ init__.py
import product_rolls_code
__ openerp__.py
{
'name': "Product Rolls",
'version': "1.0",
'category': "others",
'complexity': "normal",
'author': "Moayad Rayyan",
'depends': [
"product" #name of module which is needed to be installed
],
'init_xml': [
#place here the XML with initial data
],
'update_xml': [
"product_rolls_code_view.xml",
],
'data': ['product_rolls_code_view.xml'],
'demo_xml': [],
'test': [],
'installable': True,
'auto_install': False,
'application': False,
'images': [],
'js': [], }
product_rolls_code.py
from openerp.osv import fields, osv
class product_rolls_code(osv.osv):
_inherit = "product.product"
_columns = {
'product_rolls': fields.char('Product Rolls', size=11),
}
product_rolls_code()
product_rolls_code_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_rolls_product" model="ir.ui.view">
<field name="name">product.template.product.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<field name="ean13" position="after">
<field name="product_rolls" />
</field>
</field>
</record>
</data>
</openerp>
You are adding the field in the object product.product, while ure using the product.template in the model view. You should changue the inherited object in the py(producr.product) or changue the one in the view(product.template) so they are both the same.
Tip: use only data to add the view in the openerp file, delete the update.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.