[REF] base: Remove res.company favicon field
This commit simply removes the res.company favicon field and every related code because the feature is obsolete closes odoo/odoo#116367 Related: odoo/upgrade#4469 Signed-off-by: Pierre Paridans (app) <app@odoo.com>
This commit is contained in:
@@ -63,11 +63,4 @@ export async function startWebClient(Webclient) {
|
||||
// delete odoo.debug; // FIXME: some legacy code rely on this
|
||||
odoo.__WOWL_DEBUG__ = { root };
|
||||
odoo.isReady = true;
|
||||
|
||||
// Update Favicons
|
||||
const favicon = `/web/image/res.company/${env.services.company.currentCompany.id}/favicon`;
|
||||
const icons = document.querySelectorAll("link[rel*='icon']");
|
||||
for (const icon of icons) {
|
||||
icon.href = favicon;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
<field name="name">My Company</field>
|
||||
<field name="partner_id" ref="main_partner"/>
|
||||
<field name="currency_id" ref="base.USD"/>
|
||||
<field name="favicon" model="res.company" eval="obj()._get_default_favicon(original=True)"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -30,32 +30,6 @@ class Company(models.Model):
|
||||
def _default_currency_id(self):
|
||||
return self.env.user.company_id.currency_id
|
||||
|
||||
def _get_default_favicon(self, original=False):
|
||||
img_path = get_resource_path('web', 'static/img/favicon.ico')
|
||||
with tools.file_open(img_path, 'rb') as f:
|
||||
if original:
|
||||
return base64.b64encode(f.read())
|
||||
# Modify the source image to add a colored bar on the bottom
|
||||
# This could seem overkill to modify the pixels 1 by 1, but
|
||||
# Pillow doesn't provide an easy way to do it, and this
|
||||
# is acceptable for a 16x16 image.
|
||||
color = (randrange(32, 224, 24), randrange(32, 224, 24), randrange(32, 224, 24))
|
||||
original = Image.open(f)
|
||||
new_image = Image.new('RGBA', original.size)
|
||||
height = original.size[1]
|
||||
width = original.size[0]
|
||||
bar_size = 1
|
||||
for y in range(height):
|
||||
for x in range(width):
|
||||
pixel = original.getpixel((x, y))
|
||||
if height - bar_size <= y + 1 <= height:
|
||||
new_image.putpixel((x, y), (color[0], color[1], color[2], 255))
|
||||
else:
|
||||
new_image.putpixel((x, y), (pixel[0], pixel[1], pixel[2], pixel[3]))
|
||||
stream = io.BytesIO()
|
||||
new_image.save(stream, format="ICO")
|
||||
return base64.b64encode(stream.getvalue())
|
||||
|
||||
name = fields.Char(related='partner_id.name', string='Company Name', required=True, store=True, readonly=False)
|
||||
active = fields.Boolean(default=True)
|
||||
sequence = fields.Integer(help='Used to order Companies in the company switcher', default=10)
|
||||
@@ -91,7 +65,6 @@ class Company(models.Model):
|
||||
external_report_layout_id = fields.Many2one('ir.ui.view', 'Document Template')
|
||||
base_onboarding_company_state = fields.Selection([
|
||||
('not_done', "Not done"), ('just_done', "Just done"), ('done', "Done")], string="State of the onboarding company step", default='not_done')
|
||||
favicon = fields.Binary(string="Company Favicon", help="This field holds the image used to display a favicon for a given company.", default=_get_default_favicon)
|
||||
font = fields.Selection([("Lato", "Lato"), ("Roboto", "Roboto"), ("Open_Sans", "Open Sans"), ("Montserrat", "Montserrat"), ("Oswald", "Oswald"), ("Raleway", "Raleway"), ('Tajawal', 'Tajawal')], default="Lato")
|
||||
primary_color = fields.Char()
|
||||
secondary_color = fields.Char()
|
||||
@@ -198,10 +171,6 @@ class Company(models.Model):
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
# add default favicon
|
||||
for vals in vals_list:
|
||||
if not vals.get('favicon'):
|
||||
vals['favicon'] = self._get_default_favicon()
|
||||
|
||||
# create missing partners
|
||||
no_partner_vals_list = [
|
||||
|
||||
@@ -20,7 +20,7 @@ class Partner(models.Model):
|
||||
# Activate currency to avoid fail iterator
|
||||
(self.env.ref('base.USD') | self.env.ref('base.EUR')).active = True
|
||||
|
||||
# remaining: paperformat_id, parent_id, partner_id, favicon, font, report_header, external_report_layout_id, report_footer
|
||||
# remaining: paperformat_id, parent_id, partner_id, font, report_header, external_report_layout_id, report_footer
|
||||
def get_name(values=None, counter=0, **kwargs):
|
||||
return 'company_%s_%s' % (counter, self.env['res.currency'].browse(values['currency_id']).name)
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
<field name="website" string="Website" widget="url" placeholder="e.g. https://www.odoo.com"/>
|
||||
<field name="parent_id" groups="base.group_multi_company"/>
|
||||
<field name="sequence" invisible="1"/>
|
||||
<field name="favicon" widget="image" class="float-start oe_avatar" groups="base.group_no_one"/>
|
||||
</group>
|
||||
<group name="social_media"/>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user