Skip to content

Commit

Permalink
[ADD] fs_product_public_category_multi_image: a drop-in replacement o…
Browse files Browse the repository at this point in the history
…f storage_image_product_public_category
  • Loading branch information
BernatPForgeFlow committed Jun 18, 2024
1 parent 1fe1a81 commit 5849265
Show file tree
Hide file tree
Showing 19 changed files with 795 additions and 0 deletions.
87 changes: 87 additions & 0 deletions fs_product_public_category_multi_image/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
======================================
Fs Product Public Category Multi Image
======================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:52faa35306ff117e720655c0ff7d10523f12a5d0f19d1213cd6d183ed81c513f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_product_public_category_multi_image
: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_product_public_category_multi_image
: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|

Attach images to public categories

.. 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:

Usage
=====

A) Public Categories

Go to Website > eCommerce > Products > eCommerce Categories.
A new section Images is available to upload or use an existing image.

For uploading and managing the images see the module fs_product_multi_image.

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_product_public_category_multi_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
=======

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

* Juany Davila <[email protected]>
* Bernat Puig <[email protected]>

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_product_public_category_multi_image>`_ 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_product_public_category_multi_image/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions fs_product_public_category_multi_image/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 ForgeFlow (http://www.forgeflow.com).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Fs Product Public Category Multi Image",
"summary": """
Manage multi images from extenal file system on eCommerce public categories""",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/storage",
"depends": ["fs_base_multi_image", "website_sale", "image_tag"],
"data": [
"security/fs_product_public_category_image.xml",
"views/fs_product_public_category_image.xml",
"views/product_public_category.xml",
],
"demo": [],
"development_status": "Alpha",
}
3 changes: 3 additions & 0 deletions fs_product_public_category_multi_image/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import fs_product_public_category_image
from . import image_tag
from . import product_public_category
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 ForgeFlow (http://www.forgeflow.com).
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import fields, models


class FsProductPublicCategoryImage(models.Model):
_name = "fs.product.public.category.image"
_inherit = "fs.image.relation.mixin"
_description = "Product Public Category Image"

public_category_id = fields.Many2one(
"product.public.category",
required=True,
ondelete="cascade",
index=True,
)
tag_id = fields.Many2one(
"image.tag",
string="Tag",
domain=[("apply_on", "=", "public.category")],
index=True,
)
23 changes: 23 additions & 0 deletions fs_product_public_category_multi_image/models/image_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2024 ForgeFlow (http://www.forgeflow.com).
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).


from odoo import api, fields, models


class ImageTag(models.Model):
_inherit = "image.tag"

@api.model
def _get_default_apply_on(self):
active_model = self.env.context.get("active_model")
return (

Check warning on line 14 in fs_product_public_category_multi_image/models/image_tag.py

View check run for this annotation

Codecov / codecov/patch

fs_product_public_category_multi_image/models/image_tag.py#L13-L14

Added lines #L13 - L14 were not covered by tests
"public.category"
if active_model == "public.category.image.relation"
else super()._get_default_apply_on()
)

apply_on = fields.Selection(
selection_add=[("public.category", "Public Category")],
ondelete={"product": "cascade", "category": "cascade"},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2024 ForgeFlow (http://www.forgeflow.com).
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import fields, models

from odoo.addons.fs_image.fields import FSImage


class ProductPublicCategory(models.Model):
_inherit = "product.public.category"

image_ids = fields.One2many(
string="Images",
comodel_name="fs.product.public.category.image",
inverse_name="public_category_id",
)
image = FSImage(related="image_ids.image", readonly=True, store=False)
image_medium = FSImage(related="image_ids.image_medium", readonly=True, store=False)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Juany Davila <[email protected]>
* Bernat Puig <[email protected]>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Attach images to public categories
6 changes: 6 additions & 0 deletions fs_product_public_category_multi_image/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
A) Public Categories

Go to Website > eCommerce > Products > eCommerce Categories.
A new section Images is available to upload or use an existing image.

For uploading and managing the images see the module fs_product_multi_image.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 ForgeFlow (http://www.forgeflow.com).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>

<record model="ir.model.access" id="fs_product_public_category_image_read">
<field name="name">fs.product.public.category.image access read</field>
<field name="model_id" ref="model_fs_product_public_category_image" />
<field name="group_id" ref="base.group_user" />
<field name="perm_read" eval="1" />
<field name="perm_create" eval="0" />
<field name="perm_write" eval="0" />
<field name="perm_unlink" eval="0" />
</record>
<record model="ir.model.access" id="fs_product_public_category_image_system_admin">
<field name="name">fs.product.public.category.image access system admin</field>
<field name="model_id" ref="model_fs_product_public_category_image" />
<field name="group_id" ref="base.group_system" />
<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>
<record model="ir.model.access" id="fs_product_public_category_image_sales_manager">
<field name="name">fs.product.public.category.image access sales manager</field>
<field name="model_id" ref="model_fs_product_public_category_image" />
<field name="group_id" ref="sales_team.group_sale_manager" />
<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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5849265

Please sign in to comment.