ValueError: dictionary update sequence item # 0 has a length of 1; 2 required

I return 5for my computational field old_default_code, and I get the following error:

ValueError: dictionary update sequence item # 0 has a length of 1; 2 required

What am I doing wrong?

Python function code:

def _old_default_code(self, cr, uid, ids, name, arg, context=None):
        return '5'
_columns = {
            'old_default_code' : fields.function(_old_default_code, type='char', size=32, method=True, store=False, multi=False) }

XML code:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <!-- mrp_bom -->
        <record id="adamson_mrp_bom_form_view" model="ir.ui.view">
            <field name="name">adamson.mrp.bom.form.view</field>
            <field name="model">mrp.bom</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="mrp.mrp_bom_form_view" />
            <field name="arch" type="xml">

                <xpath expr="//notebook/page[@string='Components']/field/tree[@string='Components']/field[@name='sequence']" position="before" >
                                         <field name="old_default_code" />
                     <button class="oe_inline oe_stat_button" type="object" string="Go!" icon="gtk-go-forward" name="action_go" 
                     attrs="{'invisible':[('old_default_code','=', '5')]}"  />

                               </xpath>
+4
source share
1 answer

@Nebojsa

The field.function always expects the dictionary to be returned, and in your case you just return "Integer". The default behavior of the system is that it expects a dictionary, where the key is the "identifier" of the record and the value is the value that you want to return.

For instance:

"5" , - 2, {2: 5}

:

, , , /, , , , , , .

,

, .

+7

Source: https://habr.com/ru/post/1568816/


All Articles