Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Odoo 12中将值从字段传递给向导?_Odoo_Wizard - Fatal编程技术网

如何在Odoo 12中将值从字段传递给向导?

如何在Odoo 12中将值从字段传递给向导?,odoo,wizard,Odoo,Wizard,我在下面有这个字段 name = fields.Text("Input text here") 我想在单击按钮时将其值传递给向导。代码如下: @api.multi def open_wizard(self): return { 'view_type': 'form', 'view_mode': 'form', 'res_model': 'customer.wizard', 'target': 'new', 'type': 'ir.actions.act_window', '

我在下面有这个字段

name = fields.Text("Input text here")
我想在单击按钮时将其值传递给向导。代码如下:

@api.multi
def open_wizard(self):
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'customer.wizard',
'target': 'new',
'type': 'ir.actions.act_window',
'context': {'current_id': self.id}
 }
这是我的XML。但它仍然没有像我预期的那样起作用

对于按钮:

<button name="open_wizard" string="Submit" type="object" class="oe_highlight" context="
{'name': name}"/>

对于向导本身。我希望值位于“Resi”字段上:

<record id="view_test_report_wizard" model="ir.ui.view">
 <field name="name">Customer Wizard</field>
 <field name="model">customer.wizard</field>
 <field name="arch" type="xml">
 <form string="Choose The Details">
 <group>
 <tree>
 <group>
 <field string="Resi" name="name" context="{'name' : name}"/>
 <field name="tanggal"/>
 <field name="kotaasal"/>
 <field name="kotatujuan"/>
 <field name="id_customer"/>
 </group>
 </tree>
 </group>
 <footer>
 <button string="Back" class="oe_link" special="cancel"/>
 </footer>
</form>
</field>
</record>

客户向导
客户向导

你有什么解决办法吗?谢谢

只需更新方法
打开向导
上的上下文,如下所示:

'context': {'default_name': self.name}
这将(实际上)创建值为
self.name

的向导。您可以这样尝试

wiz = self.env['customer.wizard'].create({'name': self.name})

@api.multi
def open_wizard(self):
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'customer.wizard',
'res_id': wiz.id,
'target': 'new',
'type': 'ir.actions.act_window',
}
也可以在上下文中传递值

'context': {
   'default_name': self.name,'default_tanggal': self.tanggal
   'default_kotaasal': self.kotaasal,'default_kotatujuan': self.kotatujuan
   ,'default_id_customer': self.id_customer.id
}