如何在odoo中从一个表单视图重定向到另一个表单视图?

时间:2022-05-05 20:23:51

Even though button appears it does not redirect me anywhere.I want first button to redirect to sale.order form view (id 605) which contains discount and second button to sale2.order form view (id 575) which does not contain any discount to items.Should i do anything in python code or just modify my xml code?

即使按钮出现它也不会将我重定向到任何地方。我想要第一个按钮重定向到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>

1 个解决方案

#1


3  

The name for action button should actually be action's numeric id, and not action's name. Of course in reality it would be much better to use the name. To do that use the printf syntax - %(action_name)d instead of action_name. This way the name will later be replaced with a numeric id:

动作名称按钮实际上应该是动作的数字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"/>

#1


3  

The name for action button should actually be action's numeric id, and not action's name. Of course in reality it would be much better to use the name. To do that use the printf syntax - %(action_name)d instead of action_name. This way the name will later be replaced with a numeric id:

动作名称按钮实际上应该是动作的数字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"/>