Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5737 Lượt xem

hi,

i try to add a custom text field "detail" to the product lines in a sales order. i created a new module and added the following code:

__init__.py

import sales_order_detail_field

sales_order_detail_field.py

from openerp.osv import fields, osv

class sales_order_detail_field(osv.Model):
        _name = 'sale.order'
        _inherit = 'sale.order.line'
        _columns = {
                'detail': fields.text('Detail'),
        }

sales_order_detail_field(

sales_order_detail_field.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
   <record model="ir.ui.view" id="detail_field_in_view">
    <field name="name">New Sale Order field detail</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
    <xpath expr="//field[@name='order_line']/form/notebook/page[@string='Order Line']//field[@name='product_uom_qty' ]" position="before">
        <field name="detail" />
    </xpath>
    </field>
</record>
    </data>
</openerp>

but when i reload my openerp window, i jus tget the following error

raise except_orm('ValidateError', '\n'.join(error_msgs))
except_orm: ('ValidateError', u'Fehler w\xe4hrend der Pr\xfcfung des Feldes field(s) arch: Invalid XML for View Architecture!')

any advice what's wrong here? maybe the xml?

Ảnh đại diện
Huỷ bỏ

How you made it work?

Câu trả lời hay nhất

You should remove the _name = 'sale.order' line from your .py file. Defining the _name is not actually even necessary if you want to simply add new fields to an existing model. The current value is also referring to a different model (sale order instead of sale order line).

You can read more about the different inheritance types here: https://doc.openerp.com/trunk/server/03_module_dev_02/#object-inheritance-inherit

If there's still issues, double-check the xpath expression.

Ảnh đại diện
Huỷ bỏ
Tác giả

i removed the _name property, but it still doesn't work. changing the xpath to <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/tree[@string='Sales Order Lines']/field[@name='tax_id']" position="after"> hasn o effect also…

Bài viết liên quan Trả lời Lượt xem Hoạt động
10
thg 1 24
16998
1
thg 3 15
3420
1
thg 3 15
3617
2
thg 8 24
2288
0
thg 1 24
1135