[MIG] base_conditional_image: Migration to 15.0

pull/2644/head
Denis Leemann 2022-07-12 17:42:41 +02:00 committed by pol
parent 3545572dfe
commit 83df9b5d4b
14 changed files with 184 additions and 374 deletions

View File

@ -14,13 +14,13 @@ Conditional Images
: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/14.0/base_conditional_image
:target: https://github.com/OCA/server-tools/tree/15.0/base_conditional_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-14-0/server-tools-14-0-base_conditional_image
:target: https://translation.odoo-community.org/projects/server-tools-15-0/server-tools-15-0-base_conditional_image
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/149/14.0
:target: https://runbot.odoo-community.org/runbot/149/15.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -45,11 +45,11 @@ Installation
The sole purpose of this module is to add an abstract model to be inherited.
So, you will not notice any changes on install.
To develop using this module, you have to inherit the abstract model `abstract.conditional.image`
To develop using this module, you have to inherit the abstract model `conditional.image.consumer.mixin`
to the model that needs the conditional images::
class ResPartner(models.Model):
_inherit = ['res.partner', 'abstract.conditional.image']
_inherit = ['res.partner', 'conditional.image.consumer.mixin']
_name = 'res.partner'
Then, configure how the images will be selected for each record.
@ -71,7 +71,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_conditional_image%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_conditional_image%0Aversion:%2015.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.
@ -88,6 +88,7 @@ Contributors
* `Camptocamp <https://camptocamp.com/>`_:
* Patrick Tombez <patrick.tombez@camptocamp.com>
* Denis Leemann <denis.leemann@camptocamp.com>
* `Trobz <https://trobz.com>`_:
* Son Ho <sonhd@trobz.com>
@ -109,6 +110,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 <https://github.com/OCA/server-tools/tree/14.0/base_conditional_image>`_ project on GitHub.
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/15.0/base_conditional_image>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -1,10 +1,10 @@
# Copyright 2019 Camptocamp SA
# Copyright 2019-2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
{
"name": "Conditional Images",
"summary": "This module extends the functionality to support conditional images",
"version": "14.0.1.0.0",
"version": "15.0.1.0.0",
"author": "Camptocamp, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Misc",

View File

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@ -14,23 +14,12 @@ msgstr ""
"Plural-Forms: \n"
#. module: base_conditional_image
#: model:ir.model,name:base_conditional_image.model_abstract_conditional_image
msgid "Abstract image"
msgstr ""
#. module: base_conditional_image
#: code:addons/base_conditional_image/models/image.py:0
#, python-format
msgid "At least one image type must be specified"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_image__company_id
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__company_id
msgid "Company"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,help:base_conditional_image.field_image__company_id
#: model:ir.model.fields,help:base_conditional_image.field_conditional_image__company_id
msgid ""
"Company related check. If inherited object does not have a `company_id` "
"field, it will be ignored. The check will first take the records with a "
@ -38,81 +27,99 @@ msgid ""
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_image__create_uid
#: model:ir.model,name:base_conditional_image.model_conditional_image
#: model_terms:ir.ui.view,arch_db:base_conditional_image.view_conditional_image_form
msgid "Conditional Image"
msgstr ""
#. module: base_conditional_image
#: model:ir.actions.act_window,name:base_conditional_image.conditional_image_action
#: model:ir.ui.menu,name:base_conditional_image.conditional_image_menu
msgid "Conditional Images"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__create_uid
msgid "Created by"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_image__create_date
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__create_date
msgid "Created on"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_abstract_conditional_image__display_name
#: model:ir.model.fields,field_description:base_conditional_image.field_image__display_name
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__display_name
msgid "Display Name"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_abstract_conditional_image__id
#: model:ir.model.fields,field_description:base_conditional_image.field_image__id
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__id
msgid "ID"
msgstr ""
#. module: base_conditional_image
#: model:ir.model,name:base_conditional_image.model_image
#: model:ir.model.fields,field_description:base_conditional_image.field_abstract_conditional_image__image
#: model:ir.model.fields,field_description:base_conditional_image.field_image__image
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__image_1920
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image_consumer_mixin__image_1920
msgid "Image"
msgstr ""
#. module: base_conditional_image
#: model:ir.actions.act_window,name:base_conditional_image.image_action
#: model:ir.ui.menu,name:base_conditional_image.image_menu
msgid "Images"
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__image_1024
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image_consumer_mixin__image_1024
msgid "Image 1024"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_abstract_conditional_image____last_update
#: model:ir.model.fields,field_description:base_conditional_image.field_image____last_update
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__image_128
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image_consumer_mixin__image_128
msgid "Image 128"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__image_256
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image_consumer_mixin__image_256
msgid "Image 256"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__image_512
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image_consumer_mixin__image_512
msgid "Image 512"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image____last_update
msgid "Last Modified on"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_image__write_uid
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__write_uid
msgid "Last Updated by"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_image__write_date
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__write_date
msgid "Last Updated on"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_abstract_conditional_image__image_medium
#: model:ir.model.fields,field_description:base_conditional_image.field_image__image_medium
msgid "Medium-sized image"
#: model:ir.model,name:base_conditional_image.model_conditional_image_consumer_mixin
msgid "Mixin for conditional images consumers"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,help:base_conditional_image.field_image__image_medium
msgid ""
"Medium-sized image. It is automatically resized as a 128x128px image, with "
"aspect ratio preserved. Use this field in form views or some kanban views."
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_image__model_name
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__model_name
msgid "Model Name"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_image__name
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__name
msgid "Name"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,help:base_conditional_image.field_image__selector
#: model:ir.model.fields,help:base_conditional_image.field_conditional_image__selector
msgid ""
"Python expression used as selector when multiple images are usedfor the same"
" object. The variable `object` refers to the actual record on which the "
@ -120,25 +127,7 @@ msgid ""
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_image__selector
#: model_terms:ir.ui.view,arch_db:base_conditional_image.view_image_form
#: model:ir.model.fields,field_description:base_conditional_image.field_conditional_image__selector
#: model_terms:ir.ui.view,arch_db:base_conditional_image.view_conditional_image_form
msgid "Selector"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,field_description:base_conditional_image.field_abstract_conditional_image__image_small
#: model:ir.model.fields,field_description:base_conditional_image.field_image__image_small
msgid "Small-sized image"
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,help:base_conditional_image.field_image__image_small
msgid ""
"Small-sized image. It is automatically resized as a 64x64px image, with "
"aspect ratio preserved. Use this field anywhere a small image is required."
msgstr ""
#. module: base_conditional_image
#: model:ir.model.fields,help:base_conditional_image.field_image__image
msgid "This field holds the standard image, limited to 1024x1024px"
msgstr ""

View File

@ -1,141 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * custom_image
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 9.0e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-10-02 08:36+0000\n"
"PO-Revision-Date: 2018-10-02 08:36+0000\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: custom_image
#: code:addons/custom_image/models/image.py:47
#, python-format
msgid "At least one image type must be specified"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_image_company_id
msgid "Company"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,help:custom_image.field_image_company_id
msgid "Company related check. If inherited object does not have a `company_id` field, it will be ignored. The check will first take the records with a company then, if not match is found, the ones without a company."
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_image_create_uid
msgid "Created by"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_image_create_date
msgid "Created on"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_abstract_custom_image_display_name
#: model:ir.model.fields,field_description:custom_image.field_image_display_name
msgid "Display Name"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_abstract_custom_image_id
#: model:ir.model.fields,field_description:custom_image.field_image_id
msgid "ID"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_abstract_custom_image_image
#: model:ir.model.fields,field_description:custom_image.field_abstract_custom_image_image_medium
#: model:ir.model.fields,field_description:custom_image.field_abstract_custom_image_image_small
#: model:ir.model.fields,field_description:custom_image.field_image_image
msgid "Image"
msgstr ""
#. module: custom_image
#: model:ir.actions.act_window,name:custom_image.image_action
#: model:ir.ui.menu,name:custom_image.image_menu
msgid "Images"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_abstract_custom_image___last_update
#: model:ir.model.fields,field_description:custom_image.field_image___last_update
msgid "Last Modified on"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_image_write_uid
msgid "Last Updated by"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_image_write_date
msgid "Last Updated on"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_image_image_medium
msgid "Medium-sized image"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,help:custom_image.field_image_image_medium
msgid "Medium-sized image. It is automatically resized as a 128x128px image, with aspect ratio preserved. Use this field in form views or some kanban views."
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_image_model_name
msgid "Model Name"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_image_name
msgid "Name"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,help:custom_image.field_image_selector
msgid "Python expression used to distinguish the images for the same object. The variable `object` refer to the actual record on which the expression will be executed. An empty expression will always return `True`."
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_image_selector
#: model:ir.ui.view,arch_db:custom_image.view_image_form
msgid "Selector"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,field_description:custom_image.field_image_image_small
msgid "Small-sized image"
msgstr ""
#. module: custom_image
#: model:ir.model.fields,help:custom_image.field_image_image_small
msgid "Small-sized image. It is automatically resized as a 64x64px image, with aspect ratio preserved. Use this field anywhere a small image is required."
msgstr ""
#. module: custom_image
#: model:ir.model.fields,help:custom_image.field_image_image
msgid "This field holds the standard image, limited to 1024x1024px"
msgstr ""
#. module: custom_image
#: model:ir.model,name:custom_image.model_abstract_custom_image
msgid "abstract.custom.image"
msgstr ""
#. module: custom_image
#: model:ir.model,name:custom_image.model_image
msgid "image"
msgstr ""

View File

@ -1,2 +1,2 @@
from . import image
from . import abstract_image
from . import conditional_image_consumer_mixin
from . import conditional_image

View File

@ -1,69 +0,0 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import fields, models
from odoo.tools.safe_eval import safe_eval
class AbstractConditionalImage(models.AbstractModel):
_name = "abstract.conditional.image"
_description = "Abstract image"
image = fields.Binary(compute="_compute_image", store=False, readonly=True)
image_medium = fields.Binary(
compute="_compute_image",
string="Medium-sized image",
store=False,
readonly=True,
)
image_small = fields.Binary(
compute="_compute_image", string="Small-sized image", store=False, readonly=True
)
@staticmethod
def _compute_selector_test_without_company(image_selector, record):
return bool(safe_eval(image_selector.selector or "True", {"object": record}))
@staticmethod
def _compute_selector_test_with_company(image_selector, record):
if (
image_selector.company_id == record.company_id
or record.company_id
and not image_selector.company_id
):
return AbstractConditionalImage._compute_selector_test_without_company(
image_selector, record
)
return False
def _compute_image(self):
if "company_id" in self._fields:
search_clause = [("model_name", "=", self._name)]
test_method = self._compute_selector_test_with_company
else:
# If inherited object doesn't have a `company_id` field,
# remove the items with a company defined and the related checks
search_clause = [
("model_name", "=", self._name),
("company_id", "=", False),
]
test_method = self._compute_selector_test_without_company
image_selectors = self.env["image"].search(
search_clause, order="company_id, selector"
)
for rec in self:
found = None
for image_selector in image_selectors:
if test_method(image_selector, rec):
found = image_selector
break
rec.update(
{
"image": found and found.image,
"image_medium": found and found.image_medium,
"image_small": found and found.image_small,
}
)

View File

@ -0,0 +1,27 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import fields, models
class ConditionalImage(models.Model):
_name = "conditional.image"
_description = "Conditional Image"
_inherit = ["image.mixin"]
name = fields.Char(required=True)
model_name = fields.Char(required=True)
selector = fields.Text(
help="Python expression used as selector when multiple images are used"
"for the same object. The variable `object` refers "
"to the actual record on which the expression will be executed. "
"An empty expression will always return `True`.",
)
company_id = fields.Many2one(
"res.company",
"Company",
help="Company related check. If inherited object does not have a "
"`company_id` field, it will be ignored. "
"The check will first take the records with a company then, "
"if no match is found, the ones without a company.",
)

View File

@ -0,0 +1,67 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import fields, models
from odoo.tools.safe_eval import safe_eval
class ConditionalImageConsumerMixin(models.AbstractModel):
_name = "conditional.image.consumer.mixin"
_description = "Mixin for conditional images consumers"
_inherit = "image.mixin"
image_1920 = fields.Image(compute="_compute_images", store=False, readonly=True)
image_1024 = fields.Image(compute="_compute_images", store=False, readonly=True)
image_512 = fields.Image(compute="_compute_images", store=False, readonly=True)
image_256 = fields.Image(compute="_compute_images", store=False, readonly=True)
image_128 = fields.Image(compute="_compute_images", store=False, readonly=True)
def _conditional_image_evaluate_selector(self, conditional_image):
self.ensure_one()
if conditional_image.selector:
if (
conditional_image.company_id == self.company_id
or self.company_id
and not conditional_image.company_id
):
return bool(
safe_eval(conditional_image.selector or "True", {"object": self})
)
return False
def _compute_images(self):
if "company_id" in self._fields:
search_clause = [("model_name", "=", self._name)]
else:
# If inherited object doesn't have a `company_id` field,
# remove the items with a company defined and the related checks
search_clause = [
("model_name", "=", self._name),
("company_id", "=", False),
]
conditional_images = self.env["conditional.image"].search(
search_clause, order="company_id, selector"
)
for record in self:
images_found = conditional_images.filtered(
lambda img: record._conditional_image_evaluate_selector(img)
)
values = {
"image_1920": False,
"image_1024": False,
"image_512": False,
"image_256": False,
"image_128": False,
}
if images_found:
image = images_found[0]
values = {
"image_1920": image.image_1920,
"image_1024": image.image_1024,
"image_512": image.image_512,
"image_256": image.image_256,
"image_128": image.image_128,
}
record.update(values)

View File

@ -1,66 +0,0 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import _, api, fields, models, tools
from odoo.exceptions import ValidationError
class Image(models.Model):
_name = "image"
_description = "Image"
name = fields.Char(required=True)
model_name = fields.Char(required=True)
selector = fields.Text(
help="Python expression used as selector when multiple images are used"
"for the same object. The variable `object` refers "
"to the actual record on which the expression will be executed. "
"An empty expression will always return `True`.",
)
company_id = fields.Many2one(
"res.company",
"Company",
help="Company related check. If inherited object does not have a "
"`company_id` field, it will be ignored. "
"The check will first take the records with a company then, "
"if no match is found, the ones without a company.",
)
# image: all image fields are base64 encoded and PIL-supported
image = fields.Binary(
attachment=True,
help="This field holds the standard image, limited to 1024x1024px",
)
image_medium = fields.Binary(
"Medium-sized image",
attachment=True,
help="Medium-sized image. It is automatically "
"resized as a 128x128px image, with aspect ratio preserved. "
"Use this field in form views or some kanban views.",
)
image_small = fields.Binary(
"Small-sized image",
attachment=True,
help="Small-sized image. It is automatically "
"resized as a 64x64px image, with aspect ratio preserved. "
"Use this field anywhere a small image is required.",
)
@api.model
def _process_images(self, vals, required=False):
if {"image", "image_medium", "image_small"} & set(vals.keys()):
vals["image_medium"] = tools.image_process(
vals.get("image"), size=(128, 128)
)
vals["image_small"] = tools.image_process(vals.get("image"), size=(64, 64))
elif required:
raise ValidationError(_("At least one image type must be specified"))
@api.model
def create(self, vals):
self._process_images(vals, required=True)
return super().create(vals)
def write(self, vals):
self._process_images(vals)
return super().write(vals)

View File

@ -1,4 +1,5 @@
* `Camptocamp <https://camptocamp.com/>`_:
* Patrick Tombez <patrick.tombez@camptocamp.com>
* Denis Leemann <denis.leemann@camptocamp.com>
* `Trobz <https://trobz.com>`_:
* Son Ho <sonhd@trobz.com>

View File

@ -1,11 +1,11 @@
The sole purpose of this module is to add an abstract model to be inherited.
So, you will not notice any changes on install.
To develop using this module, you have to inherit the abstract model `abstract.conditional.image`
To develop using this module, you have to inherit the abstract model `conditional.image.consumer.mixin`
to the model that needs the conditional images::
class ResPartner(models.Model):
_inherit = ['res.partner', 'abstract.conditional.image']
_inherit = ['res.partner', 'conditional.image.consumer.mixin']
_name = 'res.partner'
Then, configure how the images will be selected for each record.

View File

@ -1,3 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_conditional_image,Conditional Image,base_conditional_image.model_image,base.group_no_one,1,1,1,1
access_conditional_image_users,Conditional Image Users,base_conditional_image.model_image,base.group_user,1,0,0,0
access_conditional_image,Conditional Image,base_conditional_image.model_conditional_image,base.group_no_one,1,1,1,1
access_conditional_image_users,Conditional Image Users,base_conditional_image.model_conditional_image,base.group_user,1,0,0,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_conditional_image Conditional Image base_conditional_image.model_image base_conditional_image.model_conditional_image base.group_no_one 1 1 1 1
3 access_conditional_image_users Conditional Image Users base_conditional_image.model_image base_conditional_image.model_conditional_image base.group_user 1 0 0 0

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/14.0/base_conditional_image"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-base_conditional_image"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/15.0/base_conditional_image"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-15-0/server-tools-15-0-base_conditional_image"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of any model to support conditional images
(based on the record attributes) and to manage them either globally or by company.</p>
<p>The main goal behind this module is to avoid storing the same image multiple times.
@ -393,11 +393,11 @@ With this module properly set up, it will be stored only one time and you can ch
<h1><a class="toc-backref" href="#id1">Installation</a></h1>
<p>The sole purpose of this module is to add an abstract model to be inherited.
So, you will not notice any changes on install.</p>
<p>To develop using this module, you have to inherit the abstract model <cite>abstract.conditional.image</cite>
<p>To develop using this module, you have to inherit the abstract model <cite>conditional.image.consumer.mixin</cite>
to the model that needs the conditional images:</p>
<pre class="literal-block">
class ResPartner(models.Model):
_inherit = ['res.partner', 'abstract.conditional.image']
_inherit = ['res.partner', 'conditional.image.consumer.mixin']
_name = 'res.partner'
</pre>
<p>Then, configure how the images will be selected for each record.</p>
@ -415,7 +415,7 @@ If your object does not have a <cite>company_id</cite> field, this check will be
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20base_conditional_image%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20base_conditional_image%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -433,6 +433,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<dt><a class="reference external" href="https://camptocamp.com/">Camptocamp</a>:</dt>
<dd><ul class="first last">
<li>Patrick Tombez &lt;<a class="reference external" href="mailto:patrick.tombez&#64;camptocamp.com">patrick.tombez&#64;camptocamp.com</a>&gt;</li>
<li>Denis Leemann &lt;<a class="reference external" href="mailto:denis.leemann&#64;camptocamp.com">denis.leemann&#64;camptocamp.com</a>&gt;</li>
</ul>
</dd>
</dl>
@ -458,7 +459,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/14.0/base_conditional_image">OCA/server-tools</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/15.0/base_conditional_image">OCA/server-tools</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_image_tree" model="ir.ui.view">
<field name="name">image.tree</field>
<field name="model">image</field>
<record id="view_conditional_image_tree" model="ir.ui.view">
<field name="name">conditional.image.tree</field>
<field name="model">conditional.image</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
@ -13,11 +13,11 @@
</field>
</record>
<record id="view_image_form" model="ir.ui.view">
<field name="name">image.form</field>
<field name="model">image</field>
<record id="view_conditional_image_form" model="ir.ui.view">
<field name="name">conditional.image.form</field>
<field name="model">conditional.image</field>
<field name="arch" type="xml">
<form>
<form string="Conditional Image">
<group>
<group>
<field name="name" />
@ -26,10 +26,10 @@
</group>
<group>
<field
name="image"
name="image_1920"
widget='image'
class="oe_avatar"
options='{"preview_image": "image_medium"}'
options='{"preview_image": "image_1920"}'
/>
</group>
<group string="Selector">
@ -45,16 +45,16 @@
</field>
</record>
<record id="image_action" model="ir.actions.act_window">
<field name="name">Images</field>
<field name="res_model">image</field>
<record id="conditional_image_action" model="ir.actions.act_window">
<field name="name">Conditional Images</field>
<field name="res_model">conditional.image</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.ui.menu" id="image_menu">
<field name="name">Images</field>
<record model="ir.ui.menu" id="conditional_image_menu">
<field name="name">Conditional Images</field>
<field name="parent_id" ref="base.menu_ir_property" />
<field name="action" ref="image_action" />
<field name="action" ref="conditional_image_action" />
<field name="sequence" eval="99" />
</record>
</odoo>