diff --git a/addons/crm/crm_action_rule_demo.xml b/addons/crm/crm_action_rule_demo.xml
index 7204f666db5..569b2d676e0 100644
--- a/addons/crm/crm_action_rule_demo.xml
+++ b/addons/crm/crm_action_rule_demo.xml
@@ -14,13 +14,7 @@
Trueir.actions.serveremail
- object.user_id.email
- Reminder on Lead: [[object.id ]] [[object.partner_id and 'of ' +object.partner_id.name or '']]
- Warning unprocessed incoming lead is more than 5 day old.
-Name: [[object.name ]]
-ID: [[object.id ]]
-Description: [[object.description]]
-
+ Set Auto Reminder on leads which are not open since 5 days.
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index 46a3f6e199e..c0f003f9792 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -945,42 +945,6 @@ class crm_lead(format_address, osv.osv):
vals.update(onchange_stage_values)
return super(crm_lead, self).write(cr, uid, ids, vals, context=context)
- def new_mail_send(self, cr, uid, ids, context=None):
- '''
- This function opens a window to compose an email, with the edi sale template message loaded by default
- '''
- assert len(ids) == 1, 'This option should only be used for a single id at a time.'
- ir_model_data = self.pool.get('ir.model.data')
- try:
- template_id = ir_model_data.get_object_reference(cr, uid, 'crm', 'email_template_opportunity_mail')[1]
- except ValueError:
- template_id = False
- try:
- compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
- except ValueError:
- compose_form_id = False
- if context is None:
- context = {}
- ctx = context.copy()
- ctx.update({
- 'default_model': 'crm.lead',
- 'default_res_id': ids[0],
- 'default_use_template': bool(template_id),
- 'default_template_id': template_id,
- 'default_composition_mode': 'comment',
- })
- return {
- 'name': _('Compose Email'),
- 'type': 'ir.actions.act_window',
- 'view_type': 'form',
- 'view_mode': 'form',
- 'res_model': 'mail.compose.message',
- 'views': [(compose_form_id, 'form')],
- 'view_id': compose_form_id,
- 'target': 'new',
- 'context': ctx,
- }
-
# ----------------------------------------
# Mail Gateway
# ----------------------------------------
diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml
index 92914542d9d..219ff2cdeee 100644
--- a/addons/crm/crm_lead_data.xml
+++ b/addons/crm/crm_lead_data.xml
@@ -220,6 +220,20 @@
${not object.partner_id and object.email_from}
+
+ Reminder to User
+
+
+ admin@example.com
+ ${object.user_id != False and object.user_id.email}
+ Reminder on Lead: ${object.id} from ${object.partner_id != False and object.partner_id.name or object.contact_name}
+ This opportunity did not have any activity since at least 5 days. Here are some details:
+
+
Name: ${object.name}
+
ID: ${object.id}
+
Description: ${object.description}
+
]]>
+
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index cb4302166a1..aa5aac76b9d 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -408,7 +408,7 @@
diff --git a/addons/email_template/__init__.py b/addons/email_template/__init__.py
index d1cf5b28431..3f091fd8645 100644
--- a/addons/email_template/__init__.py
+++ b/addons/email_template/__init__.py
@@ -22,5 +22,6 @@
import email_template
import wizard
import res_partner
+import ir_actions
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/email_template/__openerp__.py b/addons/email_template/__openerp__.py
index 1dc3baaf63c..b7977660134 100644
--- a/addons/email_template/__openerp__.py
+++ b/addons/email_template/__openerp__.py
@@ -59,6 +59,7 @@ campaigns on any OpenERP document.
'wizard/email_template_preview_view.xml',
'email_template_view.xml',
'res_partner_view.xml',
+ 'ir_actions_view.xml',
'wizard/mail_compose_message_view.xml',
'security/ir.model.access.csv'
],
diff --git a/addons/email_template/doc/changelog.rst b/addons/email_template/doc/changelog.rst
new file mode 100644
index 00000000000..2581175fe0b
--- /dev/null
+++ b/addons/email_template/doc/changelog.rst
@@ -0,0 +1,11 @@
+.. _changelog:
+
+Changelog
+=========
+
+`trunk (saas-2)`
+----------------
+
+ - Server action update
+
+ - added `email` server action type, now entirely based on email templates.
\ No newline at end of file
diff --git a/addons/email_template/doc/index.rst b/addons/email_template/doc/index.rst
new file mode 100644
index 00000000000..58cf9413601
--- /dev/null
+++ b/addons/email_template/doc/index.rst
@@ -0,0 +1,13 @@
+Email Template module documentation
+===================================
+
+Email Template documentation topics
+'''''''''''''''''''''''''''''''''''
+
+Changelog
+'''''''''
+
+.. toctree::
+ :maxdepth: 1
+
+ changelog.rst
diff --git a/addons/email_template/ir_actions.py b/addons/email_template/ir_actions.py
new file mode 100644
index 00000000000..bd860785da4
--- /dev/null
+++ b/addons/email_template/ir_actions.py
@@ -0,0 +1,86 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Business Applications
+# Copyright (c) 2013 OpenERP S.A.
+#
+# 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 .
+#
+##############################################################################
+
+from openerp.osv import fields, osv
+
+
+class actions_server(osv.Model):
+ """ Add email option in server actions. """
+ _name = 'ir.actions.server'
+ _inherit = ['ir.actions.server']
+
+ def _get_states(self, cr, uid, context=None):
+ res = super(actions_server, self)._get_states(cr, uid, context=context)
+ res.insert(0, ('email', 'Send Email'))
+ return res
+
+ _columns = {
+ 'email_from': fields.char('From',
+ help="Sender address; define the template to see its value. If not set, the default "
+ "value will be the author's email alias if configured, or email address."),
+ 'email_to': fields.char('To (Emails)',
+ help="Comma-separated recipient addresses; define the template to see its value"),
+ 'partner_to': fields.char('To (Partners)',
+ help="Comma-separated ids of recipient partners; define the template to see its value"),
+ 'subject': fields.char('Subject',
+ help="Email subject; define the template to see its value"),
+ 'body_html': fields.text('Body',
+ help="Rich-text/HTML version of the message; define the template to see its value"),
+ 'template_id': fields.many2one('email.template', 'Email Template', ondelete='set null',
+ help="Define the email template to use for the email to send.")
+ }
+
+ def on_change_template_id(self, cr, uid, ids, template_id, context=None):
+ """ Render the raw template in the server action fields. """
+ if template_id:
+ fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids']
+ template_values = self.pool.get('email.template').read(cr, uid, template_id, fields, context)
+ values = dict((field, template_values[field]) for field in fields if template_values.get(field))
+ if not values.get('email_from'):
+ return {'warning': {'title': 'Incomplete template', 'message': 'Your template should define email_from'}, 'value': values}
+ else:
+ values = self.default_get(cr, uid, ['subject', 'body_html', 'email_from', 'email_to', 'partner_to'], context=context)
+
+ return {'value': values}
+
+ def create(self, cr, uid, values, context=None):
+ if values.get('template_id'):
+ fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids']
+ template_values = self.pool.get('email.template').read(cr, uid, values.get('template_id'), fields, context)
+ values.update(dict((field, template_values[field]) for field in fields if template_values.get(field)))
+ return super(actions_server, self).create(cr, uid, values, context=context)
+
+ def write(self, cr, uid, ids, values, context=None):
+ if values.get('template_id'):
+ fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids']
+ template_values = self.pool.get('email.template').read(cr, uid, values.get('template_id'), fields, context)
+ values.update(dict((field, template_values[field]) for field in fields if template_values.get(field)))
+ return super(actions_server, self).write(cr, uid, ids, values, context=context)
+
+ def run_action_email(self, cr, uid, action, eval_context=None, context=None):
+ if not action.template_id or not context.get('active_id'):
+ return False
+ self.pool['email.template'].send_mail(cr, uid, action.template_id.id, context.get('active_id'),
+ force_send=False, raise_exception=False, context=context)
+ return False
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/email_template/ir_actions_view.xml b/addons/email_template/ir_actions_view.xml
new file mode 100644
index 00000000000..fae9c364312
--- /dev/null
+++ b/addons/email_template/ir_actions_view.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+ ir.actions.server.form
+ ir.actions.server
+
+
+
+
+
+ Please set the Base Model before setting the action details.
+
+
+
+
+ Choose a template to display its values.
+
+
+ The values displayed hereunder are informative. When sending the email, the values
+ will be taken from the email template.
+
+
+
+
+
+
+
+ Your template does not defined any email_from. Please update your template.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/email_template/tests/__init__.py b/addons/email_template/tests/__init__.py
index d63c5634cc3..9418985b06c 100644
--- a/addons/email_template/tests/__init__.py
+++ b/addons/email_template/tests/__init__.py
@@ -18,10 +18,11 @@
# along with this program. If not, see .
#
##############################################################################
-from . import test_mail
+from . import test_mail, test_ir_actions
checks = [
test_mail,
+ test_ir_actions,
]
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/email_template/tests/test_ir_actions.py b/addons/email_template/tests/test_ir_actions.py
new file mode 100644
index 00000000000..d323ee36c1f
--- /dev/null
+++ b/addons/email_template/tests/test_ir_actions.py
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Business Applications
+# Copyright (c) 2013-TODAY OpenERP S.A.
+#
+# 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 .
+#
+##############################################################################
+
+from openerp.addons.base.tests.test_ir_actions import TestServerActionsBase
+
+
+class TestServerActionsEmail(TestServerActionsBase):
+
+ def test_00_state_email(self):
+ """ Test ir.actions.server email type """
+ cr, uid = self.cr, self.uid
+
+ # create email_template
+ template_id = self.registry('email.template').create(cr, uid, {
+ 'name': 'TestTemplate',
+ 'email_from': 'myself@example.com',
+ 'email_to': 'brigitte@example.com',
+ 'partner_to': '[%s]' % self.test_partner_id,
+ 'model_id': self.res_partner_model_id,
+ 'subject': 'About ${object.name}',
+ 'body_html': '
Dear ${object.name}, your parent is ${object.parent_id and object.parent_id.name or "False"}