This question has been flagged

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

Avatar
Discard