我下面有这个字段
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>
你有什么解决办法吗?谢谢
最佳答案
你可以试试这个方法
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
}
关于odoo - 如何在 Odoo 12 中将值从字段传递给向导?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62529650/