mirror of https://github.com/OCA/web.git
Fix according to review comments.
parent
390f078636
commit
08bb9053ef
|
@ -2,9 +2,9 @@
|
||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
|
|
||||||
=====================================
|
=================================================
|
||||||
Web Widget - Email internal mail link
|
Web Widget - Internal mail wizard for email links
|
||||||
=====================================
|
=================================================
|
||||||
|
|
||||||
This module was written to provide a new widget for Email fields to replace the
|
This module was written to provide a new widget for Email fields to replace the
|
||||||
standard behaviour of displaying a 'mailto:' link with JS to open the internal
|
standard behaviour of displaying a 'mailto:' link with JS to open the internal
|
||||||
|
@ -54,4 +54,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.
|
promote its widespread use.
|
||||||
|
|
||||||
To contribute to this module, please visit http://odoo-community.org.
|
To contribute to this module, please visit https://odoo-community.org.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Web Widget - Email internal mail link',
|
'name': 'Web Widget - Internal mail wizard for email links',
|
||||||
'summary': 'Send mail using internal composition wizard.',
|
'summary': 'Send mail using internal composition wizard.',
|
||||||
'version': '8.0.1.0.0',
|
'version': '8.0.1.0.0',
|
||||||
'category': 'Social Network',
|
'category': 'Social Network',
|
||||||
|
@ -14,7 +14,6 @@
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
'depends': [
|
'depends': [
|
||||||
'web',
|
|
||||||
'mail',
|
'mail',
|
||||||
],
|
],
|
||||||
'data': [
|
'data': [
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<openerp>
|
<openerp>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<template id="assets_backend" name="custom bar assets" inherit_id="web.assets_backend">
|
<template id="assets_backend" inherit_id="web.assets_backend">
|
||||||
<xpath expr="." position="inside">
|
<xpath expr="." position="inside">
|
||||||
<link rel="stylesheet" href="/web_widget_mail_send_odoo/static/src/css/web_widget_mail_send_odoo.css"/>
|
<link rel="stylesheet" href="/web_widget_mail_send_odoo/static/src/css/web_widget_mail_send_odoo.css"/>
|
||||||
<script type="text/javascript" src="/web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js"/>
|
<script type="text/javascript" src="/web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js"/>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
.openerp .oe_form .oe_form_field_email_intern input,
|
.openerp .oe_form .oe_form_field_email_internal input,
|
||||||
|
|
|
@ -2,90 +2,88 @@
|
||||||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
openerp.web_widget_mail_send_odoo = function(instance) {
|
||||||
|
|
||||||
var instance = openerp;
|
var _t = instance.web._t,
|
||||||
var _t = instance.web._t,
|
_lt = instance.web._lt;
|
||||||
_lt = instance.web._lt;
|
var QWeb = instance.web.qweb;
|
||||||
var QWeb = instance.web.qweb;
|
|
||||||
|
|
||||||
instance.web.form.FieldEmailIntern = instance.web.form.FieldChar.extend({
|
instance.web.form.FieldEmailIntern = instance.web.form.FieldChar.extend({
|
||||||
template: 'FieldEmailIntern',
|
template: 'FieldEmailIntern',
|
||||||
initialize_content: function() {
|
initialize_content: function() {
|
||||||
this._super();
|
this._super();
|
||||||
var $button = this.$el.find('a');
|
var $button = this.$('a');
|
||||||
$button.click(this.on_clicked);
|
$button.click(this.on_clicked);
|
||||||
this.setupFocus($button);
|
this.setupFocus($button);
|
||||||
},
|
},
|
||||||
render_value: function() {
|
render_value: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (!this.get("effective_readonly")) {
|
if (!this.get("effective_readonly")) {
|
||||||
self._super();
|
self._super();
|
||||||
} else {
|
} else {
|
||||||
self.$el.find('a')
|
self.$el.find('a')
|
||||||
.removeAttr('href')
|
.removeAttr('href')
|
||||||
.removeAttr('target')
|
.removeAttr('target')
|
||||||
.text(self.get('value') || '');
|
.text(self.get('value') || '');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
on_clicked: function() {
|
on_clicked: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (!self.get('value') || !self.is_syntax_valid()) {
|
if (!self.get('value') || !self.is_syntax_valid()) {
|
||||||
self.do_warn(_t("E-mail Error"), _t("Can't send email to invalid e-mail address"));
|
self.do_warn(_t("E-mail Error"), _t("Can't send email to invalid e-mail address"));
|
||||||
} else {
|
} else {
|
||||||
// find partner id for email
|
// find partner id for email
|
||||||
var res_partner = new openerp.Model('res.partner');
|
var res_partner = new openerp.Model('res.partner');
|
||||||
var parsed_email = instance.mail.ChatterUtils.parse_email(self.get('value'));
|
var parsed_email = instance.mail.ChatterUtils.parse_email(self.get('value'));
|
||||||
res_partner.query(['id'])
|
res_partner.query(['id'])
|
||||||
.filter([['email', '=', parsed_email[1]]])
|
.filter([['email', '=', parsed_email[1]]])
|
||||||
.first().then(function(partner){
|
.first().then(function(partner){
|
||||||
if(partner){
|
if(partner){
|
||||||
var fm = self.field_manager
|
var fm = self.field_manager
|
||||||
self.do_action(
|
self.do_action(
|
||||||
'mail.action_email_compose_message_wizard', {
|
'mail.action_email_compose_message_wizard', {
|
||||||
additional_context: {
|
additional_context: {
|
||||||
default_partner_ids: [partner.id],
|
default_partner_ids: [partner.id],
|
||||||
default_composition_mode: 'comment',
|
default_composition_mode: 'comment',
|
||||||
// write to active model:
|
// write to active model:
|
||||||
default_model: fm.dataset._model.name,
|
default_model: fm.dataset._model.name,
|
||||||
default_res_id: fm.datarecord.id,
|
default_res_id: fm.datarecord.id,
|
||||||
},
|
},
|
||||||
on_close: function(){
|
on_close: function(){
|
||||||
// refresh the chatter widget here
|
// refresh the chatter widget here
|
||||||
$.each(self.view.getChildren(),
|
$.each(self.view.getChildren(),
|
||||||
function(index, value){
|
function(index, value){
|
||||||
if(value.widget=='mail_thread'){
|
if(value.widget=='mail_thread'){
|
||||||
value.root.thread.message_fetch()
|
value.root.thread.message_fetch()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
},
|
||||||
},
|
}
|
||||||
}
|
);
|
||||||
);
|
} else {
|
||||||
} else {
|
console.log(self.build_context());
|
||||||
console.log(self.build_context());
|
var pop = new instance.web.form.FormOpenPopup(self);
|
||||||
var pop = new instance.web.form.FormOpenPopup(self);
|
var context = new instance.web.CompoundContext(self.build_context(), {
|
||||||
var context = new instance.web.CompoundContext(self.build_context(), {
|
default_name: parsed_email[0],
|
||||||
default_name: parsed_email[0],
|
default_email: parsed_email[1],
|
||||||
default_email: parsed_email[1],
|
});
|
||||||
});
|
pop.show_element(
|
||||||
pop.show_element(
|
'res.partner',
|
||||||
'res.partner',
|
false,
|
||||||
false,
|
context,
|
||||||
context,
|
{
|
||||||
{
|
title: _t("Please complete partner's information."),
|
||||||
title: _t("Please complete partner's information."),
|
}
|
||||||
}
|
);
|
||||||
);
|
pop.on('create_completed', self, function (id) {
|
||||||
pop.on('create_completed', self, function (id) {
|
self.on_clicked()
|
||||||
self.on_clicked()
|
});
|
||||||
});
|
}
|
||||||
}
|
})
|
||||||
})
|
}
|
||||||
}
|
},
|
||||||
},
|
});
|
||||||
});
|
|
||||||
|
|
||||||
instance.web.form.widgets.add('email', 'instance.web.form.FieldEmailIntern')
|
instance.web.form.widgets.add('email', 'instance.web.form.FieldEmailIntern')
|
||||||
|
}
|
||||||
})()
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<templates>
|
<templates>
|
||||||
<t t-name="FieldEmailIntern" t-extend="FieldEmail">
|
<t t-name="FieldEmailIntern" t-extend="FieldEmail">
|
||||||
<t t-jquery="span:first">
|
<t t-jquery="span:first">
|
||||||
this.removeClass('oe_form_field_email').addClass('oe_form_field_email_intern');
|
this.removeClass('oe_form_field_email').addClass('oe_form_field_email_internal');
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
</templates>
|
</templates>
|
||||||
|
|
Loading…
Reference in New Issue