diff --git a/setup/storage_image_product_brand/odoo/addons/storage_image_product_brand b/setup/storage_image_product_brand/odoo/addons/storage_image_product_brand new file mode 120000 index 0000000000..f58862e9c6 --- /dev/null +++ b/setup/storage_image_product_brand/odoo/addons/storage_image_product_brand @@ -0,0 +1 @@ +../../../../storage_image_product_brand \ No newline at end of file diff --git a/setup/storage_image_product_brand/setup.py b/setup/storage_image_product_brand/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/storage_image_product_brand/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/storage_image_product_brand/README.rst b/storage_image_product_brand/README.rst new file mode 100644 index 0000000000..f48ffef358 --- /dev/null +++ b/storage_image_product_brand/README.rst @@ -0,0 +1,87 @@ +=========================== +Storage Image Product Brand +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:494af9918f9bcaf619be482903bd5ad999f2358d91801f71ccd01b7e1612509f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-OCA%2Fstorage-lightgray.png?logo=github + :target: https://github.com/OCA/storage/tree/14.0/storage_image_product_brand + :alt: OCA/storage +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/storage-14-0/storage-14-0-storage_image_product_brand + :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=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Attach images to product brands + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Go to Sales > Configuration > Products > Product Brands. +A new field Images is available to upload or use existing images. + +For uploading and managing the images see the module storage_image. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Quentin Groulard +* `Camptocamp `_ + + * Iván Todorovich + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/storage_image_product_brand/__init__.py b/storage_image_product_brand/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/storage_image_product_brand/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/storage_image_product_brand/__manifest__.py b/storage_image_product_brand/__manifest__.py new file mode 100644 index 0000000000..4099e28351 --- /dev/null +++ b/storage_image_product_brand/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Storage Image Product Brand", + "summary": "Link images to product brands", + "version": "15.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/storage", + "depends": ["storage_image_product", "product_brand"], + "data": [ + "security/product_brand_image_relation.xml", + "views/product_brand.xml", + "views/product_brand_image_relation.xml", + ], +} diff --git a/storage_image_product_brand/i18n/storage_image_product_brand.pot b/storage_image_product_brand/i18n/storage_image_product_brand.pot new file mode 100644 index 0000000000..d7e5854cb8 --- /dev/null +++ b/storage_image_product_brand/i18n/storage_image_product_brand.pot @@ -0,0 +1,139 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * storage_image_product_brand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__image_alt_name +msgid "Alt Image name" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_image_tag__apply_on +msgid "Apply On" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__brand_id +#: model:ir.model.fields.selection,name:storage_image_product_brand.selection__image_tag__apply_on__brand +msgid "Brand" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__create_uid +msgid "Created by" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__create_date +msgid "Created on" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_image_tag__display_name +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand__display_name +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__display_name +msgid "Display Name" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_image_tag__id +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand__id +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__id +msgid "ID" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__image_id +msgid "Image" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model,name:storage_image_product_brand.model_image_tag +msgid "Image Tag" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand__image_ids +#: model_terms:ir.ui.view,arch_db:storage_image_product_brand.product_brand_form_view +#: model_terms:ir.ui.view,arch_db:storage_image_product_brand.product_brand_image_relation_form_view +#: model_terms:ir.ui.view,arch_db:storage_image_product_brand.product_brand_image_relation_kanban_view +msgid "Images" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__import_from_url +msgid "Imported From Url" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_image_tag____last_update +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand____last_update +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation____last_update +msgid "Last Modified on" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__write_date +msgid "Last Updated on" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand__main_image_id +msgid "Main Image" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand__image_medium_url +msgid "Main Image URL (medium)" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand__image_small_url +msgid "Main Image URL (small)" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__image_url +msgid "Medium thumb URL" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__image_name +msgid "Name" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model,name:storage_image_product_brand.model_product_brand +msgid "Product Brand" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model,name:storage_image_product_brand.model_product_brand_image_relation +msgid "Product Brand Image Relation" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__sequence +msgid "Sequence" +msgstr "" + +#. module: storage_image_product_brand +#: model:ir.model.fields,field_description:storage_image_product_brand.field_product_brand_image_relation__tag_id +msgid "tag" +msgstr "" diff --git a/storage_image_product_brand/models/__init__.py b/storage_image_product_brand/models/__init__.py new file mode 100644 index 0000000000..5a23677a04 --- /dev/null +++ b/storage_image_product_brand/models/__init__.py @@ -0,0 +1,3 @@ +from . import product_brand +from . import product_brand_image_relation +from . import image_tag diff --git a/storage_image_product_brand/models/image_tag.py b/storage_image_product_brand/models/image_tag.py new file mode 100644 index 0000000000..3352214241 --- /dev/null +++ b/storage_image_product_brand/models/image_tag.py @@ -0,0 +1,20 @@ +# Copyright 2021 Akretion (https://www.akretion.com). +# @author Sébastien BEAU +# 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")]) diff --git a/storage_image_product_brand/models/product_brand.py b/storage_image_product_brand/models/product_brand.py new file mode 100644 index 0000000000..d10017b902 --- /dev/null +++ b/storage_image_product_brand/models/product_brand.py @@ -0,0 +1,33 @@ +# Copyright 2020 ACSONE SA/NV +# Copyright 2021 Camptocamp (http://www.camptocamp.com). +# @author Iván Todorovich +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ProductBrand(models.Model): + _inherit = "product.brand" + + image_ids = fields.One2many( + comodel_name="product.brand.image.relation", + inverse_name="brand_id", + string="Images", + ) + main_image_id = fields.Many2one( + comodel_name="storage.image", + compute="_compute_main_image_id", + # Store it to improve perf on product views + store=True, + ) + image_small_url = fields.Char( + string="Main Image URL (small)", related="main_image_id.image_small_url" + ) + image_medium_url = fields.Char( + string="Main Image URL (medium)", related="main_image_id.image_medium_url" + ) + + @api.depends("image_ids.sequence") + def _compute_main_image_id(self): + for rec in self: + rec.main_image_id = fields.first(rec.image_ids).image_id diff --git a/storage_image_product_brand/models/product_brand_image_relation.py b/storage_image_product_brand/models/product_brand_image_relation.py new file mode 100644 index 0000000000..a599606e58 --- /dev/null +++ b/storage_image_product_brand/models/product_brand_image_relation.py @@ -0,0 +1,21 @@ +# Copyright 2020 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ProductBrandImageRelation(models.Model): + _name = "product.brand.image.relation" + _inherit = "image.relation.abstract" + _description = "Product Brand Image Relation" + + 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/storage_image_product_brand/readme/CONTRIBUTORS.rst b/storage_image_product_brand/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..b625d3be27 --- /dev/null +++ b/storage_image_product_brand/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Quentin Groulard +* `Camptocamp `_ + + * Iván Todorovich diff --git a/storage_image_product_brand/readme/DESCRIPTION.rst b/storage_image_product_brand/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..2d613b1d6b --- /dev/null +++ b/storage_image_product_brand/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Attach images to product brands diff --git a/storage_image_product_brand/readme/USAGE.rst b/storage_image_product_brand/readme/USAGE.rst new file mode 100644 index 0000000000..1877782516 --- /dev/null +++ b/storage_image_product_brand/readme/USAGE.rst @@ -0,0 +1,4 @@ +Go to Sales > Configuration > Products > Product Brands. +A new field Images is available to upload or use existing images. + +For uploading and managing the images see the module storage_image. diff --git a/storage_image_product_brand/security/product_brand_image_relation.xml b/storage_image_product_brand/security/product_brand_image_relation.xml new file mode 100644 index 0000000000..6bfe1059d4 --- /dev/null +++ b/storage_image_product_brand/security/product_brand_image_relation.xml @@ -0,0 +1,23 @@ + + + + + product.brand.image.relation access read + + + + + + + + + product.brand.image.relation access edit + + + + + + + + diff --git a/storage_image_product_brand/static/description/icon.png b/storage_image_product_brand/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/storage_image_product_brand/static/description/icon.png differ diff --git a/storage_image_product_brand/static/description/index.html b/storage_image_product_brand/static/description/index.html new file mode 100644 index 0000000000..9900cbdacb --- /dev/null +++ b/storage_image_product_brand/static/description/index.html @@ -0,0 +1,432 @@ + + + + + + +Storage Image Product Brand + + + +
+

Storage Image Product Brand

+ + +

Beta License: AGPL-3 OCA/storage Translate me on Weblate Try me on Runboat

+

Attach images to product brands

+

Table of contents

+ +
+

Usage

+

Go to Sales > Configuration > Products > Product Brands. +A new field Images is available to upload or use existing images.

+

For uploading and managing the images see the module storage_image.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/storage_image_product_brand/views/product_brand.xml b/storage_image_product_brand/views/product_brand.xml new file mode 100644 index 0000000000..85443ae0d5 --- /dev/null +++ b/storage_image_product_brand/views/product_brand.xml @@ -0,0 +1,41 @@ + + + + + product.brand + + + + 1 + + + + + + + + + + + + + product.brand + + + + + + + record.image_small_url.value + + + + diff --git a/storage_image_product_brand/views/product_brand_image_relation.xml b/storage_image_product_brand/views/product_brand_image_relation.xml new file mode 100644 index 0000000000..6d20364986 --- /dev/null +++ b/storage_image_product_brand/views/product_brand_image_relation.xml @@ -0,0 +1,40 @@ + + + + + + product.brand.image.relation + + primary + +
+ Images +
+ + + +
+
+ + + product.brand.image.relation + + primary + + + Images + + + + +