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

I don't get the product_id in a selection field

By
chesucr
on 3/31/15, 6:38 AM 450 views

Hello!!

I have this field the suppliers field in the model mrp.bom.line

class MrpBomLine(models.Model):
    _inherit = 'mrp.bom.line'
    
    suppliers = fields.Selection(string='Supplier',selection="_select_objects")
    
    @api.depends('product_id')
    def _select_objects(self):
        _logger.debug(self.product_id)
        suppliers = self.env['product.supplierinfo'].search([('product_tmpl_id', '=', self.product_id.product_tmpl_id.id)])
        name_fields = [(supplier.id, supplier.name.name) for supplier in suppliers]          
        return name_fields

But, the problem is that I never get the selected product_id even though the product is selected. 

With the instruction `_logger.debug(self.product_id)` I always get `product.product()` without the id

Am I doing anything wrong? Is there another way to do this?

I tried to override the onchange method of product_id, but without any solution

Thanks in advance

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

2 follower(s)

Stats

Asked: 3/31/15, 6:38 AM
Seen: 450 times
Last updated: 3/31/15, 6:38 AM