Skip to Content
Menu
This question has been flagged
1 Reply
2934 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
Related Posts Replies Views Activity
2
Nov 24
262
1
Oct 24
328
4
Oct 24
323
2
Oct 24
360
2
Dec 24
661