summaryrefslogtreecommitdiff
path: root/addons/mail
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2019-08-01 11:20:40 +0000
committerSébastien Theys <seb@odoo.com>2019-08-02 16:47:58 +0000
commitf0ffbea17381cb117f2eed4ea18a76e2b0f37f00 (patch)
tree6b0a1a34e1b79b9d5d7e46c54d461684a4d584bf /addons/mail
parent1b85ab93ec647ed723dd72d11df7b3c8283d5f98 (diff)
[IMP] *: remove unnecessary image sizes
The big images are probably never going to be used for the following models: - pos category - fleet brand - livechat channel - mail channel - payment acquirer And if big images are needed some day the model should use image.mixin instead. PR: #34925
Diffstat (limited to 'addons/mail')
-rw-r--r--addons/mail/models/mail_channel.py23
-rw-r--r--addons/mail/static/src/js/models/threads/channel.js2
-rw-r--r--addons/mail/views/mail_channel_views.xml2
3 files changed, 7 insertions, 20 deletions
diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py
index 83a418a44e4..974897c3c1c 100644
--- a/addons/mail/models/mail_channel.py
+++ b/addons/mail/models/mail_channel.py
@@ -12,7 +12,6 @@ from odoo import _, api, fields, models, modules, tools
from odoo.exceptions import UserError, ValidationError
from odoo.osv import expression
from odoo.tools import ormcache
-from odoo.tools.safe_eval import safe_eval
MODERATION_FIELDS = ['moderation', 'moderator_ids', 'moderation_ids', 'moderation_notify', 'moderation_notify_msg', 'moderation_guidelines', 'moderation_guidelines_msg']
_logger = logging.getLogger(__name__)
@@ -64,7 +63,7 @@ class Channel(models.Model):
def _get_default_image(self):
image_path = modules.get_module_resource('mail', 'static/src/img', 'groupdefault.png')
- return tools.image_process(base64.b64encode(open(image_path, 'rb').read()), size=(1024, 1024))
+ return base64.b64encode(open(image_path, 'rb').read())
@api.model
def default_get(self, fields):
@@ -101,17 +100,7 @@ class Channel(models.Model):
help="Members of those groups will automatically added as followers. "
"Note that they will be able to manage their subscription manually "
"if necessary.")
- # image: all image fields are base64 encoded and PIL-supported
- image = fields.Binary("Photo", default=_get_default_image,
- help="This field holds the image used as photo for the group, limited to 1024x1024px.")
- image_128 = fields.Binary('Medium-sized photo',
- help="Medium-sized photo of the group. It is automatically "
- "resized as a 128x128px image, with aspect ratio preserved. "
- "Use this field in form views or some kanban views.")
- image_64 = fields.Binary('Small-sized photo',
- help="Small-sized photo of the group. It is automatically "
- "resized as a 64x64px image, with aspect ratio preserved. "
- "Use this field anywhere a small image is required.")
+ image_128 = fields.Image("Image", max_width=128, max_height=128, default=_get_default_image)
is_subscribed = fields.Boolean(
'Is Subscribed', compute='_compute_is_subscribed')
# moderation
@@ -209,11 +198,10 @@ class Channel(models.Model):
@api.model
def create(self, vals):
# ensure image at quick create
- if not vals.get('image'):
- defaults = self.default_get(['image'])
- vals['image'] = defaults['image']
+ if not vals.get('image_128'):
+ defaults = self.default_get(['image_128'])
+ vals['image_128'] = defaults['image_128']
- tools.image_resize_images(vals)
# Create channel and alias
channel = super(Channel, self.with_context(
alias_model_name=self._name, alias_parent_model_name=self._name, mail_create_nolog=True, mail_create_nosubscribe=True)
@@ -250,7 +238,6 @@ class Channel(models.Model):
if not self.env.user.has_group('base.group_system'):
raise UserError("You do not possess the rights to modify fields related to moderation on one of the channels you are modifying.")
- tools.image_resize_images(vals)
result = super(Channel, self).write(vals)
if vals.get('group_ids'):
diff --git a/addons/mail/static/src/js/models/threads/channel.js b/addons/mail/static/src/js/models/threads/channel.js
index 17d9453697a..83a0a259e94 100644
--- a/addons/mail/static/src/js/models/threads/channel.js
+++ b/addons/mail/static/src/js/models/threads/channel.js
@@ -220,7 +220,7 @@ var Channel = SearchableThread.extend(ThreadTypingMixin, {
getPreview: function () {
var result = this._super.apply(this, arguments);
if (!this.isTwoUserThread()) {
- result.imageSRC = '/web/image/mail.channel/' + this.getID() + '/image_64';
+ result.imageSRC = '/web/image/mail.channel/' + this.getID() + '/image_128';
}
var lastMessage = this.getLastMessage();
return _.extend(result, {
diff --git a/addons/mail/views/mail_channel_views.xml b/addons/mail/views/mail_channel_views.xml
index 1fcd1c3ab58..7667d2b47fe 100644
--- a/addons/mail/views/mail_channel_views.xml
+++ b/addons/mail/views/mail_channel_views.xml
@@ -94,7 +94,7 @@
</button>
</div>
<div class="oe_button_box" name="button_box"/>
- <field name="image" widget="image" class="oe_avatar" options="{'preview_image': 'image_128', 'size': [90, 90]}"/>
+ <field name="image_128" widget="image" class="oe_avatar" options="{'size': [90, 90]}"/>
<div class="oe_title">
<div class="oe_edit_only">
<label for="name"/>