diff --git a/web_widget_one2many_product_picker/__init__.py b/web_widget_one2many_product_picker/__init__.py index f0e48908c..28345b82a 100644 --- a/web_widget_one2many_product_picker/__init__.py +++ b/web_widget_one2many_product_picker/__init__.py @@ -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 diff --git a/web_widget_one2many_product_picker/__manifest__.py b/web_widget_one2many_product_picker/__manifest__.py index 60a0cace7..6332f71df 100644 --- a/web_widget_one2many_product_picker/__manifest__.py +++ b/web_widget_one2many_product_picker/__manifest__.py @@ -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)", diff --git a/web_widget_one2many_product_picker/i18n/web_widget_one2many_product_picker.pot b/web_widget_one2many_product_picker/i18n/web_widget_one2many_product_picker.pot index 63bd61eb5..816fb70ab 100644 --- a/web_widget_one2many_product_picker/i18n/web_widget_one2many_product_picker.pot +++ b/web_widget_one2many_product_picker/i18n/web_widget_one2many_product_picker.pot @@ -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 diff --git a/web_widget_one2many_product_picker/models/__init__.py b/web_widget_one2many_product_picker/models/__init__.py new file mode 100644 index 000000000..3d1f7c9ef --- /dev/null +++ b/web_widget_one2many_product_picker/models/__init__.py @@ -0,0 +1,2 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +from . import product_product diff --git a/web_widget_one2many_product_picker/models/product_product.py b/web_widget_one2many_product_picker/models/product_product.py new file mode 100644 index 000000000..6beab967a --- /dev/null +++ b/web_widget_one2many_product_picker/models/product_product.py @@ -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 diff --git a/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml b/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml index 78078dba4..700e7fe4f 100644 --- a/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml +++ b/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml @@ -90,11 +90,11 @@ - + - +