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

Hi,

in a customer module, I add a new field in stock.picking class to calculate total weight with the _inherit keyword. So, it works good for delivery orders (class stock.picking.out inherit stock.picking) and also for incoming shipments (class stock.picking.in inherit stock.picking).

Then, I want to display this field on delivery orders view (stock.view_picking_out_form) and on incoming shipment view (stock.view_picking_in_form). This 2 views are defined in stock module with inherit from view_picking_form.

If I inherit stock.view_picking_form in my customer xml like that :

        <record model="ir.ui.view" id="view_picking_form" >
        <field name="name">stock.picking.form</field>
        <field name="model">stock.picking</field>
        <field name="priority" eval="10"/>
        <field name="inherit_id" ref="stock.view_picking_form" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='stock_journal_id']" position="after" version="7.0">
                <field name="picking_weight" />
            </xpath>
        </field>
    </record>

the field does not appear on the screen of delivery orders or incoming shipment...

If I inherit stock.view_picking_out_form like that:

        <record model="ir.ui.view" id="view_picking_out_form_1" >
        <field name="name">stock.picking.out.form1</field>
        <field name="model">stock.picking.out</field>
        <field name="inherit_id" ref="stock.view_picking_out_form" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='stock_journal_id']" position="after" version="7.0">
                <field name="picking_weight" />
            </xpath>
        </field>
    </record>

after updating my module, I can't load the view when clicking on delivery orders...

my eclipse log write :

2013-05-02 13:39:52,480 5920 ERROR semens openerp.osv.osv: Uncaught exception

Traceback (most recent call last): File "C:\Users\IOTA\workspace\OpenERP7def\openerp\osv\osv.py", line 131, in wrapper return f(self, dbname, args, *kwargs) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\osv\osv.py", line 197, in execute res = self.execute_cr(cr, uid, obj, method, args, *kw) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\osv\osv.py", line 185, in execute_cr return getattr(object, method)(cr, uid, args, *kw) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\addons\stock\stock.py", line 728, in fields_view_get return super(stock_picking, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\osv\orm.py", line 2260, in fields_view_get xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=ctx) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\osv\orm.py", line 1932, in __view_look_dom_arch model = res[0][1] IndexError: list index out of range 2013-05-02 13:39:52,494 5920 ERROR semens openerp.netsvc: list index out of range Traceback (most recent call last): File "C:\Users\IOTA\workspace\OpenERP7def\openerp\netsvc.py", line 293, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\service\web_services.py", line 626, in dispatch res = fn(db, uid, params) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\osv\osv.py", line 188, in execute_kw return self.execute(db, uid, obj, method, *args, *kw or {}) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\osv\osv.py", line 131, in wrapper return f(self, dbname, args, *kwargs) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\osv\osv.py", line 197, in execute res = self.execute_cr(cr, uid, obj, method, args, *kw) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\osv\osv.py", line 185, in execute_cr return getattr(object, method)(cr, uid, args, *kw) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\addons\stock\stock.py", line 728, in fields_view_get return super(stock_picking, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\osv\orm.py", line 2260, in fields_view_get xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=ctx) File "C:\Users\IOTA\workspace\OpenERP7def\openerp\osv\orm.py", line 1932, in __view_look_dom_arch model = res[0][1] IndexError: list index out of range

c:\users\iota\workspace\openerp7def\openerp\osv\orm.py(1932)__view_look_dom_arch() -> model = res[0][1] (Pdb)

It seems that picking_weight field doesn't exist in stock.picking.out class...

How can I do ?

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

Maybe put it in stock.picking and stock.picking.out and in.

Tác giả

how works heritage if we must redefine the field in different heritages

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

The error message talks about an 'IndexError: list index out of range' in the method/assignment: '__view_look_dom_arch model = res[0][1]'

So somehow res[0][1] is referring to a non-existing thing.

  • If this value is in an existing module, you might not have given some information needed for the method to finish correctly
  • If this value is in your own module, something from the super might not have been send in order to finish correctly.
Ảnh đại diện
Huỷ bỏ