@api.model
def create(self, values):
res_id = super(NameModel, self).create(values)
return res_id
如何重写
vals 返回包括所有字段的字典,你能像这样赋值一个新值到 vals['']
def create (cr, uid, vals, context=None)
#vals or values returns dictionary containing all the fields, so you can use it like this to assign new values
vals['field_name_1'] = new_value_1
vals['field_name_2'] = new_value_2
#or assign to a variable
var_1 = vals['field_name_1']
var_2 = vals['field_name_2']
return super(class_name, self).create(cr, uid, vals, context=context)
本文介绍如何在Python中重写创建方法,通过修改vals或values字典来设置新字段值。示例展示了如何使用这些字典参数更新字段,并提供了一个具体的实现方法。

1万+

被折叠的 条评论
为什么被折叠?



