Skip to content
Permalink
Browse files

[IMP] base,web,website: user can set independent logo for company, we…

…bsite and report

		       - current behaviour before this commit, when user change the logo from website side it is also change the logo of company
		       - in this commit, by default logo of website and report display as set on company
                       - if user change the logo from website/report side it will not change the logo of company
                       - user can set different logo to display for website, report and company
  • Loading branch information...
rop-odoo committed Apr 16, 2019
1 parent defbb16 commit 2ded8836980cf85e784d6002a43aa5d3d77f684b
@@ -143,7 +143,7 @@
<div class="float-right">
<h3 class="mt0 text-right" t-field="company.report_header"/>
</div>
<img t-if="company.logo" t-att-src="image_data_uri(company.logo)" class="float-left" alt="Logo"/>
<img t-if="company.report_display_logo" t-att-src="image_data_uri(company.report_display_logo)" class="float-left" alt="Logo"/>
<div class="float-left company_address">
<div>
<strong t-field="company.partner_id.name"/>
@@ -184,7 +184,7 @@
<div class="o_boxed_header">
<div class="row mb8">
<div class="col-6">
<img t-if="company.logo" t-att-src="image_data_uri(company.logo)" alt="Logo"/>
<img t-if="company.report_display_logo" t-att-src="image_data_uri(company.report_display_logo)" alt="Logo"/>
</div>
<div class="col-6 text-right mb4">
<h4 class="mt0" t-field="company.report_header"/>
@@ -223,7 +223,7 @@
<div class="o_clean_header">
<div class="row">
<div class="col-6">
<img t-if="company.logo" t-att-src="image_data_uri(company.logo)" alt="Logo"/>
<img t-if="company.report_display_logo" t-att-src="image_data_uri(company.report_display_logo)" alt="Logo"/>
</div>
<div class="col-5 offset-1" name="company_address">
<ul class="list-unstyled">
@@ -268,11 +268,11 @@
<div class="header">
<div class="row">
<div class="col-3 mb4">
<img t-if="company.logo" t-att-src="image_data_uri(company.logo)" style="max-height: 45px;" alt="Logo"/>
<img t-if="company.report_display_logo" t-att-src="image_data_uri(company.report_display_logo)" style="max-height: 45px;" alt="Logo"/>
</div>
<div class="col-9 text-right" style="margin-top:22px;" t-field="company.report_header" name="moto"/>
</div>
<div t-if="company.logo or company.report_header" class="row zero_min_height">
<div t-if="company.report_display_logo or company.report_header" class="row zero_min_height">
<div class="col-12">
<div style="border-bottom: 1px solid black;"/>
</div>
@@ -108,6 +108,8 @@ def _default_social_twitter(self):
('b2b', 'On invitation'),
('b2c', 'Free sign up'),
], string='Customer Account', default='b2b')
display_logo = fields.Binary(compute='_compute_display_logo', inverse='_inverse_display_logo')
logo = fields.Binary()

@api.onchange('language_ids')
def _onchange_language_ids(self):
@@ -120,6 +122,14 @@ def _compute_menu(self):
for website in self:
website.menu_id = Menu.search([('parent_id', '=', False), ('website_id', '=', website.id)], order='id', limit=1).id

def _compute_display_logo(self):
for website in self:
website.display_logo = website.logo if website.logo else website.company_id.logo

def _inverse_display_logo(self):
for website in self:
website.logo = website.display_logo

@api.model
def create(self, vals):
if 'user_id' not in vals:
@@ -324,7 +324,7 @@
<template id="layout_logo_show" inherit_id="website.layout" name="Show Logo">
<xpath expr="//header//a[hasclass('navbar-brand')]" position="replace">
<a href="/" class="navbar-brand logo">
<span t-field="res_company.logo" t-options="{'widget': 'image'}" role="img" t-att-aria-label="'Logo of %s' % res_company.name" t-att-title="res_company.name" />
<span t-field="website.display_logo" t-options="{'widget': 'image'}" role="img" t-att-aria-label="'Logo of %s' % website.name" t-att-title="website.name" />
</a>
</xpath>
</template>
@@ -25,6 +25,7 @@
<field name="arch" type="xml">
<form string="Website Settings">
<sheet>
<field name="display_logo" widget="image" class="oe_avatar"/>
<div name="domain">
<group name="domain">
<field name="name"/>
@@ -40,6 +40,8 @@ def _get_user_currency(self):
# 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)
report_display_logo = fields.Binary(string="Report Logo", compute='_compute_report_display_logo', inverse='_inverse_report_display_logo')
report_logo = fields.Binary(string="Report Logo Store")
currency_id = fields.Many2one('res.currency', string='Currency', required=True, default=lambda self: self._get_user_currency())
user_ids = fields.Many2many('res.users', 'res_company_users_rel', 'cid', 'user_id', string='Accepted Users')
account_no = fields.Char(string='Account No.')
@@ -122,6 +124,14 @@ def _compute_logo_web(self):
for company in self:
company.logo_web = tools.image_resize_image(company.partner_id.image, (180, None))

def _compute_report_display_logo(self):
for company in self:
company.report_display_logo = company.report_logo if company.report_logo else company.logo

def _inverse_report_display_logo(self):
for company in self:
company.report_logo = company.report_display_logo

@api.onchange('state_id')
def _onchange_state(self):
self.country_id = self.state_id.country_id
@@ -183,7 +183,7 @@
}"/>
</group>
<group>
<field name="logo" widget="image" style="width: 50%"/>
<field name="report_display_logo" widget="image" style="width: 50%"/>
<field name="report_header" widget="char"
placeholder="e.g. Global Business Solutions" />
<field name="report_footer" string="Footer"

0 comments on commit 2ded883

Please sign in to comment.
You can’t perform that action at this time.