[IMP] point_of_sale: display image as color attribute value
With this commit, Image options for the colour variant have been added. now, the user can identify the pattern values by the image. - It will display the image instead of HEX color if the image is set. task-3381738 closes odoo/odoo#132685 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
committed by
Antoine Vandevenne (anv)
parent
c05336d273
commit
dde1eb57c7
@@ -1630,14 +1630,14 @@ class PosSession(models.Model):
|
||||
[('attribute_id', 'in', product_attributes.ids)],
|
||||
['attribute_id', 'attribute_line_id', 'product_attribute_value_id', 'price_extra'],
|
||||
)
|
||||
product_template_attribute_values.product_attribute_value_id.fetch(['name', 'is_custom', 'html_color'])
|
||||
product_template_attribute_values.product_attribute_value_id.fetch(['name', 'is_custom', 'html_color', 'image'])
|
||||
|
||||
key1 = lambda ptav: (ptav.attribute_line_id.id, ptav.attribute_id.id)
|
||||
key2 = lambda ptav: (ptav.attribute_line_id.id, ptav.attribute_id)
|
||||
res = {}
|
||||
for key, group in groupby(sorted(product_template_attribute_values, key=key1), key=key2):
|
||||
attribute_line_id, attribute = key
|
||||
values = [{**ptav.product_attribute_value_id.read(['name', 'is_custom', 'html_color'])[0],
|
||||
values = [{**ptav.product_attribute_value_id.read(['name', 'is_custom', 'html_color', 'image'])[0],
|
||||
'price_extra': ptav.price_extra} for ptav in list(group)]
|
||||
res[attribute_line_id] = {
|
||||
'id': attribute_line_id,
|
||||
|
||||
+3
-1
@@ -50,8 +50,10 @@
|
||||
<ul class="color_attribute_list d-flex gap-3">
|
||||
<li t-foreach="values" t-as="value" t-key="value.id" class="color_attribute_list_item">
|
||||
<t t-set="is_custom" t-value="is_custom || (value.is_custom && value.id == state.attribute_value_ids)"/>
|
||||
<t t-set="img_style" t-value="value.image ? 'background:url(/web/image/product.attribute.value/' + value.id + '/image); background-size:cover;' : ''"/>
|
||||
<t t-set="color_style" t-value="value.is_custom ? '' : 'background-color: ' + value.html_color" />
|
||||
<label t-attf-class="configurator_color rounded border {{ value.id == state.attribute_value_ids ? 'active border-3 border-primary' : 'border-3 border-secondary' }}"
|
||||
t-attf-style="background-color: {{ value.html_color }};" t-att-data-color="value.name">
|
||||
t-attf-style="#{img_style or color_style}" t-att-data-color="value.name">
|
||||
<input class="m-4 opacity-0" type="radio" t-model="state.attribute_value_ids" t-att-value="value.id" t-att-name="attribute.id"/>
|
||||
</label>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user