当我使用相同格式的按钮更新field1的值为field2时,我遇到了问题。
<field name="field1" />
<field name="field2" />
<button name="button1" type="object" />
这是方法代码:
def button1(self, cr, uid, ids, context=None):
...
return self.write(cr, uid, ids, {'field1': field2}, context=context)
_columns = {
'field1': fields.integer('Field1'),
'field2': fields.integer('Field2'),
}
答案 0 :(得分:0)
首先,您需要浏览该记录,然后将其值分配给field1。
试试这个
def button1(self, cr, uid, ids, context=None):
field2 = self.browse(cr, uid, ids[0], context=context).field2
return self.write(cr, uid, ids, {'field1': field2}, context=context)