콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
8360 화면

Greetings,

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 " .

the problem is i can't see my field .

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.product.form</field>
        <field name="model">product.product</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>

 

아바타
취소

if i inhirit product.template , i will get error : field 'product_rolls' does not exist . by the way the field is created but its hidden ,because once i open manage views , i can see my field created under 'ean13'

@moayad I am asking to inherit only the view.. Inherit the view - "product_normal_form_view".. instead of 'product_template_only_form_view'

작성자

i tried , there is no erros but still the field is hidden :(

@moayad just for testing try another field say "default_code" instead of ean13, because ean13 is there in the template view as well as product view, so may be causing the problem

작성자

i tried but still :( , many thanks to you

@moayad I will try and let you know

베스트 답변

Slam Alykom ;)

As Emipro Technologies pointed, you have to change the view id, try this:

<record id="product_rolls_product" model="ir.ui.view">
    <field name="name">product.product.rolls.form</field>
    <field name="model">product.product</field>
    <field name="inherit_id" ref="product.product_normal_form_view"/>
    <field name="arch" type="xml">
        <data>
            <xpath expr="//field[@name='list_price']" position="after">
                <field name="product_rolls" />
            </xpath>
        </data>
    </field>
</record>

Also why would you mention "product_rolls_code_view.xml" twice in your manifest file? including it in 'update_xml' is enough.

Good Luck.

아바타
취소
작성자

Wa Alekom Salam ^^ Element '<xpath expr="//field[@name='list_price']">' cannot be located in parent view why you just used : product.product.rolls.form once we are using the product.form it self

베스트 답변

Hello Moayad,

Check the model name in the view, it is written as 'product.ptoduct'

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

Edit:

I think change your model to product.template instead of product.product, because ean13 is actually field set in the 'product.template' module and the view that you have inherited is of model 'product.template'

If you want to set your field try to inherit "product_normal_form_view" .

아바타
취소
작성자

Thank you , but its not the problem ^^ it's copied by mistake

@moayad Try to inherit the "product_normal_form_view" because the view you inherited is of model 'product.template' and you have specified 'product.product'

작성자

Error : ParseError: "External ID not found in the system: product.product_only_form_view" while parsing

@moayad the view id is 'product_normal_form_view' not 'product_only_form_view'