diff --git a/fs_product_brand_multi_image/README.rst b/fs_product_brand_multi_image/README.rst new file mode 100644 index 0000000000..38929e8775 --- /dev/null +++ b/fs_product_brand_multi_image/README.rst @@ -0,0 +1,35 @@ +**This file is going to be generated by oca-gen-addon-readme.** + +*Manual changes will be overwritten.* + +Please provide content in the ``readme`` directory: + +* **DESCRIPTION.rst** (required) +* INSTALL.rst (optional) +* CONFIGURE.rst (optional) +* **USAGE.rst** (optional, highly recommended) +* DEVELOP.rst (optional) +* ROADMAP.rst (optional) +* HISTORY.rst (optional, recommended) +* **CONTRIBUTORS.rst** (optional, highly recommended) +* CREDITS.rst (optional) + +Content of this README will also be drawn from the addon manifest, +from keys such as name, authors, maintainers, development_status, +and license. + +A good, one sentence summary in the manifest is also highly recommended. + + +Automatic changelog generation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +`HISTORY.rst` can be auto generated using `towncrier `_. + +Just put towncrier compatible changelog fragments into `readme/newsfragments` +and the changelog file will be automatically generated and updated when a new fragment is added. + +Please refer to `towncrier` documentation to know more. + +NOTE: the changelog will be automatically generated when using `/ocabot merge $option`. +If you need to run it manually, refer to `OCA/maintainer-tools README `_. diff --git a/fs_product_brand_multi_image/__init__.py b/fs_product_brand_multi_image/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/fs_product_brand_multi_image/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/fs_product_brand_multi_image/__manifest__.py b/fs_product_brand_multi_image/__manifest__.py new file mode 100644 index 0000000000..4672dffb79 --- /dev/null +++ b/fs_product_brand_multi_image/__manifest__.py @@ -0,0 +1,21 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Fs Product Brand Multi Image", + "summary": """ + Link images to product brands""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/storage", + "depends": ["fs_base_multi_image", "product_brand", "sales_team", "image_tag"], + "data": [ + "security/fs_product_brand_image.xml", + "views/fs_product_brand_image.xml", + "views/product_brand.xml", + ], + "demo": [], + "maintainers": ["lmignon"], + "development_status": "Alpha", +} diff --git a/fs_product_brand_multi_image/models/__init__.py b/fs_product_brand_multi_image/models/__init__.py new file mode 100644 index 0000000000..78b1d43526 --- /dev/null +++ b/fs_product_brand_multi_image/models/__init__.py @@ -0,0 +1,3 @@ +from . import fs_product_brand_image +from . import product_brand +from . import image_tag diff --git a/fs_product_brand_multi_image/models/fs_product_brand_image.py b/fs_product_brand_multi_image/models/fs_product_brand_image.py new file mode 100644 index 0000000000..094cd088cc --- /dev/null +++ b/fs_product_brand_multi_image/models/fs_product_brand_image.py @@ -0,0 +1,21 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class FsProductBrandImage(models.Model): + _name = "fs.product.brand.image" + _inherit = "fs.image.relation.mixin" + _description = "Product Brand Image" + + brand_id = fields.Many2one( + "product.brand", + required=True, + ondelete="cascade", + ) + tag_id = fields.Many2one( + "image.tag", + string="tag", + domain=[("apply_on", "=", "brand")], + ) diff --git a/fs_product_brand_multi_image/models/image_tag.py b/fs_product_brand_multi_image/models/image_tag.py new file mode 100644 index 0000000000..7a2cd37a70 --- /dev/null +++ b/fs_product_brand_multi_image/models/image_tag.py @@ -0,0 +1,23 @@ +# Copyright 2021 Akretion (https://www.akretion.com). +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +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") + if active_model == "product.brand.image.relation": + return "brand" + else: + return super()._get_default_apply_on() + + apply_on = fields.Selection( + selection_add=[("brand", "Brand")], + ondelete={"brand": "cascade"}, + ) diff --git a/fs_product_brand_multi_image/models/product_brand.py b/fs_product_brand_multi_image/models/product_brand.py new file mode 100644 index 0000000000..6a9686c5dc --- /dev/null +++ b/fs_product_brand_multi_image/models/product_brand.py @@ -0,0 +1,20 @@ +# Copyright 2020 ACSONE SA/NV +# Copyright 2021 Camptocamp (http://www.camptocamp.com). +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + +from odoo.addons.fs_image.fields import FSImage + + +class ProductBrand(models.Model): + _inherit = "product.brand" + + image_ids = fields.One2many( + string="Images", + comodel_name="fs.product.brand.image", + inverse_name="brand_id", + ) + image = FSImage(related="image_ids.image", readonly=True, store=False) + image_medium = FSImage(related="image_ids.image_medium", readonly=True, store=False) diff --git a/fs_product_brand_multi_image/readme/CONTRIBUTORS.rst b/fs_product_brand_multi_image/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..12f7d304e3 --- /dev/null +++ b/fs_product_brand_multi_image/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* Sébastien Beau +* Quentin Groulard +* `Camptocamp `_ + + * Iván Todorovich + +* Laurent Mignon diff --git a/fs_product_brand_multi_image/readme/DESCRIPTION.rst b/fs_product_brand_multi_image/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..76e6915bc8 --- /dev/null +++ b/fs_product_brand_multi_image/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +Attach images stored into an external filesystem to product brands + +This addon is a drop-in replacement for the **storage_image_product_brand** addon. diff --git a/fs_product_brand_multi_image/readme/USAGE.rst b/fs_product_brand_multi_image/readme/USAGE.rst new file mode 100644 index 0000000000..2d71d16339 --- /dev/null +++ b/fs_product_brand_multi_image/readme/USAGE.rst @@ -0,0 +1,2 @@ +Go to Sales > Configuration > Products > Product Brands. +A new field Images is available to upload or use existing images. diff --git a/fs_product_brand_multi_image/security/fs_product_brand_image.xml b/fs_product_brand_multi_image/security/fs_product_brand_image.xml new file mode 100644 index 0000000000..72358a901f --- /dev/null +++ b/fs_product_brand_multi_image/security/fs_product_brand_image.xml @@ -0,0 +1,23 @@ + + + + + fs.product.brand.image access read + + + + + + + + + fs.product.brand.image access edit + + + + + + + + diff --git a/fs_product_brand_multi_image/static/description/icon.png b/fs_product_brand_multi_image/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/fs_product_brand_multi_image/static/description/icon.png differ diff --git a/fs_product_brand_multi_image/views/fs_product_brand_image.xml b/fs_product_brand_multi_image/views/fs_product_brand_image.xml new file mode 100644 index 0000000000..6c6c003303 --- /dev/null +++ b/fs_product_brand_multi_image/views/fs_product_brand_image.xml @@ -0,0 +1,22 @@ + + + + + product.brand.fs.image.form + fs.product.brand.image + + primary + + + + + + + diff --git a/fs_product_brand_multi_image/views/product_brand.xml b/fs_product_brand_multi_image/views/product_brand.xml new file mode 100644 index 0000000000..5c17c7c441 --- /dev/null +++ b/fs_product_brand_multi_image/views/product_brand.xml @@ -0,0 +1,50 @@ + + + + + product.brand + + + + 1 + + + + + + + + + + + + + + + + + + + product.brand + + + + kanban_image('product.brand', 'image_medium', record.id.raw_value) + + + + diff --git a/setup/fs_product_brand_multi_image/odoo/addons/fs_product_brand_multi_image b/setup/fs_product_brand_multi_image/odoo/addons/fs_product_brand_multi_image new file mode 120000 index 0000000000..7bb3dc4ffd --- /dev/null +++ b/setup/fs_product_brand_multi_image/odoo/addons/fs_product_brand_multi_image @@ -0,0 +1 @@ +../../../../fs_product_brand_multi_image \ No newline at end of file diff --git a/setup/fs_product_brand_multi_image/setup.py b/setup/fs_product_brand_multi_image/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/fs_product_brand_multi_image/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)