Skip to content

Commit

Permalink
[ADD] fs_import_image_advanced_thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisOForgeFlow committed Apr 22, 2024
1 parent 0ccbfe6 commit 5c8f999
Show file tree
Hide file tree
Showing 13 changed files with 587 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs_import_image_advanced/models/import_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ def _assign_product_tmpl_attr_values(self, product):
product["product_template_attribute_value_ids"]
)

@api.model
def _post_process_image(self, image):
pass

def _do_import(self, lines, product_model, options=None):
tag_obj = self.env["image.tag"]
image_obj = self.env["fs.image"]
Expand Down Expand Up @@ -309,6 +313,7 @@ def _do_import(self, lines, product_model, options=None):
tmpl_id = prod["product_tmpl_id"][0]

image = image_obj.create(file_vals)
self._post_process_image(image)
if options.get("overwrite"):
domain = [
("image_id.name", "=", image.name),
Expand Down
81 changes: 81 additions & 0 deletions fs_import_image_advanced_thumbnail/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
====================================================
Import Storage product image thumbnail creation tool
====================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:12c7348e725edb528078c94d16ac9f21b523ef9e01cbaa9c369585b41f3d7f13
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstorage-lightgray.png?logo=github
:target: https://github.com/OCA/storage/tree/16.0/fs_import_image_advanced_thumbnail
:alt: OCA/storage
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/storage-16-0/storage-16-0-fs_import_image_advanced_thumbnail
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/storage&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Hook to auto install thumbnail creation when importing massively images with tool

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/storage/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/storage/issues/new?body=module:%20fs_import_image_advanced_thumbnail%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ForgeFlow

Contributors
~~~~~~~~~~~~

* Christopher Ormaza <chris.ormaza@forgeflow.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/storage <https://github.com/OCA/storage/tree/16.0/fs_import_image_advanced_thumbnail>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions fs_import_image_advanced_thumbnail/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions fs_import_image_advanced_thumbnail/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2024 ForgeFlow S.L. (http://www.forgeflow.com)
# @author Christopher Ormaza <chris.ormaza@forgeflow.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Import Storage product image thumbnail creation tool",
"version": "16.0.1.0.0",
"summary": "Import product images using CSV",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"maintainer": "chris.ormaza@forgeflow.com",
"website": "https://github.com/OCA/storage",
"category": "Product",
"development_status": "Alpha",
"depends": ["fs_import_image_advanced", "fs_image_thumbnail"],
"data": [],
"license": "AGPL-3",
"installable": True,
"auto_install": True,
}
1 change: 1 addition & 0 deletions fs_import_image_advanced_thumbnail/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import import_image
18 changes: 18 additions & 0 deletions fs_import_image_advanced_thumbnail/models/import_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from odoo import api, models

from odoo.addons.fs_image.fields import FSImageValue


class ProductImageImportWizard(models.Model):
_inherit = "storage.import.product_image"

@api.model
def _post_process_image(self, image):
thumbnail_model = self.env["fs.thumbnail"]
res = super()._post_process_image(image)
fs_image_value = FSImageValue(attachment=image.image.attachment)
# CHECK ME: This values should be setup on a parameter maybe?
thumbnail_model.get_or_create_thumbnails(
fs_image_value, sizes=[(128, 128), (64, 64)]
)
return res
1 change: 1 addition & 0 deletions fs_import_image_advanced_thumbnail/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Christopher Ormaza <chris.ormaza@forgeflow.com>
1 change: 1 addition & 0 deletions fs_import_image_advanced_thumbnail/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hook to auto install thumbnail creation when importing massively images with tool
Loading

0 comments on commit 5c8f999

Please sign in to comment.