mirror of https://github.com/OCA/web.git
[FIX] web_widget_one2many_product_picker: Use variant image
parent
d97de8920b
commit
8c0cac194b
|
@ -1,2 +1,3 @@
|
|||
# Copyright 2020 Tecnativa - Alexandre Díaz
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import models
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
{
|
||||
'name': 'Web Widget One2Many Product Picker',
|
||||
'summary': 'Widget to select products on one2many fields',
|
||||
'version': '12.0.1.1.2',
|
||||
'version': '12.0.1.2.0',
|
||||
'category': 'Website',
|
||||
'author': "Tecnativa, "
|
||||
"Odoo Community Association (OCA)",
|
||||
|
|
|
@ -55,6 +55,11 @@ msgstr ""
|
|||
msgid "Price:"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_widget_one2many_product_picker
|
||||
#: model:ir.model,name:web_widget_one2many_product_picker.model_product_product
|
||||
msgid "Product"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_widget_one2many_product_picker
|
||||
#. openerp-web
|
||||
#: code:addons/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker_quick_create.xml:13
|
||||
|
@ -76,6 +81,26 @@ msgstr ""
|
|||
msgid "Subtotal:"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_widget_one2many_product_picker
|
||||
#: model:ir.model.fields,help:web_widget_one2many_product_picker.field_product_product__image_variant_medium
|
||||
msgid "This field holds the image used as image for the product variantor product image medium, limited to 512x512px."
|
||||
msgstr ""
|
||||
|
||||
#. module: web_widget_one2many_product_picker
|
||||
#: model:ir.model.fields,help:web_widget_one2many_product_picker.field_product_product__image_variant_big
|
||||
msgid "This field holds the image used as image for the product variantor product image, limited to 1024x1024px."
|
||||
msgstr ""
|
||||
|
||||
#. module: web_widget_one2many_product_picker
|
||||
#: model:ir.model.fields,field_description:web_widget_one2many_product_picker.field_product_product__image_variant_big
|
||||
msgid "Variant Image Big (Computed)"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_widget_one2many_product_picker
|
||||
#: model:ir.model.fields,field_description:web_widget_one2many_product_picker.field_product_product__image_variant_medium
|
||||
msgid "Variant Image Medium (Computed)"
|
||||
msgstr ""
|
||||
|
||||
#. module: web_widget_one2many_product_picker
|
||||
#. openerp-web
|
||||
#: code:addons/web_widget_one2many_product_picker/static/src/js/views/One2ManyProductPicker/record.js:302
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
|
||||
from . import product_product
|
|
@ -0,0 +1,36 @@
|
|||
# Copyright 2020 Tecnativa - Alexandre D. Díaz
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
|
||||
from odoo import api, fields, models, tools
|
||||
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
image_variant_medium = fields.Binary(
|
||||
"Variant Image Medium (Computed)",
|
||||
compute='_compute_variant_image',
|
||||
help="This field holds the image used as image for the product variant"
|
||||
"or product image medium, limited to 512x512px.",
|
||||
)
|
||||
|
||||
image_variant_big = fields.Binary(
|
||||
"Variant Image Big (Computed)",
|
||||
compute='_compute_variant_image',
|
||||
help="This field holds the image used as image for the product variant"
|
||||
"or product image, limited to 1024x1024px.",
|
||||
)
|
||||
|
||||
@api.depends('image_variant', 'product_tmpl_id.image')
|
||||
def _compute_variant_image(self):
|
||||
for record in self:
|
||||
if record.image_variant:
|
||||
resized_images = tools.image_get_resized_images(
|
||||
record.image_variant,
|
||||
return_big=False,
|
||||
return_small=False,
|
||||
avoid_resize_medium=True)
|
||||
record.image_variant_medium = resized_images['image_medium']
|
||||
record.image_variant_big = record.image_variant
|
||||
else:
|
||||
record.image_variant_medium = record.product_tmpl_id.image_medium
|
||||
record.image_variant_big = record.product_tmpl_id.image
|
|
@ -90,11 +90,11 @@
|
|||
</t>
|
||||
</div>
|
||||
<span data-field="display_name" class="oe_one2many_product_picker_title position-absolute fixed-bottom p-1" data-esc="display_name" />
|
||||
<img alt="" class="img img-fluid" t-att-src="image(state.data[field_map.product].data.id,'image_medium')" t-att-data-src-alt="image(state.data[field_map.product].data.id,'image')" />
|
||||
<img alt="" class="img img-fluid" t-att-src="image(state.data[field_map.product].data.id,'image_variant_medium')" t-att-data-src-alt="image(state.data[field_map.product].data.id,'image_variant_big')" />
|
||||
</t>
|
||||
<t t-else="">
|
||||
<span class="oe_one2many_product_picker_title position-absolute fixed-bottom p-1" t-esc="record_search.display_name" />
|
||||
<img alt="" class="img img-fluid" t-att-src="image(record_search.id,'image_medium')" t-att-data-src-alt="image(record_search.id,'image')" />
|
||||
<img alt="" class="img img-fluid" t-att-src="image(record_search.id,'image_variant_medium')" t-att-data-src-alt="image(record_search.id,'image_variant_big')" />
|
||||
</t>
|
||||
</div>
|
||||
<div class="oe_flip_card_back">
|
||||
|
|
Loading…
Reference in New Issue