[IMP] mail: remove default logo
Many templates use the company logo that is set by default on database creation. As that logo is clearly a placeholder and the user isn't necesserely prompted to update it. It's possible for a user to inadvertently start sending emails with "your logo" placeholders plastered all over. This removes the default logo of the company and removes it from templates conditionally. The logo isn't simply replaced with a transparent PNG as the templates set a fixed height for the logo, which would look weird. task-3067315 Part-of: odoo/odoo#106307
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<span style="font-size: 20px; font-weight: bold;">
|
||||
<t t-out="object.name or ''">Marc Demo</t>
|
||||
</span>
|
||||
</td><td valign="middle" align="right">
|
||||
</td><td valign="middle" align="right" t-if="not object.company_id.uses_default_logo">
|
||||
<img t-attf-src="/logo.png?company={{ object.company_id.id }}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="object.company_id.name"/>
|
||||
</td></tr>
|
||||
<tr><td colspan="2" style="text-align:center;">
|
||||
@@ -118,7 +118,7 @@
|
||||
<span style="font-size: 20px; font-weight: bold;">
|
||||
<t t-out="object.name or ''">Marc Demo</t>
|
||||
</span>
|
||||
</td><td valign="middle" align="right">
|
||||
</td><td valign="middle" align="right" t-if="not object.company_id.uses_default_logo">
|
||||
<img t-attf-src="/logo.png?company={{ object.company_id.id }}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="object.company_id.name"/>
|
||||
</td></tr>
|
||||
<tr><td colspan="2" style="text-align:center;">
|
||||
@@ -266,7 +266,7 @@
|
||||
<span style="font-size: 20px; font-weight: bold;">
|
||||
<t t-out="object.name or ''">Marc Demo</t>
|
||||
</span>
|
||||
</td><td valign="middle" align="right">
|
||||
</td><td valign="middle" align="right" t-if="not object.company_id.uses_default_logo">
|
||||
<img t-attf-src="/logo.png?company={{ object.company_id.id }}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="object.company_id.name"/>
|
||||
</td></tr>
|
||||
<tr><td colspan="2" style="text-align:center;">
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
View Event
|
||||
</a>
|
||||
</t>
|
||||
<t t-else="">
|
||||
<t t-elif="not object.company_id.uses_default_logo">
|
||||
<img t-att-src="'/logo.png?company=%s' % object.company_id.id" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="'%s' % object.company_id.name"/>
|
||||
</t>
|
||||
</td></tr>
|
||||
@@ -290,7 +290,7 @@
|
||||
View Event
|
||||
</a>
|
||||
</t>
|
||||
<t t-else="">
|
||||
<t t-elif="not object.company_id.uses_default_logo">
|
||||
<img t-att-src="'/logo.png?company=%s' % object.company_id.id" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="'%s' % object.company_id.name"/>
|
||||
</t>
|
||||
</td></tr>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<tr><td valign="middle">
|
||||
<span style="font-size: 10px;">Your Badge</span><br/>
|
||||
<span style="font-size: 20px; font-weight: bold;" t-out="object.badge_id.name or ''"></span>
|
||||
</td><td valign="middle" align="right">
|
||||
</td><td valign="middle" align="right" t-if="not object.user_id.company_id.uses_default_logo">
|
||||
<img t-attf-src="/logo.png?company={{ object.user_id.company_id.id }}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="object.user_id.company_id.name"/>
|
||||
</td></tr>
|
||||
<tr><td colspan="2" style="text-align:center;">
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
|
||||
<template id="hr_expense_template_register_no_user">
|
||||
<div style="background:#F0F0F0;color:#515166;padding:10px 0px;font-family:Arial,Helvetica,sans-serif;font-size:14px;">
|
||||
<table style="width:600px;margin:5px auto;">
|
||||
<table style="width:600px;margin:5px auto;" t-if="not expense.employee_id.company_id.uses_default_logo">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="/"><img src="/web/binary/company_logo" style="vertical-align:baseline;max-width:100px;" /></a></td>
|
||||
<td><a href="/"><img t-attf-src="/logo.png?company={{ expense.employee_id.company_id.id }}" style="vertical-align:baseline;max-width:100px;max-height:50px;" /></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<span style="font-size: 20px; font-weight: bold;">
|
||||
<t t-esc="company.name"/>
|
||||
</span>
|
||||
</td><td valign="middle" align="right">
|
||||
</td><td valign="middle" align="right" t-if="not company.uses_default_logo">
|
||||
<img t-att-src="'/logo.png?company=%s' % company.id" style="padding: 0px; margin: 0px; height: 48px;" t-att-alt="'%s' % company.name"/>
|
||||
</td></tr>
|
||||
<tr><td colspan="2" style="text-align:center;">
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
|
||||
<tr><td valign="middle">
|
||||
<span style="font-size: 10px;">Lunch Order</span><br/>
|
||||
</td><td valign="middle" align="right">
|
||||
</td><td valign="middle" align="right" t-if="not user.company_id.uses_default_logo">
|
||||
<img t-attf-src="/logo.png?company={{ user.company_id.id }}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="user.company_id.name"/>
|
||||
</td></tr>
|
||||
<tr><td colspan="2" style="text-align:center;">
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
<table role="presentation" cellspacing="0" cellpadding="0" border="0" style="width: 100%; margin-top: 5px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="center">
|
||||
<img t-att-src="'/logo.png?company=%s' % (company.id or 0)" style="padding: 0px; margin: 0px; height: auto; max-width: 200px; max-height: 36px;" t-att-alt="'%s' % company.name"/>
|
||||
<td valign="center" t-if="company and not company.uses_default_logo">
|
||||
<img t-att-src="'/logo.png?company=%s' % company.id" style="padding: 0px; margin: 0px; height: auto; max-width: 200px; max-height: 36px;" t-att-alt="'%s' % company.name"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -138,8 +138,8 @@
|
||||
<t t-out="message.record_name and message.record_name.replace('/','-') or ''"/>
|
||||
</span>
|
||||
</t>
|
||||
</td><td valign="middle" align="right">
|
||||
<img t-att-src="'/logo.png?company=%s' % (company.id or 0)" style="padding: 0px; margin: 0px; height: 48px;" t-att-alt="'%s' % company.name"/>
|
||||
</td><td valign="middle" align="right" t-if="company and not company.uses_default_logo">
|
||||
<img t-att-src="'/logo.png?company=%s' % company.id" style="padding: 0px; margin: 0px; height: 48px;" t-att-alt="'%s' % company.name"/>
|
||||
</td></tr>
|
||||
<tr><td colspan="2" style="text-align:center;">
|
||||
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:4px 0px 32px 0px;"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<tr><td valign="middle">
|
||||
<span style="font-size: 10px;">Your Account</span><br/>
|
||||
<span style="font-size: 20px; font-weight: bold;" t-out="object.user_id.name or ''">Marc Demo</span>
|
||||
</td><td valign="middle" align="right">
|
||||
</td><td valign="middle" align="right" t-if="not object.user_id.company_id.uses_default_logo">
|
||||
<img t-attf-src="/logo.png?company={{ object.user_id.company_id.id }}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="object.user_id.company_id.name"/>
|
||||
</td></tr>
|
||||
<tr><td colspan="2" style="text-align:center;">
|
||||
|
||||
@@ -58,7 +58,9 @@
|
||||
<tbody>
|
||||
<tr><td>
|
||||
<!-- We use the logo of the company that created the survey (to handle multi company cases) -->
|
||||
<a href="/"><img t-attf-src="/logo.png?company={{ object.survey_id.create_uid.company_id.id }}" style="vertical-align:baseline;max-width:100px;" /></a>
|
||||
<a href="/"><img t-if="not object.survey_id.create_uid.company_id.uses_default_logo"
|
||||
t-attf-src="/logo.png?company={{ object.survey_id.create_uid.company_id.id }}"
|
||||
style="vertical-align:baseline;max-width:100px;" /></a>
|
||||
</td><td style="text-align:right;vertical-align:middle;">
|
||||
Certification: <t t-out="object.survey_id.display_name or ''">Feedback Form</t>
|
||||
</td></tr>
|
||||
|
||||
@@ -357,7 +357,7 @@ class Website(models.Model):
|
||||
'module_state': feature.module_id.state,
|
||||
} for feature in configurator_features]
|
||||
r['logo'] = False
|
||||
if company.logo and company.logo != company._get_logo():
|
||||
if not company.uses_default_logo:
|
||||
r['logo'] = company.logo.decode('utf-8')
|
||||
try:
|
||||
result = self._website_api_rpc('/api/website/1/configurator/industries', {'lang': self.env.context.get('lang')})
|
||||
@@ -543,7 +543,7 @@ class Website(models.Model):
|
||||
'res_field': 'logo',
|
||||
'res_id': website.id,
|
||||
})
|
||||
elif not logo_attachment_id and company.logo and company.logo != company._get_logo():
|
||||
elif not logo_attachment_id and not company.uses_default_logo:
|
||||
website.logo = company.logo.decode('utf-8')
|
||||
|
||||
# palette
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
|
||||
<tr><td valign="middle">
|
||||
<span style="font-size: 10px;">Your leads</span><br/>
|
||||
</td><td valign="middle" align="right">
|
||||
</td><td valign="middle" align="right" t-if="not user.company_id.uses_default_logo">
|
||||
<img t-attf-src="/logo.png?company={{ user.company_id.id }}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="user.company_id.name"/>
|
||||
</td></tr>
|
||||
<tr><td colspan="2" style="text-align:center;">
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<t t-out="object.company_id.name or ''">YourCompany</t> Profile validation
|
||||
</span>
|
||||
</td>
|
||||
<td valign="middle" align="right">
|
||||
<td t-if="not user.company_id.uses_default_logo" valign="middle" align="right">
|
||||
<img t-attf-src="/logo.png?company={{ user.company_id.id }}" style="padding: 0px; margin: 0px; height: auto; width: 80px;" t-att-alt="user.company_id.name"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
<span style="font-size: 20px; font-weight: bold;">
|
||||
<t t-esc="message.record_name and message.record_name.replace('/','-') or ''"/>
|
||||
</span>
|
||||
</td><td valign="middle" align="right">
|
||||
<img t-att-src="'/logo.png?company=%s' % (company.id or 0)" style="padding: 0px; margin: 0px; height: 48px;" t-att-alt="'%s' % company.name"/>
|
||||
</td><td valign="middle" align="right" t-if="company and not company.uses_default_logo">
|
||||
<img t-att-src="'/logo.png?company=%s' % company.id" style="padding: 0px; margin: 0px; height: 48px;" t-att-alt="'%s' % company.name"/>
|
||||
</td></tr>
|
||||
<tr><td colspan="2" style="text-align:center;">
|
||||
<hr width="100%" style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0; margin:4px 0px 32px 0px;"/>
|
||||
|
||||
@@ -10,6 +10,7 @@ import warnings
|
||||
from odoo import api, fields, models, tools, _, Command
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
from odoo.modules.module import get_resource_path
|
||||
from odoo.tools import file_open
|
||||
from random import randrange
|
||||
from PIL import Image
|
||||
|
||||
@@ -25,7 +26,8 @@ class Company(models.Model):
|
||||
raise UserError(_('Duplicating a company is not allowed. Please create a new company instead.'))
|
||||
|
||||
def _get_logo(self):
|
||||
return base64.b64encode(open(os.path.join(tools.config['root_path'], 'addons', 'base', 'static', 'img', 'res_company_logo.png'), 'rb') .read())
|
||||
with file_open('base/static/img/res_company_logo.png', 'rb') as file:
|
||||
return base64.b64encode(file.read())
|
||||
|
||||
def _default_currency_id(self):
|
||||
return self.env.user.company_id.currency_id
|
||||
@@ -43,6 +45,7 @@ class Company(models.Model):
|
||||
# logo_web: do not store in attachments, since the image is retrieved in SQL for
|
||||
# performance reasons (see addons/web/controllers/main.py, Binary.company_logo)
|
||||
logo_web = fields.Binary(compute='_compute_logo_web', store=True, attachment=False)
|
||||
uses_default_logo = fields.Boolean(compute='_compute_uses_default_logo', store=True)
|
||||
currency_id = fields.Many2one('res.currency', string='Currency', required=True, default=lambda self: self._default_currency_id())
|
||||
user_ids = fields.Many2many('res.users', 'res_company_users_rel', 'cid', 'user_id', string='Accepted Users')
|
||||
street = fields.Char(compute='_compute_address', inverse='_inverse_street')
|
||||
@@ -131,6 +134,12 @@ class Company(models.Model):
|
||||
img = company.partner_id.image_1920
|
||||
company.logo_web = img and base64.b64encode(tools.image_process(base64.b64decode(img), size=(180, 0)))
|
||||
|
||||
@api.depends('partner_id.image_1920')
|
||||
def _compute_uses_default_logo(self):
|
||||
default_logo = self._get_logo()
|
||||
for company in self:
|
||||
company.uses_default_logo = not company.logo or company.logo == default_logo
|
||||
|
||||
@api.onchange('state_id')
|
||||
def _onchange_state(self):
|
||||
if self.state_id.country_id:
|
||||
|
||||
@@ -38,3 +38,15 @@ class TestCompany(TransactionCase):
|
||||
'company_ids': main_company.ids,
|
||||
})
|
||||
user.action_unarchive()
|
||||
|
||||
def test_logo_check(self):
|
||||
"""Ensure uses_default_logo is properly (re-)computed."""
|
||||
company = self.env['res.company'].create({'name': 'foo'})
|
||||
|
||||
self.assertTrue(company.logo, 'Should have a default logo')
|
||||
self.assertTrue(company.uses_default_logo)
|
||||
company.partner_id.image_1920 = False
|
||||
# No logo means we fall back to another default logo for the website route -> uses_default
|
||||
self.assertTrue(company.uses_default_logo)
|
||||
company.partner_id.image_1920 = "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
|
||||
self.assertFalse(company.uses_default_logo)
|
||||
|
||||
Reference in New Issue
Block a user