Browse Source
Merge pull request #279 from initOS/web-mail-send-intern
Merge pull request #279 from initOS/web-mail-send-intern
Web mail send using composition wizard instead of 'mailto:'pull/307/head
Markus Schneider
9 years ago
10 changed files with 288 additions and 0 deletions
-
57web_widget_mail_send_odoo/README.rst
-
0web_widget_mail_send_odoo/__init__.py
-
25web_widget_mail_send_odoo/__openerp__.py
-
13web_widget_mail_send_odoo/assets.xml
-
39web_widget_mail_send_odoo/i18n/de.po
-
38web_widget_mail_send_odoo/i18n/web_widget_mail_send_odoo.pot
-
BINweb_widget_mail_send_odoo/static/description/icon.png
-
1web_widget_mail_send_odoo/static/src/css/web_widget_mail_send_odoo.css
-
107web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js
-
8web_widget_mail_send_odoo/static/src/xml/web_widget_mail_send_odoo.xml
@ -0,0 +1,57 @@ |
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
|||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
================================================= |
|||
Web Widget - Internal mail wizard for email links |
|||
================================================= |
|||
|
|||
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 |
|||
Email wizard from Odoo for message composition. |
|||
|
|||
The message you sent gets appended to the chatter as if you where using the |
|||
internal mail functions of Odoo. |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
To use this module, you need to: |
|||
|
|||
* Install the module. |
|||
* It will replace the default widget for email fields. |
|||
|
|||
For further information, please visit: |
|||
|
|||
* https://www.odoo.com/forum/help-1 |
|||
|
|||
Bug Tracker |
|||
=========== |
|||
|
|||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_. |
|||
In case of trouble, please check there if your issue has already been reported. |
|||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback |
|||
`here <https://github.com/OCA/web/issues/new?body=module:%20web_widget_mail_send_odoo%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Peter Hahn <peter.hahn@initos.com> |
|||
|
|||
Maintainer |
|||
---------- |
|||
|
|||
.. image:: https://odoo-community.org/logo.png |
|||
:alt: Odoo Community Association |
|||
:target: https://odoo-community.org |
|||
|
|||
This module is maintained by the OCA. |
|||
|
|||
OCA, or the Odoo Community Association, is a nonprofit organization whose |
|||
mission is to support the collaborative development of Odoo features and |
|||
promote its widespread use. |
|||
|
|||
To contribute to this module, please visit https://odoo-community.org. |
@ -0,0 +1,25 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2015 initOS GmbH (<http://www.initos.com>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
{ |
|||
'name': 'Web Widget - Internal mail wizard for email links', |
|||
'summary': 'Send mail using internal composition wizard.', |
|||
'version': '8.0.1.0.0', |
|||
'category': 'Social Network', |
|||
'website': 'https://odoo-community.org', |
|||
'author': 'initOS GmbH, Odoo Community Association (OCA)', |
|||
'license': 'AGPL-3', |
|||
'application': False, |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'depends': [ |
|||
'mail', |
|||
], |
|||
'data': [ |
|||
'assets.xml', |
|||
], |
|||
'qweb': [ |
|||
'static/src/xml/web_widget_mail_send_odoo.xml', |
|||
], |
|||
} |
@ -0,0 +1,13 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<template id="assets_backend" inherit_id="web.assets_backend"> |
|||
<xpath expr="." position="inside"> |
|||
<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"/> |
|||
</xpath> |
|||
</template> |
|||
|
|||
</data> |
|||
</openerp> |
@ -0,0 +1,39 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * web_widget_mail_send_odoo |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 8.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2016-01-27 20:09+0000\n" |
|||
"PO-Revision-Date: 2016-01-27 21:12+0100\n" |
|||
"Last-Translator: \n" |
|||
"Language-Team: \n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: 8bit\n" |
|||
"X-Generator: Poedit 1.5.4\n" |
|||
"Language: de\n" |
|||
"X-Poedit-SourceCharset: UTF-8\n" |
|||
|
|||
#. module: web_widget_mail_send_odoo |
|||
#. openerp-web |
|||
#: code:addons/web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js:33 |
|||
#, python-format |
|||
msgid "Can't send email to invalid e-mail address" |
|||
msgstr "Die Empfängeradresse ist keine gültige Email." |
|||
|
|||
#. module: web_widget_mail_send_odoo |
|||
#. openerp-web |
|||
#: code:addons/web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js:33 |
|||
#, python-format |
|||
msgid "E-mail Error" |
|||
msgstr "Email Fehler" |
|||
|
|||
#. module: web_widget_mail_send_odoo |
|||
#. openerp-web |
|||
#: code:addons/web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js:75 |
|||
#, python-format |
|||
msgid "Please complete partner's information." |
|||
msgstr "Bitte vervollständigen Sie die Kontaktinformationen des Empfängers." |
@ -0,0 +1,38 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * web_widget_mail_send_odoo |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 8.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2016-01-27 20:09+0000\n" |
|||
"PO-Revision-Date: 2016-01-27 20:09+0000\n" |
|||
"Last-Translator: <>\n" |
|||
"Language-Team: \n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Plural-Forms: \n" |
|||
|
|||
#. module: web_widget_mail_send_odoo |
|||
#. openerp-web |
|||
#: code:addons/web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js:33 |
|||
#, python-format |
|||
msgid "Can't send email to invalid e-mail address" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_mail_send_odoo |
|||
#. openerp-web |
|||
#: code:addons/web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js:33 |
|||
#, python-format |
|||
msgid "E-mail Error" |
|||
msgstr "" |
|||
|
|||
#. module: web_widget_mail_send_odoo |
|||
#. openerp-web |
|||
#: code:addons/web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js:75 |
|||
#, python-format |
|||
msgid "Please complete partner's information." |
|||
msgstr "" |
|||
|
After Width: 128 | Height: 128 | Size: 9.2 KiB |
@ -0,0 +1 @@ |
|||
.openerp .oe_form .oe_form_field_email_internal input, |
@ -0,0 +1,107 @@ |
|||
/* © 2015 initOS GmbH (<http://www.initos.com>) |
|||
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|||
*/ |
|||
|
|||
openerp.web_widget_mail_send_odoo = function(instance) { |
|||
|
|||
var _t = instance.web._t, |
|||
_lt = instance.web._lt; |
|||
var QWeb = instance.web.qweb; |
|||
|
|||
instance.web.form.FieldEmailIntern = instance.web.form.FieldChar.extend({ |
|||
template: 'FieldEmailIntern', |
|||
initialize_content: function() { |
|||
this._super(); |
|||
var $button = this.$('a'); |
|||
$button.click(this.on_clicked); |
|||
this.setupFocus($button); |
|||
}, |
|||
render_value: function() { |
|||
var self = this; |
|||
if (!this.get("effective_readonly")) { |
|||
self._super(); |
|||
} else { |
|||
self.$el.find('a') |
|||
.removeAttr('href') |
|||
.removeAttr('target') |
|||
.text(self.get('value') || ''); |
|||
} |
|||
}, |
|||
is_syntax_valid: function(){ |
|||
var self = this; |
|||
if(!self._super()) |
|||
return false; |
|||
if (!self.get("effective_readonly") && 0 < self.$("input").size() && self.$("input").val()) { |
|||
try { |
|||
var parsed_email = instance.mail.ChatterUtils.parse_email(self.$("input").val()); |
|||
console.log(parsed_email) |
|||
if(!parsed_email[1]) |
|||
return false; |
|||
return true; |
|||
} catch(e) { |
|||
return false; |
|||
} |
|||
} |
|||
return true; |
|||
}, |
|||
on_clicked: function() { |
|||
var self = this; |
|||
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")); |
|||
} else { |
|||
// find partner id for email
|
|||
var res_partner = new openerp.Model('res.partner'); |
|||
var parsed_email = instance.mail.ChatterUtils.parse_email(self.get('value')); |
|||
res_partner.query(['id']) |
|||
.filter([['email', '=', parsed_email[1]]]) |
|||
.first().then(function(partner){ |
|||
if(partner){ |
|||
var fm = self.field_manager |
|||
self.do_action( |
|||
'mail.action_email_compose_message_wizard', { |
|||
additional_context: { |
|||
default_partner_ids: [partner.id], |
|||
default_composition_mode: 'comment', |
|||
// write to active model:
|
|||
default_model: fm.dataset._model.name, |
|||
default_res_id: fm.datarecord.id, |
|||
}, |
|||
on_close: function(){ |
|||
// refresh the chatter widget here
|
|||
$.each(self.view.getChildren(), |
|||
function(index, value){ |
|||
if(value.root && value.root.thread && value.root.thread.message_fetch){ |
|||
value.root.thread.message_fetch() |
|||
} |
|||
} |
|||
); |
|||
}, |
|||
} |
|||
); |
|||
} else { |
|||
var pop = new instance.web.form.FormOpenPopup(self); |
|||
var context = new instance.web.CompoundContext(self.build_context(), { |
|||
default_name: parsed_email[0], |
|||
default_email: parsed_email[1], |
|||
force_email: true, |
|||
}); |
|||
pop.show_element( |
|||
'res.partner', |
|||
false, |
|||
context, |
|||
{ |
|||
title: _t("Please complete partner's information."), |
|||
} |
|||
); |
|||
pop.on('create_completed', self, function (id) { |
|||
self.on_clicked() |
|||
}); |
|||
} |
|||
}) |
|||
} |
|||
}, |
|||
}); |
|||
|
|||
instance.web.form.widgets.add('email_mailto', 'instance.web.form.FieldEmail') |
|||
instance.web.form.widgets.add('email', 'instance.web.form.FieldEmailIntern') |
|||
} |
@ -0,0 +1,8 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<templates> |
|||
<t t-name="FieldEmailIntern" t-extend="FieldEmail"> |
|||
<t t-jquery="span:first"> |
|||
this.removeClass('oe_form_field_email').addClass('oe_form_field_email_internal'); |
|||
</t> |
|||
</t> |
|||
</templates> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue