I created a new model with the name product.service.type. Then in the model, product.productI also created a field Many2many(with a name service_typepointing to the model product.service.type).
Now I have a model testthat has fields product_idand service_type_id, both Many2onepoint to product.productand product.service.typerespectively.
When I select a product, I want to change the domain of the service type to display only the service types of the selected product. I managed it through onchange:
def onchange_product_id(self, cr, uid, ids, product_id, context=None):
if product_id:
product = self.pool.get('product.product').browse(
cr, uid, [product_id], context=context)
service_type_ids = product.service_type.mapped('id')
return {
'domain': {
'service_type_id': [('id', 'in', service_type_ids)],
},
}
This works great, the problem is that you are editing the record (without creating a new one), because in this case onchangeit is not executed, and therefore the domain shows all types of services.
title. , , title, , Corp., Ltd. .., , , , , , .. . . title, is_company. , , ( ).
?