diff --git a/zip_product_image/models/product.py b/zip_product_image/models/product.py index a389eaed..4bf8caf0 100644 --- a/zip_product_image/models/product.py +++ b/zip_product_image/models/product.py @@ -20,3 +20,10 @@ def _generate_image_zipfile(self): .create({}) ._get_zip_product_images(self.browse(prd_ids)) ) + + def _product_image_buffer(self): + self.ensure_one() + if "fs.product.image" in self.env.registry: + # Here fs_product_multi_image is installed + return self.image + return self.image_1920 diff --git a/zip_product_image/wizards/export_image.py b/zip_product_image/wizards/export_image.py index 87544e11..343e7677 100644 --- a/zip_product_image/wizards/export_image.py +++ b/zip_product_image/wizards/export_image.py @@ -21,10 +21,9 @@ class ZipProductImage(models.TransientModel): def _get_zip_product_images(self, products): """Generate a zip file with the images of the products.""" zip_buffer = BytesIO() - img_field = self._product_image_field() with zipfile.ZipFile(zip_buffer, "a", zipfile.ZIP_DEFLATED, False) as zip_file: for prd in products: - img_data = prd[img_field] and base64.b64decode(prd[img_field]) + img_data = base64.b64decode(prd._product_image_buffer()) if img_data: name = "" for field in self._product_field_names(): @@ -45,7 +44,3 @@ def _product_field_names(self): def _product_image_extension(self): return "png" - - def _product_image_field(self): - "Can be different is used with storage repo" - return "image_1920" diff --git a/zip_product_image/wizards/export_image.xml b/zip_product_image/wizards/export_image.xml index 6b5d913c..e501e740 100644 --- a/zip_product_image/wizards/export_image.xml +++ b/zip_product_image/wizards/export_image.xml @@ -23,7 +23,7 @@ - Export images + 📎 Zip images export code