Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
3 Vastaukset
7450 Näkymät

hi all,

nice to see you.

now, my problem ,if someone have any idea and can help me.

I try to add a field ,type of field : fields.funtion ( who concatenate two other field.char )

thanks

Avatar
Hylkää
Paras vastaus

This is the code

_function_example(self, cr, uid, ids, name, arg, context=None):
    res = {}
    records = self.browse(cr, uid, ids)
    for record in records:
        res[record.id] = '%s%s' % (record.field_char_1, record.field_char_2)
    return res

_columns = {
    'your_function_field' : fields.function(_function_example, type='char', size=64, method=True, store=False),
}
Avatar
Hylkää
Tekijä

thanks a lot

Tekijä

i have this error

I've update the code. Try now with the new code.

Tekijä

thanks just i should add type="char"

Tekijä Paras vastaus

i have this error :(

Uncaught Error: [_.sprintf] expecting number but found string

Just add : type="char"

Avatar
Hylkää
Paras vastaus
'your_function_field' : fields.function(_function_example, type='char', size=64, method=True, store=False),

Replace by:

'your_function_field' : fields.function(_function_example, string='your_string, type='char', size=64, method=True, store=False),
Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
marrask. 20
6202
1
kesäk. 15
5080
1
toukok. 21
10653
1
heinäk. 16
7426
1
heinäk. 15
8584