Odoo Help

0

I don't get the product_id in a selection field

By
chesucr
on 3/31/15, 6:38 AM 640 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

About This Community

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

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

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