Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
5 Replies
13142 Tampilan

Hi,

I'm trying to add another column on the Product Tree View by using a module.

However, I'm receiving this error message: except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')

This is what I got so far,

__openerp__.py => I already added 'product' on the 'depends' field.

mymodule.py =>

class custom_products(osv.osv):
    _name = "product.product"
    _inherit = "product.product"
    _columns = {
        'asupplier_code': fields.char('Supplier Code',size=32),
    }
    _defaults = {
        'asupplier_code': '-',
    }
custom_products();

mymodule_view.xml =>

<record model="ir.ui.view" id="attempt_2_form">
    <field name="name">product.product.tree</field>
    <field name="model">product.product</field>
    <field name="type">tree</field>
    <field name="inherit_id" ref="product.product_product_tree_view"/>
    <field name="arch" type="xml">
        <field name="default_code" position="after">
            <field name="assupplier_code"/>
        </field>
    </field>
</record>

From what I understand, (when trying to create a module that will edit an existing view)

<field name="name">product.product.tree</field> : I got the value from the View Name field

<field name="model">product.product</field> : I got it from the Object field

<field name="inherit_id" ref="product.product_product_tree_view"/> : The ref would be the name of the view that I wish to inherit right?

Is there something wrong with my understanding and code that results with a Invalid XML for View Architecture?

Thanks!

Avatar
Buang
Penulis

I finally found what's wrong. The field name has an extra 's'.

Penulis

still not fixed though.

Jawaban Terbai

In odoo 9 (in you have you odoo server in other directory, just change the path to you odoo directory installation)

Create a new custom module:

cd /odoo/odoo-server <--Here inside is the odoo.py script to create a new custom module.

sudo ./odoo.py scaffold myproductviewtreelist /odoo/custom/addons <--This is my directory for my custom modules, this code create a new custom module

cd /odoo/custom/addons/myproductviewtreelist

Edit  __openerp__.py and save this settings:

locate: 'depends': ['base'], and add 'sale' like this:

'depends': ['base','sale'],

Edit emplates.xml and save this settings:

add this code: <--In my case a just want add the default_code field but you can add any field from your product form.

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

<field name="name">my.view.products.tree.inherit</field>

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

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

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

<!-- Before the field 'name' i add the 'default_code' field, or any field from my product form-->

<field name="name" position="before">

<field name="default_code"/>

</field>

</field>

</record>

Go to top menu/apps on line then go to left menu update apps list, delete the filter in the search box app and put my and search, then install the module myproductviewtreelist

Avatar
Buang
Jawaban Terbai

In your __openerp__.py file you should add your custom view:

'data': [
'yourmodule_view.xml'
]

Regards.

Avatar
Buang
Jawaban Terbai

In your module you have declared new class custom_products...

and in view you are calling odl class product.product...

rename your module class to :

class product_product (osv.osv):
..... 

 

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
3
Mar 15
6143
1
Mar 22
3184
0
Agu 21
3266
1
Mei 16
3786
2
Mar 15
6791