Hi there,
i try to set a domain in an on_change function on project_task. Selecting the sale order item a sub-product has to be selected and i want to set the domain on this many2one field.
class bundleProduct(models.Model):
_name = "bundle.product"
name = fields.Many2one('product.product',string="Name")
prod_id = fields.Many2one('product.product', string="Product Id")
quantity = fields.Integer(string="Quantity", default="0")
unit_id = fields.Many2one('product.uom', 'Unit of Measure ')
class bundleProductTask(models.Model):
_inherit = "project.task"
#Sub - Product
bundle_product_id = fields.Many2one('bundle.product')
@api.onchange('sale_line_id')
def onchange_sale_line_id(self):
bundle_product_ids = self.env['bundle.product'].search([('prod_id', '=', self.sale_line_id.product_id.id)])
return {'domain': {'bundle_product_id': [('id', 'in', bundle_product_ids.id)]}}
Creating a task - selecting a sale order item - no sub-product for selection will be shown. I have tried to set the domain inside the xml view without any success.
Thanks for your help,
Kind regards, Franz