diff --git a/addons/product/models/product_attribute_value.py b/addons/product/models/product_attribute_value.py index b6804793095..fcf5f9011e4 100644 --- a/addons/product/models/product_attribute_value.py +++ b/addons/product/models/product_attribute_value.py @@ -44,6 +44,12 @@ class ProductAttributeValue(models.Model): " to display the color if the attribute type is 'Color'.") display_type = fields.Selection(related='attribute_id.display_type') color = fields.Integer(string="Color Index", default=_get_default_color) + image = fields.Image( + string="Image", + help="You can upload an image that will be used as the color of the attribute value.", + max_width=70, + max_height=70, + ) _sql_constraints = [ ('value_company_uniq', diff --git a/addons/product/models/product_template_attribute_value.py b/addons/product/models/product_template_attribute_value.py index 445d8e32d0f..5e7bd6b6489 100644 --- a/addons/product/models/product_template_attribute_value.py +++ b/addons/product/models/product_template_attribute_value.py @@ -60,6 +60,7 @@ class ProductTemplateAttributeValue(models.Model): is_custom = fields.Boolean(related='product_attribute_value_id.is_custom') display_type = fields.Selection(related='product_attribute_value_id.display_type') color = fields.Integer(string="Color", default=_get_default_color) + image = fields.Image(related='product_attribute_value_id.image') _sql_constraints = [ ('attribute_value_unique', diff --git a/addons/product/views/product_attribute_views.xml b/addons/product/views/product_attribute_views.xml index 11703518fdf..1835d3300e2 100644 --- a/addons/product/views/product_attribute_views.xml +++ b/addons/product/views/product_attribute_views.xml @@ -46,7 +46,12 @@ - + + @@ -95,7 +100,8 @@ - + + @@ -113,7 +119,8 @@ - + + diff --git a/addons/sale_product_configurator/controllers/main.py b/addons/sale_product_configurator/controllers/main.py index cca3513900f..003b064eaa6 100644 --- a/addons/sale_product_configurator/controllers/main.py +++ b/addons/sale_product_configurator/controllers/main.py @@ -236,6 +236,7 @@ class ProductConfiguratorController(Controller): 'name': str, 'price_extra': float, 'html_color': str|False, + 'image': str|False, 'is_custom': bool }], 'selected_attribute_id': int, @@ -270,7 +271,7 @@ class ProductConfiguratorController(Controller): attribute=dict(**ptal.attribute_id.read(['id', 'name', 'display_type'])[0]), attribute_values=[ dict( - **ptav.read(['name', 'html_color', 'is_custom'])[0], + **ptav.read(['name', 'html_color', 'image', 'is_custom'])[0], price_extra=ptav.currency_id._convert( ptav.price_extra, currency, diff --git a/addons/sale_product_configurator/static/src/js/product_template_attribute_line/product_template_attribute_line.js b/addons/sale_product_configurator/static/src/js/product_template_attribute_line/product_template_attribute_line.js index adc1f271b52..ca2cff0a672 100644 --- a/addons/sale_product_configurator/static/src/js/product_template_attribute_line/product_template_attribute_line.js +++ b/addons/sale_product_configurator/static/src/js/product_template_attribute_line/product_template_attribute_line.js @@ -29,6 +29,7 @@ export class ProductTemplateAttributeLine extends Component { id: Number, name: String, html_color: [Boolean, String], // backend sends 'false' when there is no color + image: [Boolean, String], // backend sends 'false' when there is no image set is_custom: Boolean, price_extra: Number, excluded: { type: Boolean, optional: true }, diff --git a/addons/sale_product_configurator/static/src/js/product_template_attribute_line/product_template_attribute_line.xml b/addons/sale_product_configurator/static/src/js/product_template_attribute_line/product_template_attribute_line.xml index f15410b2778..93c83f84e11 100644 --- a/addons/sale_product_configurator/static/src/js/product_template_attribute_line/product_template_attribute_line.xml +++ b/addons/sale_product_configurator/static/src/js/product_template_attribute_line/product_template_attribute_line.xml @@ -92,9 +92,11 @@
  • + +