Odoo Help

0

how to pass sale.order active id into wizard?

By
Eric
on 3/26/14, 8:51 PM 7,475 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

1
Med Said BARA
On 3/27/14, 2:40 PM

Hi;

Maybe this Question + Answer can help you

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

Eric
on 3/27/14, 3:11 PM
0
Pakiza Rana
On 11/3/17, 5:54 AM

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

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 3/26/14, 8:51 PM
Seen: 7475 times
Last updated: 11/3/17, 5:54 AM