diff --git a/mrp_bom_attribute_match/models/mrp_bom.py b/mrp_bom_attribute_match/models/mrp_bom.py index 4d8137d54..af2be4e2d 100644 --- a/mrp_bom_attribute_match/models/mrp_bom.py +++ b/mrp_bom_attribute_match/models/mrp_bom.py @@ -69,7 +69,8 @@ class MrpBomLine(models.Model): raise ValidationError( _( "No match on attribute has been detected for Component " - "(Product Template) %s" % self.component_template_id.display_name + "(Product Template) %s", + self.component_template_id.display_name, ) ) if not all(item in prod_attr_ids for item in comp_attr_ids): @@ -96,16 +97,15 @@ class MrpBomLine(models.Model): ) same_attrs = set(self.match_on_attribute_ids.ids) & set(variant_attr_ids.ids) if len(same_attrs) > 0: + attr_recs = self.env["product.attribute"].browse(same_attrs) raise ValidationError( _( - "You cannot use an attribute value for attribute" - " %s in the field “Apply on Variants” as it’s the" - " same attribute used in field “Match on Attribute”" - "related to the component %s." - % ( - self.env["product.attribute"].browse(same_attrs), - self.component_template_id.name, - ) + "You cannot use an attribute value for attribute(s) %(attributes)s " + "in the field “Apply on Variants” as it's the same attribute used " + "in the field “Match on Attribute” related to the component " + "%(component)s.", + attributes=", ".join(attr_recs.mapped("name")), + component=self.component_template_id.name, ) ) diff --git a/mrp_bom_attribute_match/models/product.py b/mrp_bom_attribute_match/models/product.py index da1012b46..7d34ae507 100644 --- a/mrp_bom_attribute_match/models/product.py +++ b/mrp_bom_attribute_match/models/product.py @@ -26,11 +26,13 @@ class ProductTemplate(models.Model): attr_recs = self.env["product.attribute"].browse(diff) raise UserError( _( - "The attributes you're trying to remove is used in BoM " - "as a match with Component (Product Template). To " - "remove these attributes, first remove the BOM line " - "with the matching component.\nAttributes: %s\nBoM: %s" - % (attr_recs.mapped("name"), bom.display_name) + "The attributes you're trying to remove are used in " + "the BoM as a match with Component (Product Template). " + "To remove these attributes, first remove the BOM line " + "with the matching component.\n" + "Attributes: %(attributes)s\nBoM: %(bom)s", + attributes=", ".join(attr_recs.mapped("name")), + bom=bom.display_name, ) ) @@ -48,13 +50,11 @@ class ProductTemplate(models.Model): raise UserError( _( "This product template is used as a component in the " - "BOMs for %s and attribute(s) %s is not present in all " - "such product(s), and this would break the BOM " - "behavior." - % ( - bom.display_name, - attr_recs.mapped("name"), - ) + "BOMs for %(bom)s and attribute(s) %(attributes)s is " + "not present in all such product(s), and this would " + "break the BOM behavior.", + attributes=", ".join(attr_recs.mapped("name")), + bom=bom.display_name, ) )