# -*- coding: utf-8 -*-
'''
    product

    :copyright: (c) 2014 by Openlabs Technologies & Consulting (P) Ltd.
    :license: GPLv3, see LICENSE for more details

'''
from trytond.pool import Pool, PoolMeta


__all__ = ['Product']

__metaclass__ = PoolMeta


class Product:
    "Product extension for Nereid"
    __name__ = "product.product"

    def get_default_image(self, name):
        "Returns default product image"
        ModelData = Pool().get('ir.model.data')

        images = self.get_images()
        if images:
            return images[0].id
        else:
            return ModelData.get_id("nereid_webshop", "mystery_box")

@@ -465,16 +465,425 @@
 data')%0A%0A
+        # Get default image from default_image_set of product template%0A        # or product variant.%0A        if self.use_template_images:%0A            if self.template.default_image_set:%0A                return self.template.default_image_set.image.id%0A        elif self.default_image_set:%0A            return self.default_image_set.image.id%0A%0A        # Fallback condition if there is no default_image_set defined%0A
         

Set default image set for product variants and templates #4673