Skip to content

Commit

Permalink
ADD zip_product_image module
Browse files Browse the repository at this point in the history
  • Loading branch information
bealdav committed Aug 12, 2024
1 parent 795f403 commit 571079d
Show file tree
Hide file tree
Showing 14 changed files with 632 additions and 0 deletions.
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,
)
60 changes: 60 additions & 0 deletions zip_product_image/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
==================
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 of selected products

**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
29 changes: 29 additions & 0 deletions zip_product_image/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 Akretion
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

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_buffer(self):
self.ensure_one()
if "fs.product.image" in self.env.registry:
# Here fs_product_multi_image is installed
return self.image and self.image.getvalue() or False
return self.image_1920 or False
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
1 change: 1 addition & 0 deletions zip_product_image/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wizard to generate a zip images of selected products
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

0 comments on commit 571079d

Please sign in to comment.