mirror of https://github.com/OCA/web.git
[MIG] support_branding migration to 10
parent
b2998d6be4
commit
f0673e698c
|
@ -69,6 +69,7 @@ Contributors
|
||||||
|
|
||||||
* Holger Brunn <hbrunn@therp.nl>
|
* Holger Brunn <hbrunn@therp.nl>
|
||||||
* Stefan Rijnhart <srijnhart@therp.nl>
|
* Stefan Rijnhart <srijnhart@therp.nl>
|
||||||
|
* Robert Rottermann <robert@redo2oo.ch>
|
||||||
|
|
||||||
Icon
|
Icon
|
||||||
----
|
----
|
||||||
|
|
|
@ -1,28 +1,14 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
# Copyright 2012-2015 Therp BV (<http://therp.nl>)
|
||||||
#
|
# Copyright 2016 - Tecnativa - Angel Moya <odoo@tecnativa.com>
|
||||||
# OpenERP, Open Source Management Solution
|
# Copyright 2017 - redO2oo - Robert Rottermann <robert@redO2oo.ch>
|
||||||
# This module copyright (C) 2012-2015 Therp BV (<http://therp.nl>).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
{
|
{
|
||||||
"name": "Support branding",
|
"name": "Support branding",
|
||||||
"summary": "Adds your branding to an Odoo instance",
|
"summary": "Adds your branding to an Odoo instance",
|
||||||
"category": "Dependecy/Hidden",
|
"category": "Dependecy/Hidden",
|
||||||
"version": "8.0.2.0.0",
|
"version": "10.0.1.0.0",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"author": "Therp BV,Odoo Community Association (OCA)",
|
"author": "Therp BV,Odoo Community Association (OCA)",
|
||||||
"website": 'http://therp.nl',
|
"website": 'http://therp.nl',
|
||||||
|
@ -36,5 +22,5 @@
|
||||||
"data/ir_config_parameter.xml",
|
"data/ir_config_parameter.xml",
|
||||||
'views/qweb.xml',
|
'views/qweb.xml',
|
||||||
],
|
],
|
||||||
'installable': False,
|
'installable': True,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,73 +1,56 @@
|
||||||
/*
|
|
||||||
|
|
||||||
Copyright (C) 2012-2015 Therp BV
|
/* Copyright 2012-2015 Therp
|
||||||
License: GNU AFFERO GENERAL PUBLIC LICENSE
|
* Copyright 2016 - Tecnativa - Angel Moya <odoo@tecnativa.com>
|
||||||
Version 3 or any later version
|
* Copyright 2017 - redO2oo - Robert Rottermann <robert@redO2oo.ch>
|
||||||
|
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
|
||||||
|
|
||||||
Usage: if you run an OpenERP support company and you support
|
odoo.define('web.support_branding', function(require) {
|
||||||
customers without an OPW, you can brand the OpenERP instance
|
var CrashManager = require('web.CrashManager');
|
||||||
accordingly using this module. Please enter the two variables
|
var core = require('web.core');
|
||||||
in the code below, 'support_name' and 'support_link'. They will
|
var Model = require('web.Model');
|
||||||
replace the unfriendly message about the OpenERP instance not
|
var _t = core._t;
|
||||||
being supported.
|
CrashManager.include({
|
||||||
|
init: function() {
|
||||||
*/
|
|
||||||
|
|
||||||
openerp.support_branding = function(instance) {
|
|
||||||
var QWeb = instance.web.qweb,
|
|
||||||
_t = instance.web._t;
|
|
||||||
|
|
||||||
instance.web.CrashManager.include({
|
|
||||||
init: function()
|
|
||||||
{
|
|
||||||
var self = this,
|
var self = this,
|
||||||
ir_config_parameter = new openerp.web.Model('ir.config_parameter');
|
ir_config_parameter = new Model('ir.config_parameter');
|
||||||
ir_config_parameter.call(
|
ir_config_parameter.call(
|
||||||
'get_param', ['support_branding.support_email']).then(
|
'get_param', ['support_branding.support_email']).then(
|
||||||
function(email)
|
function(email) {
|
||||||
{
|
|
||||||
self.support_branding_support_email = email;
|
self.support_branding_support_email = email;
|
||||||
});
|
});
|
||||||
ir_config_parameter.call(
|
ir_config_parameter.call(
|
||||||
'get_param', ['support_branding.company_name']).then(
|
'get_param', ['support_branding.company_name']).then(
|
||||||
function(name)
|
function(name) {
|
||||||
{
|
|
||||||
self.support_branding_company_name = name;
|
self.support_branding_company_name = name;
|
||||||
});
|
});
|
||||||
return this._super(this, arguments);
|
return this._super(this, arguments);
|
||||||
},
|
},
|
||||||
show_error: function(error)
|
show_error: function(error) {
|
||||||
{
|
|
||||||
var self = this;
|
var self = this;
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
jQuery('.support-branding-submit-form').each(function()
|
jQuery('.support-branding-submit-form').each(function() {
|
||||||
{
|
|
||||||
var $form = jQuery(this),
|
var $form = jQuery(this),
|
||||||
$button = $form.find('button'),
|
$button = $form.find('button'),
|
||||||
$description = $form.find('textarea[name="description"]'),
|
$description = $form.find('textarea[name="description"]'),
|
||||||
$subject = $form.find('input[name="subject"]'),
|
$subject = $form.find('input[name="subject"]'),
|
||||||
$body = $form.find('input[name="body"]');
|
$body = $form.find('input[name="body"]');
|
||||||
if(self.support_branding_support_email)
|
if (self.support_branding_support_email) {
|
||||||
{
|
|
||||||
$form.attr(
|
$form.attr(
|
||||||
'action',
|
'action',
|
||||||
'mailto:' + self.support_branding_support_email);
|
'mailto:' + self.support_branding_support_email);
|
||||||
$form.parents('.modal').find('.modal-body')
|
$form.parents('.modal').find('.modal-body')
|
||||||
.css('max-height', '70vh');
|
.css('max-height', '70vh');
|
||||||
$button.click(function(ev)
|
$button.click(function(ev) {
|
||||||
{
|
var mail_mail = new Model('mail.mail');
|
||||||
var mail_mail = new instance.web.Model('mail.mail');
|
if (!$description.val()) {
|
||||||
if(!$description.val())
|
|
||||||
{
|
|
||||||
$description.parent().addClass('oe_form_invalid');
|
$description.parent().addClass('oe_form_invalid');
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mail_mail.call(
|
mail_mail.call(
|
||||||
'create',
|
'create', [{
|
||||||
[{
|
|
||||||
state: 'outgoing',
|
state: 'outgoing',
|
||||||
auto_delete: false,
|
auto_delete: true,
|
||||||
email_to: self.support_branding_support_email,
|
email_to: self.support_branding_support_email,
|
||||||
subject: $subject.val(),
|
subject: $subject.val(),
|
||||||
body_html: jQuery('<div/>').append(
|
body_html: jQuery('<div/>').append(
|
||||||
|
@ -75,35 +58,31 @@ openerp.support_branding = function(instance) {
|
||||||
jQuery('<pre/>').text($body.val())
|
jQuery('<pre/>').text($body.val())
|
||||||
).html(),
|
).html(),
|
||||||
}])
|
}])
|
||||||
.then(function(mail_id)
|
.then(function(mail_id) {
|
||||||
{
|
return mail_mail.call('send', [
|
||||||
return mail_mail.call('send', [[mail_id]]);
|
[mail_id]
|
||||||
}, function()
|
]);
|
||||||
{
|
}, function() {
|
||||||
// if the call failed, fire the mailto link
|
// if the call failed, fire the mailto link
|
||||||
// hoping there is a properly configured email
|
// hoping there is a properly configured email
|
||||||
// client
|
// client
|
||||||
$body.val($description.val() + '\n' + $body.val())
|
$body.val($description.val() + '\n' + $body.val());
|
||||||
$button.unbind('click');
|
$button.unbind('click');
|
||||||
$button.click();
|
$button.click();
|
||||||
})
|
})
|
||||||
.then(function()
|
.then(function() {
|
||||||
{
|
|
||||||
$form.parents('.modal').modal('hide');
|
$form.parents('.modal').modal('hide');
|
||||||
});
|
});
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$description.hide();
|
$description.hide();
|
||||||
$button.hide();
|
$button.hide();
|
||||||
}
|
}
|
||||||
if(self.support_branding_company_name)
|
if (self.support_branding_company_name) {
|
||||||
{
|
|
||||||
$button.text(
|
$button.text(
|
||||||
_.str.sprintf(
|
_.str.sprintf(
|
||||||
openerp.web._t('Email to %s'),
|
_t('Email to %s'),
|
||||||
self.support_branding_company_name));
|
self.support_branding_company_name));
|
||||||
}
|
}
|
||||||
$form.prependTo(
|
$form.prependTo(
|
||||||
|
@ -111,4 +90,6 @@ openerp.support_branding = function(instance) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
// this is already instantiated, so we need to call init manually
|
||||||
|
require('web.crash_manager').init();
|
||||||
|
});
|
||||||
|
|
|
@ -1,17 +1,27 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<openerp>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
<template id="support_branding_assets" name="support_branding assets" inherit_id="web.assets_backend">
|
<template
|
||||||
|
id="support_branding_assets"
|
||||||
|
name="support_branding assets"
|
||||||
|
inherit_id="web.assets_backend">
|
||||||
<xpath expr="." position="inside">
|
<xpath expr="." position="inside">
|
||||||
<script type="text/javascript" src="/support_branding/static/src/js/support_branding.js"></script>
|
<script type="text/javascript" src="/support_branding/static/src/js/support_branding.js"></script>
|
||||||
<link rel="stylesheet" href="/support_branding/static/src/css/support_branding.css" />
|
<link rel="stylesheet" href="/support_branding/static/src/css/support_branding.css" />
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
<template id="menu_secondary" inherit_id="web.menu_secondary">
|
<template id="menu_secondary" inherit_id="web.menu_secondary">
|
||||||
<xpath expr="//div[@class='oe_footer']" position="inside">
|
<xpath expr="//div[@class='o_sub_menu_footer']" position="inside">
|
||||||
<span>, supported by <a target="_new" t-att-href="request.env['ir.config_parameter'].get_param('support_branding.company_url')" t-att-style="'color: ' + request.env['ir.config_parameter'].get_param('support_branding.company_color')"><t t-esc="request.env['ir.config_parameter'].get_param('support_branding.company_name')" /></a></span>
|
<span>, supported by
|
||||||
<div t-if="request.env['ir.config_parameter'].get_param('support_branding.release')">Version <t t-esc="request.env['ir.config_parameter'].get_param('support_branding.release')" /></div>
|
<a target="_new" t-att-href="request.env['ir.config_parameter'].get_param('support_branding.company_url')"
|
||||||
|
t-att-style="'color: ' + request.env['ir.config_parameter'].get_param('support_branding.company_color')">
|
||||||
|
<t t-esc="request.env['ir.config_parameter'].get_param('support_branding.company_name')" />
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
<div t-if="request.env['ir.config_parameter'].get_param('support_branding.release')">
|
||||||
|
Version <t t-esc="request.env['ir.config_parameter'].get_param('support_branding.release')" />
|
||||||
|
</div>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</odoo>
|
||||||
|
|
Loading…
Reference in New Issue