beriliox
beriliox

Reputation: 267

Why Odoo shows me the message: Form view couldn't be loaded?

I have a button that when pressed opens a view stock.picking model ( stock.picking.form ). This button and function are in the sale.order.line model.

In the sale.order.form view :

<button type='object' name='open_wizard' string="Stock Picking View" icon="fa-arrow-right"/>

In the sale.order.line model:

@api.multi
def open_wizard(self):
    view_id = self.env.ref('stock.view_picking_form').id
    context = self._context.copy()
    return {
        'name':'Stock Picking Form',
        'view_type':'form',
        'view_mode':'tree',
        'views' : [(view_id,'form')],
        'res_model':'stock.picking',
        'view_id':view_id,
        'type':'ir.actions.act_window',
        'res_id':self.id,
        'target':'new',
        'context':context,
    }

When I press the button, Odoo shows me the following message: Form view couldn't be loaded enter image description here

If someone could help me, to correct any errors . Because I don't understand why Odoo shows me the message above . Thank you so much.

Upvotes: 1

Views: 1714

Answers (3)

Salem Hassan
Salem Hassan

Reputation: 85

I was have same problem and It was In the res_id : self.Id after I change It It to 'res_id':self.cash_policy_ids.id, I my case Its work I hope this can help you

Upvotes: 0

beriliox
beriliox

Reputation: 267

Odoo I still continued showing me the same message : Form view Could not be loaded . Maybe they are missing parameters to add to the function and does not recognize the view.

This is my code: [In my sale.py]

@api.multi
def redirection(self):
    view_id = self.env.ref('stock.view_picking_form').id
    return {
        'name':'stock.picking.form',
        'view_type':'form',
        'view_mode':'form',
        'views' : [(view_id,'form')],
        'res_model':'stock.picking',
        'view_id':view_id,
        'type':'ir.actions.act_window',
        'res_id':self.id,
        'target':'current',
    }

[In my sale.order.form view ]

<button type="object" string="Form Stock Picking" name="redirection"/>

What could be the problem?

Upvotes: -1

Kiran
Kiran

Reputation: 1531

I had created a button for redirecting to form view.May be you can use this code as reference. This is my xml file,

<record model="ir.ui.view" id="view_census_form">
            <field name="name">census.form</field>
            <field name="model">census</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
            <form string="census">
            <group>
                <field name="first_name" style="width: 40%"/>
                <field name="last_name" style="width: 40%"/>
                <field name="birth_date" style="width: 40%"/>       
                <field name="address" style="width: 40%"/>
                <field name="phone" style="width: 40%"/>
                <field name="email" style="width: 40%"/>  
                <button type="object" string="Form2" name="redirection"/>
            </group>    
            </form>
            </field>
        </record>

.py file,

    @api.multi
    def redirection(self):
        view_id = self.env.ref('census.view_census_form').id


        return {
            'name':'census.form',
            'view_type':'form',
            'view_mode':'form',
            'views' : [(view_id,'form')],
            'res_model':'census',
            'view_id':view_id,
            'type':'ir.actions.act_window',
            'res_id':self.id,
            'target':'current',

        }

Upvotes: 1

Related Questions