This question has been flagged
1 Reply
2768 Views

I have a problem when i update field1 with the vale of field2 from button in the same form


<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'),

}

Avatar
Discard

field2 is an undefined variable(in python), so you need to assign the value to it by browsing the record

Author Best Answer

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)

Avatar
Discard