diff --git a/base_multi_image/README.rst b/base_multi_image/README.rst index df59057f4e5..b1337a42126 100644 --- a/base_multi_image/README.rst +++ b/base_multi_image/README.rst @@ -17,19 +17,19 @@ Multiple images base :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github - :target: https://github.com/OCA/server-tools/tree/16.0/base_multi_image + :target: https://github.com/OCA/server-tools/tree/17.0/base_multi_image :alt: OCA/server-tools .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_multi_image + :target: https://translation.odoo-community.org/projects/server-tools-17-0/server-tools-17-0-base_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/server-tools&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=17.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| -This module extends the functionality of any model to support multiple images -(a gallery) attached to it and allow you to manage them. +This module extends the functionality of any model to support multiple +images (a gallery) attached to it and allow you to manage them. **Table of contents** @@ -39,80 +39,88 @@ This module extends the functionality of any model to support multiple images Installation ============ -This module adds abstract models to work on. Its sole purpose is to serve as -base for other modules that implement galleries, so if you install this one -manually you will notice no change. You should install any other module based -on this one and this will get installed automatically. +This module adds abstract models to work on. Its sole purpose is to +serve as base for other modules that implement galleries, so if you +install this one manually you will notice no change. You should install +any other module based on this one and this will get installed +automatically. Configuration ============= To manage all stored images, you need to: -* Go to *Settings > Technical > Multi images*. +- Go to *Settings > Technical > Multi images*. ... but you probably prefer to manage them from the forms supplied by submodules that inherit this behavior. Development -=========== +----------- To develop a module based on this one: -* See module ``product_multi_image`` as an example. +- See module ``product_multi_image`` as an example. + +- You have to inherit model ``base_multi_image.owner`` to the model that + needs the gallery: + + :: + + class MyOwner(models.Model): + _name = "my.model.name" + _inherit = ["my.model.name", "base_multi_image.owner"] -* You have to inherit model ``base_multi_image.owner`` to the model that needs - the gallery:: + # If you need this, you will need ``pre_init_hook_for_submodules`` and + ``uninstall_hook_for_submodules`` as detailed below. + old_image_field = fields.Binary(related="image_1920", store=False) - class MyOwner(models.Model): - _name = "my.model.name" - _inherit = ["my.model.name", "base_multi_image.owner"] +- Somewhere in the owner view, add: - # If you need this, you will need ``pre_init_hook_for_submodules`` and - ``uninstall_hook_for_submodules`` as detailed below. - old_image_field = fields.Binary(related="image_1920", store=False) + :: -* Somewhere in the owner view, add:: + - +- If the model you are extending already had an image field, and you + want to trick Odoo to make those images to multi-image mode, you will + need to make use of the provided ~.hooks.post_init_hook_for_submodules + and ~.hooks.uninstall_hook_for_submodules, like the + ``product_multi_image`` module does: -* If the model you are extending already had an image field, and you want to - trick Odoo to make those images to multi-image mode, you will need to make - use of the provided `~.hooks.post_init_hook_for_submodules` and - `~.hooks.uninstall_hook_for_submodules`, like the - ``product_multi_image`` module does:: + :: - try: - from odoo.addons.base_multi_image.hooks import ( - uninstall_hook_for_submodules, - ) - except ImportError: - pass + try: + from odoo.addons.base_multi_image.hooks import ( + uninstall_hook_for_submodules, + ) + except ImportError: + pass - def uninstall_hook(cr, registry): - """Remove multi images for models that no longer use them.""" - uninstall_hook_for_submodules(cr, registry, "product.template") - uninstall_hook_for_submodules(cr, registry, "product.product") + def uninstall_hook(cr, registry): + """Remove multi images for models that no longer use them.""" + uninstall_hook_for_submodules(cr, registry, "product.template") + uninstall_hook_for_submodules(cr, registry, "product.product") +|Try me on Runbot| -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot +.. |Try me on Runbot| image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :target: https://runbot.odoo-community.org/runbot/149/10.0 Known issues / Roadmap ====================== -* *OS file* storage mode for images is meant to provide a path where Odoo has - read access and the image is already found, **not for making the module store - images there**. It would be nice to add that feature though. +- *OS file* storage mode for images is meant to provide a path where + Odoo has read access and the image is already found, **not for making + the module store images there**. It would be nice to add that feature + though. Bug Tracker =========== @@ -120,7 +128,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -128,7 +136,7 @@ Credits ======= Authors -~~~~~~~ +------- * Tecnativa * Antiun Ingeniería @@ -138,28 +146,29 @@ Authors * OpenFire Contributors -~~~~~~~~~~~~ - -* Pedro M. Baeza -* Rafael Blasco -* Jairo Llopis -* Sodexis -* Dave Lasley -* Shepilov Vladislav -* `Greenice `_: - - * Fernando La Chica +------------ + +- Pedro M. Baeza +- Rafael Blasco +- Jairo Llopis +- Sodexis +- Dave Lasley +- Shepilov Vladislav +- `Greenice `__: +- Fernando La Chica +- Ugne Sinkeviciene Other credits -~~~~~~~~~~~~~ +------------- Original implementation ------------------------ -This module is inspired in previous module *product_images* from OpenLabs -and Akretion. +~~~~~~~~~~~~~~~~~~~~~~~ + +This module is inspired in previous module *product_images* from +OpenLabs and Akretion. Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -171,6 +180,6 @@ 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/server-tools `_ project on GitHub. +This module is part of the `OCA/server-tools `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_multi_image/__manifest__.py b/base_multi_image/__manifest__.py index 4f933f89231..23bfdee1d94 100644 --- a/base_multi_image/__manifest__.py +++ b/base_multi_image/__manifest__.py @@ -7,7 +7,7 @@ { "name": "Multiple images base", "summary": "Allow multiple images for database objects", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "author": "Tecnativa, " "Antiun Ingeniería, S.L., Sodexis, " "LasLabs, OpenFire, " diff --git a/base_multi_image/hooks.py b/base_multi_image/hooks.py index 2632fbc2c0b..a120c35ade1 100644 --- a/base_multi_image/hooks.py +++ b/base_multi_image/hooks.py @@ -29,9 +29,7 @@ def post_init_hook_for_submodules(cr, model, field): with cr.savepoint(): column_exists = table_has_column(cr, table, field) if column_exists: - cr.execute( - "SELECT id FROM %(table)s WHERE %(field)s IS NOT NULL" - ) # pylint: disable=sql-injection + cr.execute("SELECT id FROM %(table)s WHERE %(field)s IS NOT NULL") # pylint: disable=sql-injection else: cr.execute( """ @@ -52,7 +50,7 @@ def post_init_hook_for_submodules(cr, model, field): { "owner_id": record.id, "owner_model": model, - "owner_ref_id": "%s,%s" % (model, record.id), + "owner_ref_id": f"{model},{record.id}", "image_1920": record[field], }, ) @@ -111,13 +109,10 @@ def save_directly_to_table(cr, Model, field, Field, main_images): if field and not Field.attachment: fields.append(field + " = " + "%(image)s") query = """ - UPDATE %(table)s - SET %(fields)s - WHERE id = %%(id)s - """ % { - "table": Model._table, - "fields": ", ".join(fields), - } + UPDATE {table} + SET {fields} + WHERE id = %(id)s + """.format(table=Model._table, fields=", ".join(fields)) for main_image in main_images: params = {"id": main_image.owner_id} if field and not Field.attachment: diff --git a/base_multi_image/i18n/it.po b/base_multi_image/i18n/it.po index 0cbbe10b1e4..85d56d274f1 100644 --- a/base_multi_image/i18n/it.po +++ b/base_multi_image/i18n/it.po @@ -10,7 +10,7 @@ msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-01-06 02:24+0000\n" -"PO-Revision-Date: 2024-09-09 10:06+0000\n" +"PO-Revision-Date: 2024-09-11 09:06+0000\n" "Last-Translator: mymage \n" "Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" "Language: it\n" @@ -150,12 +150,12 @@ msgstr "Ultima modifica il" #. module: base_multi_image #: model:ir.model.fields,field_description:base_multi_image.field_base_multi_image_image__write_uid msgid "Last Updated by" -msgstr "Last Updated by" +msgstr "Ultimo aggiornamento di" #. module: base_multi_image #: model:ir.model.fields,field_description:base_multi_image.field_base_multi_image_image__write_date msgid "Last Updated on" -msgstr "Last Updated on" +msgstr "Ultimo aggiornamento il" #. module: base_multi_image #: model:ir.model.fields,field_description:base_multi_image.field_base_multi_image_image__load_from diff --git a/base_multi_image/models/image.py b/base_multi_image/models/image.py index 944513be73c..d4daa9fdfdb 100644 --- a/base_multi_image/models/image.py +++ b/base_multi_image/models/image.py @@ -69,7 +69,7 @@ def _compute_owner_ref_id(self): """Get a reference field based on the split model and id fields.""" for s in self: if s.owner_model: - s.owner_ref_id = "{0.owner_model},{0.owner_id}".format(s) + s.owner_ref_id = f"{s.owner_model},{s.owner_id}" @api.depends("owner_id", "owner_model") def _compute_show_technical(self): diff --git a/base_multi_image/pyproject.toml b/base_multi_image/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/base_multi_image/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/base_multi_image/readme/CONFIGURE.md b/base_multi_image/readme/CONFIGURE.md new file mode 100644 index 00000000000..454e04bd6cd --- /dev/null +++ b/base_multi_image/readme/CONFIGURE.md @@ -0,0 +1,55 @@ +To manage all stored images, you need to: + +- Go to *Settings \> Technical \> Multi images*. + +... but you probably prefer to manage them from the forms supplied by +submodules that inherit this behavior. + +## Development + +To develop a module based on this one: + +- See module `product_multi_image` as an example. + +- You have to inherit model `base_multi_image.owner` to the model that + needs the gallery: + + class MyOwner(models.Model): + _name = "my.model.name" + _inherit = ["my.model.name", "base_multi_image.owner"] + + # If you need this, you will need ``pre_init_hook_for_submodules`` and + ``uninstall_hook_for_submodules`` as detailed below. + old_image_field = fields.Binary(related="image_1920", store=False) + +- Somewhere in the owner view, add: + + + +- If the model you are extending already had an image field, and you + want to trick Odoo to make those images to multi-image mode, you will + need to make use of the provided ~.hooks.post_init_hook_for_submodules + and ~.hooks.uninstall_hook_for_submodules, like the + `product_multi_image` module does: + + try: + from odoo.addons.base_multi_image.hooks import ( + uninstall_hook_for_submodules, + ) + except ImportError: + pass + + + def uninstall_hook(cr, registry): + """Remove multi images for models that no longer use them.""" + uninstall_hook_for_submodules(cr, registry, "product.template") + uninstall_hook_for_submodules(cr, registry, "product.product") + +[![Try me on Runbot](https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas)](https://runbot.odoo-community.org/runbot/149/10.0) diff --git a/base_multi_image/readme/CONFIGURE.rst b/base_multi_image/readme/CONFIGURE.rst deleted file mode 100644 index c335c2a1812..00000000000 --- a/base_multi_image/readme/CONFIGURE.rst +++ /dev/null @@ -1,59 +0,0 @@ -To manage all stored images, you need to: - -* Go to *Settings > Technical > Multi images*. - -... but you probably prefer to manage them from the forms supplied by -submodules that inherit this behavior. - -Development -=========== - -To develop a module based on this one: - -* See module ``product_multi_image`` as an example. - -* You have to inherit model ``base_multi_image.owner`` to the model that needs - the gallery:: - - class MyOwner(models.Model): - _name = "my.model.name" - _inherit = ["my.model.name", "base_multi_image.owner"] - - # If you need this, you will need ``pre_init_hook_for_submodules`` and - ``uninstall_hook_for_submodules`` as detailed below. - old_image_field = fields.Binary(related="image_1920", store=False) - -* Somewhere in the owner view, add:: - - - -* If the model you are extending already had an image field, and you want to - trick Odoo to make those images to multi-image mode, you will need to make - use of the provided `~.hooks.post_init_hook_for_submodules` and - `~.hooks.uninstall_hook_for_submodules`, like the - ``product_multi_image`` module does:: - - try: - from odoo.addons.base_multi_image.hooks import ( - uninstall_hook_for_submodules, - ) - except ImportError: - pass - - - def uninstall_hook(cr, registry): - """Remove multi images for models that no longer use them.""" - uninstall_hook_for_submodules(cr, registry, "product.template") - uninstall_hook_for_submodules(cr, registry, "product.product") - - -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/149/10.0 diff --git a/base_multi_image/readme/CONTRIBUTORS.md b/base_multi_image/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..69f7094259d --- /dev/null +++ b/base_multi_image/readme/CONTRIBUTORS.md @@ -0,0 +1,9 @@ +- Pedro M. Baeza \<\> +- Rafael Blasco \<\> +- Jairo Llopis \<\> +- Sodexis \<\> +- Dave Lasley \<\> +- Shepilov Vladislav \<\> +- [Greenice](https://www.greenice.com): +- Fernando La Chica \<\> +- Ugne Sinkeviciene \<\> diff --git a/base_multi_image/readme/CONTRIBUTORS.rst b/base_multi_image/readme/CONTRIBUTORS.rst deleted file mode 100644 index f1633e7ee6e..00000000000 --- a/base_multi_image/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,9 +0,0 @@ -* Pedro M. Baeza -* Rafael Blasco -* Jairo Llopis -* Sodexis -* Dave Lasley -* Shepilov Vladislav -* `Greenice `_: - - * Fernando La Chica diff --git a/base_multi_image/readme/CREDITS.md b/base_multi_image/readme/CREDITS.md new file mode 100644 index 00000000000..a67b5e48520 --- /dev/null +++ b/base_multi_image/readme/CREDITS.md @@ -0,0 +1,4 @@ +## Original implementation + +This module is inspired in previous module *product_images* from +OpenLabs and Akretion. diff --git a/base_multi_image/readme/CREDITS.rst b/base_multi_image/readme/CREDITS.rst deleted file mode 100644 index 3d3c26198f6..00000000000 --- a/base_multi_image/readme/CREDITS.rst +++ /dev/null @@ -1,4 +0,0 @@ -Original implementation ------------------------ -This module is inspired in previous module *product_images* from OpenLabs -and Akretion. diff --git a/base_multi_image/readme/DESCRIPTION.md b/base_multi_image/readme/DESCRIPTION.md new file mode 100644 index 00000000000..e6e719c9386 --- /dev/null +++ b/base_multi_image/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module extends the functionality of any model to support multiple +images (a gallery) attached to it and allow you to manage them. diff --git a/base_multi_image/readme/DESCRIPTION.rst b/base_multi_image/readme/DESCRIPTION.rst deleted file mode 100644 index 656cb78dc6d..00000000000 --- a/base_multi_image/readme/DESCRIPTION.rst +++ /dev/null @@ -1,2 +0,0 @@ -This module extends the functionality of any model to support multiple images -(a gallery) attached to it and allow you to manage them. diff --git a/base_multi_image/readme/INSTALL.md b/base_multi_image/readme/INSTALL.md new file mode 100644 index 00000000000..740fe297ddb --- /dev/null +++ b/base_multi_image/readme/INSTALL.md @@ -0,0 +1,5 @@ +This module adds abstract models to work on. Its sole purpose is to +serve as base for other modules that implement galleries, so if you +install this one manually you will notice no change. You should install +any other module based on this one and this will get installed +automatically. diff --git a/base_multi_image/readme/INSTALL.rst b/base_multi_image/readme/INSTALL.rst deleted file mode 100644 index e58d92fb5bf..00000000000 --- a/base_multi_image/readme/INSTALL.rst +++ /dev/null @@ -1,4 +0,0 @@ -This module adds abstract models to work on. Its sole purpose is to serve as -base for other modules that implement galleries, so if you install this one -manually you will notice no change. You should install any other module based -on this one and this will get installed automatically. diff --git a/base_multi_image/readme/ROADMAP.md b/base_multi_image/readme/ROADMAP.md new file mode 100644 index 00000000000..f668ea5eba6 --- /dev/null +++ b/base_multi_image/readme/ROADMAP.md @@ -0,0 +1,4 @@ +- *OS file* storage mode for images is meant to provide a path where + Odoo has read access and the image is already found, **not for making + the module store images there**. It would be nice to add that feature + though. diff --git a/base_multi_image/readme/ROADMAP.rst b/base_multi_image/readme/ROADMAP.rst deleted file mode 100644 index e360a6475cc..00000000000 --- a/base_multi_image/readme/ROADMAP.rst +++ /dev/null @@ -1,3 +0,0 @@ -* *OS file* storage mode for images is meant to provide a path where Odoo has - read access and the image is already found, **not for making the module store - images there**. It would be nice to add that feature though. diff --git a/base_multi_image/static/description/index.html b/base_multi_image/static/description/index.html index 2d0027ebbf9..450a93b13df 100644 --- a/base_multi_image/static/description/index.html +++ b/base_multi_image/static/description/index.html @@ -8,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -274,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -300,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -368,15 +369,17 @@

