diff --git a/fs_product_multi_image/README.rst b/fs_product_multi_image/README.rst index 0e243cc6e2..85793f8b63 100644 --- a/fs_product_multi_image/README.rst +++ b/fs_product_multi_image/README.rst @@ -94,6 +94,7 @@ Contributors * Laurent Mignon * Raphaël Reverdy +* Mathieu Delva * Denis Roussel * Quentin Groulard * `Camptocamp `_ diff --git a/fs_product_multi_image/models/fs_product_image.py b/fs_product_multi_image/models/fs_product_image.py index e5584be3a5..e9738abb91 100644 --- a/fs_product_multi_image/models/fs_product_image.py +++ b/fs_product_multi_image/models/fs_product_image.py @@ -35,6 +35,22 @@ class FsProductImage(models.Model): domain=[("apply_on", "=", "product")], index=True, ) + image_url = fields.Char(compute="_compute_image_url") + + @api.depends("image") + def _compute_image_url(self): + for record in self: + record.image_url = False + if record.image: + record.image_url = self._get_url() + + def _get_url(self): + name = self.product_tmpl_id.name + return f"/web/image/fs.product.image/{self.id}/image?download=true&&filename={name}.jpg" + + def download_image_url(self): + base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url") + return f"{base_url}{self._get_url()}" @api.depends("product_tmpl_id.attribute_line_ids.value_ids") def _compute_available_attribute(self): diff --git a/fs_product_multi_image/readme/CONTRIBUTORS.rst b/fs_product_multi_image/readme/CONTRIBUTORS.rst index 33d0863bc0..0f99d680eb 100644 --- a/fs_product_multi_image/readme/CONTRIBUTORS.rst +++ b/fs_product_multi_image/readme/CONTRIBUTORS.rst @@ -1,5 +1,6 @@ * Laurent Mignon * Raphaël Reverdy +* Mathieu Delva * Denis Roussel * Quentin Groulard * `Camptocamp `_ diff --git a/fs_product_multi_image/static/description/index.html b/fs_product_multi_image/static/description/index.html index 092f4a0457..8eae5884a3 100644 --- a/fs_product_multi_image/static/description/index.html +++ b/fs_product_multi_image/static/description/index.html @@ -441,6 +441,7 @@

Contributors