Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD zip_product_image #314

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup/zip_product_image/odoo/addons/zip_product_image
6 changes: 6 additions & 0 deletions setup/zip_product_image/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
62 changes: 62 additions & 0 deletions zip_product_image/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
==================
Zip Product Images
==================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2918847fc8cec3732a3cbdc65ee2f5cb8dfef637c526f6cfd9424bcd6dccd6fc
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |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-akretion%2Fak--odoo--incubator-lightgray.png?logo=github
:target: https://github.com/akretion/ak-odoo-incubator/tree/16.0/zip_product_image
:alt: akretion/ak-odoo-incubator

|badge1| |badge2| |badge3|

Wizard to generate a zip images file of selected variant products.

This module is compatible with fs_product_multi_image module (from OCA/storage) but doesn't depends on it.

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/akretion/ak-odoo-incubator/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/akretion/ak-odoo-incubator/issues/new?body=module:%20zip_product_image%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
~~~~~~~

* Akretion

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

Kevin Khao

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

This module is part of the `akretion/ak-odoo-incubator <https://github.com/akretion/ak-odoo-incubator/tree/16.0/zip_product_image>`_ project on GitHub.

You are welcome to contribute.
2 changes: 2 additions & 0 deletions zip_product_image/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import wizards
17 changes: 17 additions & 0 deletions zip_product_image/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "Zip Product Images",
"version": "16.0.1.0.0",
"author": "Akretion",
"category": "Product",
"depends": [
"product",
],
"website": "https://github.com/akretion/ak-odoo-incubator",
"data": [
"wizards/export_image.xml",
"security/security.xml",
],
"maintainer": ["kevinkhao", "bealdav"],
"license": "AGPL-3",
"installable": True,
}
1 change: 1 addition & 0 deletions zip_product_image/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product
36 changes: 36 additions & 0 deletions zip_product_image/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2024 Akretion
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import base64
import imghdr

from odoo import api, models

LIMIT = 500


class ProductProduct(models.Model):
_inherit = "product.product"

@api.model
def _generate_image_zipfile(self):
prd_ids = self.env.context["active_ids"]
if prd_ids:
if len(prd_ids) > LIMIT:
raise ValueError(f"Too many selected products : limit = {LIMIT}")
return (
self.env["zip.product.image"]
.create({})
._get_zip_product_images(self.browse(prd_ids))
)

def _product_image_data(self):
self.ensure_one()
if "fs_product_multi_image" in self.env.registry._init_modules:
# Here fs_product_multi_image is installed
if self.image:
return (base64.b64encode(self.image.getvalue()), self.image.extension)
return (False, False)
image_data = base64.b64decode(self.image_1920)
image_type = imghdr.what(None, h=image_data)
return (self.image_1920 or False, f".{image_type}")
1 change: 1 addition & 0 deletions zip_product_image/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Kevin Khao
3 changes: 3 additions & 0 deletions zip_product_image/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Wizard to generate a zip images file of selected variant products.

This module is compatible with fs_product_multi_image module (from OCA/storage) but doesn't depends on it.
16 changes: 16 additions & 0 deletions zip_product_image/security/security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Akretion
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.model.access" id="zip_product_image_access">
<field name="name">wizard zip product image access</field>
<field name="model_id" ref="model_zip_product_image" />
<field name="group_id" ref="base.group_user" />
<field name="perm_read" eval="1" />
<field name="perm_create" eval="1" />
<field name="perm_write" eval="1" />
<field name="perm_unlink" eval="1" />
</record>

</odoo>
Loading
Loading