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

Button to Open Product Record in Tree view

By
Cyrus Waithaka
on 4/28/15, 3:37 AM 633 views

In the manufacturing bill of materials (mrp.bom model) form view, There is a list of components that make up a product. I want to add a button to the list view that opens the product component in a pop up.

I have tried this code but the button is opening the wrong product item. Please help me resolve what I am doing wrong.

class mrp_bom_line(osv.osv):
    _inherit = ['mrp.bom.line']
    def open_full_record(self, cr, uid, ids, context=None):
        return {
            'type': 'ir.actions.act_window',
            'view_type': 'form',
            'view_mode': 'form',
            'res_model': 'product.template',#self._name,
            'res_id': ids[0],
            'target': 'new',
            'context': context,  # May want to modify depending on the source/destination
            }

 

0

Temur

--Temur--
2896
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 4/28/15, 4:06 AM

use "active_id"

I have specified that but it soesnt seem to work. This is how I added it. data = self.browse(cr, uid, ids[0], context=context) context['active_id'] = data.product_id.id above the return statement.

Cyrus Waithaka
on 4/28/15, 9:01 AM

what is the lite

'res_id': ids[0],
for?
Temur
on 4/29/15, 12:10 PM

res_id (optional) if the default view is form, specifies the record to load (otherwise a new record should be created)

Temur
on 4/29/15, 12:11 PM

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

1 follower(s)

Stats

Asked: 4/28/15, 3:37 AM
Seen: 633 times
Last updated: 4/28/15, 4:06 AM