跳至內容
選單
此問題已被標幟
3 回覆
7453 瀏覽次數

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

頭像
捨棄
最佳答案

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),
}
頭像
捨棄
作者

thanks a lot

作者

i have this error

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

作者

thanks just i should add type="char"

作者 最佳答案

i have this error :(

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

Just add : type="char"

頭像
捨棄
最佳答案
'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),
頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
11月 20
6202
1
6月 15
5087
1
5月 21
10658
1
7月 16
7427
1
7月 15
8584