即使按钮出现也不会将我重定向到任何地方。我希望第一个按钮重定向到sale.order表单视图(ID 605),其中包含折扣和第二个按钮到sale2.order表单视图(id 575),其中不包含对items的任何折扣。我应该在python代码中做什么或只修改我的xml代码?
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view3_order_form" model="ir.ui.view">
<field name="name">sale3.order.form</field>
<field name="model">sale.order</field>
<field name="arch" type="xml">
<form string="Sales Order">
<h1>Selection Panel</h1>
<button name="redirection1" string="Discount" type="action" class="oe_highlight"/>
<button name="redirection2" string="No Discount" type="action" class="oe_highlight"/>
</form>
</field>
</record>
<record id="action3_orders" model="ir.actions.act_window">
<field name="name">Sales3 Orders</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
<record id="redirection1" model="ir.actions.act_window">
<field name="name">Redirection_to_discount</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="res_id">605</field>
<field name="target">current</field>
</record>
<record id="redirection2" model="ir.actions.act_window">
<field name="name">Redirection_to_no_discount</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="res_id">575</field>
<field name="target">current</field>
</record>
</data>
</openerp>
答案 0 :(得分:3)
name
for action按钮实际上应该是操作的数字ID,而不是操作的名称。当然,实际上使用这个名称要好得多。为此,请使用printf语法 - %(action_name)d
而不是action_name
。这样,名称稍后将替换为数字ID:
<button name="%(redirection1)d" string="Discount" type="action" class="oe_highlight"/>
<button name="%(redirection2)d" string="No Discount" type="action" class="oe_highlight"/>