Odoo Help

Welcome!

This community 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.

0

error in open a wizard from python code?

By
Laurent33
on 6/21/13, 1:41 PM 2,105 views

Hi,

in a custom module, I have inherit account.invoice and create a new method which is executed after invoice validation for opening a wizard defined in the custom module.

    def action_task_picking(self, cr, uid, ids, context=None):
    if context==None:
        context={}

    action = {
        'type': 'ir.actions.act_window',
        'view_type': 'form',
        'view_mode': 'form',
        'res_model': 'iota.task.picking',
        'target': 'new',
        'view_id': False,
        }
    return action

The XML view for the wizard :

        <record model="ir.ui.view" id="view_iota_task_picking">
        <field name="name">Invoice validation</field>
        <field name="model">iota.task.picking</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Invoice validation" >
                <field name="partner_id" />
                <separator string="Tasks" colspan="4"/>
                    <field name="task_ids" />
                <separator string="Picking" colspan="4"/>
                <group colspan="2" col="6" >
                    <field name="date_receipt" />
                    <field name="pick_ids" /> 
                    <newline/>
                </group>
                <newline/>
                <separator string="" colspan="4"/>
                <button special="cancel" string="Cancel" icon="gtk-cancel"/>
                <button name="action_confirm" string="Validate" type="object" icon="gtk-apply"/>  
            </form>
        </field>
    </record>

When running action_task_picking, I obtain message (in french)

Impossible d’obtenir la propriété  « view_type » d’une référence null ou non définie

I translate by

Unable to get property view_type for null or undefined reference

What is wrong in pyton code ?

1
Dharmesh Rathod
On 6/22/13, 2:57 PM

Hi,

You have to provide ID value for FORM view.

Thanks
Acespritech Solutions Pvt Ltd
http://www.acespritech.com
http://acespritechblog.wordpress.com

Hi, i've tried to add : 'view_id': 1198, (the id of the view in ir_ui_view) in the dictionnary but always the same error message

Laurent33
on 6/24/13, 11:06 AM
0
Laurent33
On 6/28/13, 5:25 AM

Hi,

it works by calling wizard like that :

    modl_obj = self.pool.get('ir.model.data')
view_id_res=modl_obj.get_object_reference(cr, uid, 'my_custom_module', 'view_iota_task_picking')[1]
return {
    'type': 'ir.actions.act_window',
    'view_id': False,
    'view_type': 'form',
    'view_mode': 'form',
    'views': [(view_id_res, 'form')],
    'res_model': 'iota.task.picking',
    'nodestroy': True,
    'target': 'new',
    'context': context,
    }

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 6/21/13, 1:41 PM
Seen: 2105 times
Last updated: 3/16/15, 8:10 AM