Multiple images base

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:60ac00ce7f687070232e6497bd0c97a20de9bcf45f9263960a3529ab63865636 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

-

This module extends the functionality of any model to support multiple images -(a gallery) attached to it and allow you to manage them.

+

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

+

This module extends the functionality of any model to support multiple +images (a gallery) attached to it and allow you to manage them.

Table of contents

Installation

-

This module adds abstract models to work on. Its sole purpose is to serve as -base for other modules that implement galleries, so if you install this one -manually you will notice no change. You should install any other module based -on this one and this will get installed automatically.

+

This module adds abstract models to work on. Its sole purpose is to +serve as base for other modules that implement galleries, so if you +install this one manually you will notice no change. You should install +any other module based on this one and this will get installed +automatically.

Configuration

@@ -406,15 +410,14 @@

Configuration

… but you probably prefer to manage them from the forms supplied by submodules that inherit this behavior.

-
-

Development

+

Development

To develop a module based on this one:

  • See module product_multi_image as an example.

  • -
  • You have to inherit model base_multi_image.owner to the model that needs -the gallery:

    +
  • You have to inherit model base_multi_image.owner to the model that +needs the gallery:

     class MyOwner(models.Model):
         _name = "my.model.name"
    @@ -437,10 +440,10 @@ 

    Development

    mode="kanban"/>
  • -
  • If the model you are extending already had an image field, and you want to -trick Odoo to make those images to multi-image mode, you will need to make -use of the provided ~.hooks.post_init_hook_for_submodules and -~.hooks.uninstall_hook_for_submodules, like the +

  • If the model you are extending already had an image field, and you +want to trick Odoo to make those images to multi-image mode, you will +need to make use of the provided ~.hooks.post_init_hook_for_submodules +and ~.hooks.uninstall_hook_for_submodules, like the product_multi_image module does:

     try:
    @@ -458,14 +461,16 @@ 

    Development

