From bba4c6d2239bcf949027fad6400a1f3a9ccb02dc Mon Sep 17 00:00:00 2001 From: Peter Hahn Date: Fri, 8 Jan 2016 11:50:36 +0100 Subject: [PATCH] Create new partner contact on the fly if no partner exists for mail. --- .../src/js/web_widget_mail_send_odoo.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js b/web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js index b905d426..57991ca6 100644 --- a/web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js +++ b/web_widget_mail_send_odoo/static/src/js/web_widget_mail_send_odoo.js @@ -54,12 +54,24 @@ instance.web.form.FieldEmailIntern = instance.web.form.FieldChar.extend({ */ }, } - ) + ); } else { - self.do_warn(_t("E-mail Error"), - _t("No partner for email.")); - // fall back to mailto: - location.href = 'mailto:' + self.get('value'); + console.log(self.build_context()); + var pop = new instance.web.form.FormOpenPopup(self); + var context = new instance.web.CompoundContext(self.build_context(), { + default_email: self.get('value'), + }); + pop.show_element( + 'res.partner', + false, + context, + { + title: _t("Please complete partner's information."), + } + ); + pop.on('create_completed', self, function (id) { + self.on_clicked() + }); } }) }