Python 使用按钮从其他字段更新字段
当我用相同形式的field2 from按钮的值更新field1时,我遇到了一个问题Python 使用按钮从其他字段更新字段,python,openerp,odoo,openerp-7,Python,Openerp,Odoo,Openerp 7,当我用相同形式的field2 from按钮的值更新field1时,我遇到了一个问题 <field name="field1" /> <field name="field2" /> <button name="button1" type="object" /> 首先,您需要浏览该记录,然后将其值分配给字段1 试试这个 def button1(self, cr, uid, ids, context=None): field2 = self.brow
<field name="field1" />
<field name="field2" />
<button name="button1" type="object" />
首先,您需要浏览该记录,然后将其值分配给字段1 试试这个
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)
您能否发布
button1
方法的完整代码,以便我们能更好地帮助您。field2=self.browse(cr,uid,id,context=context)。field2因为它的一个对象no?self.browse为您提供了一组值,因为表包含许多列。browse(cr,uid,ids[0],context=context)为您提供了一个这样的函数,我们从中获取字段2。
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)