-Try me on Runbot +

Try me on Runbot

+

Known issues / Roadmap

    -
  • OS file storage mode for images is meant to provide a path where Odoo has -read access and the image is already found, not for making the module store -images there. It would be nice to add that feature though.
  • +
  • OS file storage mode for images is meant to provide a path where +Odoo has read access and the image is already found, not for making +the module store images there. It would be nice to add that feature +though.
@@ -473,7 +478,7 @@

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.

+feedback.

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

@@ -498,28 +503,29 @@

Contributors

  • Sodexis <dev@sodexis.com>
  • Dave Lasley <dave@laslabs.com>
  • Shepilov Vladislav <shepilov.v@protonmail.com>
  • -
  • Greenice: -
  • +
  • Ugne Sinkeviciene <ugne@versada.eu>
  • Other credits

    Original implementation

    -

    This module is inspired in previous module product_images from OpenLabs -and Akretion.

    +

    This module is inspired in previous module product_images from +OpenLabs and Akretion.

    Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +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/server-tools project on GitHub.

    +

    This module is part of the OCA/server-tools project on GitHub.

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

    diff --git a/base_multi_image/views/image_view.xml b/base_multi_image/views/image_view.xml index 7c48f442be8..a76ef74f61e 100644 --- a/base_multi_image/views/image_view.xml +++ b/base_multi_image/views/image_view.xml @@ -8,14 +8,7 @@
    - +