Skip to Content
Menu
This question has been flagged
2 Replies
7517 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 ?

Avatar
Discard
Best Answer

Hi,

You have to provide ID value for FORM view.

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

Avatar
Discard
Author

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

Author Best Answer

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,
    }
Avatar
Discard
Related Posts Replies Views Activity
0
Mar 15
6961
3
Feb 25
57619
1
Mar 15
5966
1
Mar 15
7014
0
Mar 25
1173