Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Update field with button

By
mehdi
on 5/8/15, 10:51 AM 341 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'),

}

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

Atchuthan - Technical Consultant, Sodexis Inc
on 5/12/15, 8:18 AM
0
mehdi
On 5/11/15, 3:58 AM

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)

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/8/15, 10:51 AM
Seen: 341 times
Last updated: 5/12/15, 8:18 AM