Skip to Content
Menu
This question has been flagged
3 Replies
19675 Views

Hello, I created a wizard and have a many2one field that is related to the sale.order. I would like to pass in the sale.order active id to the many2one field that is on the wizard.

In the Sale Order form I have a button with the type set to action, and I am using the context to pass in the active id of the sale.order to the sale_order_id field

<button name="%(action_view_wiz_pay_auth_net)d" type="action" string="Pay with Authorize.net" context="{'sale_order_id': active_id}" class="oe_highlight" />

Here is my xml wizard action:

<record id="action_view_wiz_pay_auth_net" model="ir.actions.act_window">
        <field name="name">Credit Card Info</field>
        <field name="res_model">sale.auth.net.payment</field>
        <field name="view_type">form</field>
        <field name="view_mode">form</field>
        <field name="view_id" ref="view_wiz_auth_net_payment_form"/>
        <field name="target">new</field>
    </record>

here is the wizard form:

<record id="view_wiz_auth_net_payment_form" model="ir.ui.view">
        <field name="name">wiz.auth.net.payment Form View</field>
        <field name="model">sale.auth.net.payment</field>
        <field name="arch" type="xml">
            <form string="Authorize.net" version="7.0">
                <group>
                    <field name="cc_num" style="width:300px;"/>
                    <field name="exp_month" style="width:60px;"/>
                    <field name="exp_year" style="width:60px;"/>
                    <field name="ccv_num" style="width:60px;"/>
                    <field name="amount" />
                    <field name="has_dif_billing" />
                    <field name="sale_order_id" style="width:300px;"/>
                </group>
                <group attrs="{'invisible': [('has_dif_billing','=', False)]}">
                    <field name="partner_id" style="width:300px;"/>
                    <field name="billing_add" style="width:300px;"/>
                    <field name="billing_city" style="width:100px;"/>
                    <field name="billing_state" style="width:60px;"/>
                    <field name="billing_zip" style="width:60px;"/>
                </group>

                <footer>
                    <button name="make_payment" string="Pay Now" type="object" 
                        context="{'amount': amount, 
                                  'cc_num': cc_num,
                                  'exp_month': exp_month,
                                  'exp_year': exp_year,
                                  'ccv_num': ccv_num,
                                  'billing_add': billing_add,
                                  'billing_city': billing_city,
                                  'billing_state': billing_state,
                                  'billing_zip': billing_zip,
                                  'has_dif_billing': has_dif_billing,
                                  }" class="oe_highlight"/> or
                    <button string="Cancel" special="cancel" class="oe_link"/>
                </footer>
            </form>
        </field>
    </record>

I have another many2one field partner_id that is related to res.partners on my wizard which actually loads the partner that is related to the sale.order. Im not sure why the partner_id is loaded, but not the order_id in the wizard. Can anyone explain why? Thank you

Avatar
Discard
Best Answer

Hi;

Maybe this Question + Answer can help you

Avatar
Discard
Author

Yes thank you. I had to set the _defaults = { 'sale_order_id': lambda self, cr, uid, context: context.get('sale_order_id', False), }

Best Answer

check the first step of my answer at

https://www.odoo.com/forum/help-1/question/add-product-to-shopping-cart-from-external-site-114337

Avatar
Discard
Related Posts Replies Views Activity
5
Jul 23
15620
1
Mar 15
6408
1
Dec 22
1810
3
Nov 23
28102
4
Dec 18
3584