تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
5946 أدوات العرض

Hello, 

   I have a custom module that adds an item to the "More" button dropdown from the tree view.  The item calls a function which creates a new sales order like it's supposed to do.  The problem is, I would like to open the Sales Order form after the record is created, but for some reason it isn't doing that.

Here is my return statement 

return {
            'name': 'Sale Order',
            'view_type': 'form',
            'view_mode': 'form',
            'view_id': self.pool.get('ir.ui.view').search(cr, uid, [('name','=','sale.order.form')])[0],
            'res_model': 'sale.order',
            'res_id': new_order_id,
            'type': 'ir.actions.act_window',
        }

This block of code works for other things, but it doesn't work when opening a form from a tree view that calls a function when an item in the "More" dropdown menu is clicked.

الصورة الرمزية
إهمال
أفضل إجابة

You shuoldn't need view_id at all, that's only useful when you have multiple, diverging view definitions and need to pick a non-standard one.  If you really wanted to select a specific view, use the XML ID instead:

xml_id_obj = self.pool['ir.model.data']
form_id = xml_id_obj.get_object_reference(cr, uid, 'sale', 'view_order_form')[1]
return {
    'name': 'Sale Order',
    'view_type': 'form',
    'view_mode': 'form',
    'views': [(form_id,'form')],
    'res_model': 'sale.order',
    'res_id': new_order_id,
    'type': 'ir.actions.act_window',
}

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
مارس 15
5553
1
أكتوبر 24
2224
1
سبتمبر 24
3401
6
ديسمبر 23
17333
0
يناير 16
3799