diff --git a/web_widget_one2many_product_picker/models/base.py b/web_widget_one2many_product_picker/models/base.py index 86a1cd305..970e7dc1b 100644 --- a/web_widget_one2many_product_picker/models/base.py +++ b/web_widget_one2many_product_picker/models/base.py @@ -31,21 +31,14 @@ class BaseModel(models.BaseModel): field_obj = self[relation_field] if field_obj: relation_id = relation_id.id - has_product = ( - self.search( - [ - (relation_field, "=", relation_id), - (product_field, "in", product_ids), - ], - count=True, - limit=1, - ) - != 0 + db_sol = self.search( + [(relation_field, "=", relation_id), (product_field, "in", product_ids)], + limit=1, ) - if has_product: + if db_sol: raise ValidationError( - _("Can't create the %s: Duplicated product! (Already in database)") - % relation + _("Can't create the %s: Duplicated product (%s)! (Already in database)") + % (relation, db_sol[product_field].display_name) ) @api.model_create_multi