Skip to Content
Menu
This question has been flagged
1 Reply
1691 Views

Hello,


I created a product with variants with multiple colors.

and now i'm trying to display the colors on product variants list ( for exemple not juste the word red but the actual color).

I tried some things with the field product_template_attribute_value_ids but nothing works.

Avatar
Discard
Best Answer

To display the colors on the product variants list in Odoo 14, you can follow these steps:

  1. Create a new field in your product template model, for example, color_hex, and store the color hex code for each variant.

  2. In your template, you can use this field to display the color in the variants list. You can create a new template and inherit the existing one.

    
    

  1. You can use the css to define the width and the height of the color.
.variant-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-block;
}
  1. To populate the color_hex field, you can create a new method in your product template model and update the field with the color hex code.

  2. Finally, you need to call this method when creating or updating a variant, you can do it by adding the method in the create and write methods of the product template attribute value model.

You can also use this approach in the product page template and add the color in the product list view template.

Please note that the above steps are a general approach and you need to adjust it according to your specific requirements.

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 24
1483
1
Nov 24
1188
2
Sep 24
1047
1
Aug 24
2451
3
Aug 24
2686