2
votes

so I Have several fields in my Wizard model that the default value is the same from the form but we can change it. I try to send my form field value using context but it has an error like this

odoo.tools.convert.ParseError: ": "name 'arrival_date' is not defined"

while evaluating. The name of the field already right because when I use context in my line or one2many field It works just fine.

And Second when I create the record its not referencing my form record. Do I need to change the default write method?

<record model="ir.ui.view" id="kre_product_reservation_wizard_form_view">
        <field name="name">kre.product_reservation.form</field>
        <field name="model">kre.product_reservation</field>
        <field name="arch" type="xml">
            <form string="Add Attendees">
                <group>
                    <group>
                        <!-- Add your fields here -->
                        <field name="reservation_number"/>
                        <field name="arrivals_date"/>
                        <field name="departure_date"/>
                        <field name="stay_period"/>
                        <field name="qty"/>
                        <field name="price"/>
                        <field name="tax"/>
                        <field name="sub_amount"/>
                        <field name="tax_amount"/>
                        <field name="amount"/>
                        <field name="description"/>
                    </group>
                    <notebook>
                        <page string="Guest List">
                            <field name="guests"/>
                        </page>
                    </notebook>
                </group>
            </form>
        </field>
    </record>

    <act_window id="insert_reservation_wizard" name="Insert Reservation" context="{'reservation_id' : active_id, 'arrival_date' : arrival_date, 'departure_date' : departure_date}" binding_model="kre.reservation" res_model="kre.product_reservation" view_mode="form" target="new"/>

And this is the binding model Field that I want to send in Context.

<field name="name"/>
<field name="billing_name"/>
<field name="arrival_date"/>
<field name="departure_date"/>
<field name="group"/>
<field name="currency"/>
<field name="sub_total"/>
<field name="tax"/>
<field name="total"/>
1

1 Answers

4
votes

Hello Theodorus Agum Gumilang,

On your act_window you can set the model id or any selection or boolean from the default context passing. Like this,

<act_window id="insert_reservation_wizard"
        name="Insert Reservation"
        binding_model="kre.reservation"
        res_model="kre.product_reservation"
        view_mode="form"
        context="{'default_reservation_id' : active_id, 'reservation_id' : active_id}"
        target="new"/>

You can check the other reference on odoo for default value set from act_window. As on your default value set from the form itself on wizard view, you can do with by changing the approach this way,

1) Calling your wizard action from the python.

2) On the python, you can pass the default value on context.

On you form view added the button,

<button name="action_wizard" string="Your String" type="object" class="btn-primary" />

On Python Function,

def action_wizard(self):
    return {
        'name': _("Your String"),
        'type': 'ir.actions.act_window',
        'view_type': 'form',
        'view_mode': 'form',
        'res_model': 'Object',
        'view_id': self.env.ref('module.ref_id').id,
        'target': 'new',
        'context': {
            'default_name': self.default_name,
            'default_billing_name': self.default_billing_name,
            'default_arrival_date': self.default_arrival_date,
            'default_departure_date': self.default_departure_date,
            'default_group': self.default_group,
            'default_currency': self.default_currency,
            'default_sub_total': self.default_sub_total,
            'default_tax': self.default_tax,
            'default_total': self.default_total
        }}

Thanks