openerp-dev-web team mailing list archive
-
openerp-dev-web team
-
Mailing list archive
-
Message #05338
[Merge] lp:~openerp-dev/openobject-addons/addons_merge_mail_wizard_rha into lp:~openerp-dev/openobject-addons/emails-framework-addons
Rifakat Haradwala (OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/addons_merge_mail_wizard_rha into lp:~openerp-dev/openobject-addons/emails-framework-addons.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/addons_merge_mail_wizard_rha/+merge/57155
- improvements for email.compose.message fields subject and body
- email.compose.message inherited in crm_helpdesk, project_issue, hr_recruitment, event, project_planning
- improvements for mass mailing
--
https://code.launchpad.net/~openerp-dev/openobject-addons/addons_merge_mail_wizard_rha/+merge/57155
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/emails-framework-addons.
=== modified file 'crm/wizard/email_compose_message.py'
--- crm/wizard/email_compose_message.py 2011-03-01 09:50:57 +0000
+++ crm/wizard/email_compose_message.py 2011-04-11 12:46:09 +0000
@@ -38,10 +38,10 @@
model_obj = self.pool.get(model)
data = model_obj.browse(cr, uid , resource_id, context)
result.update({
- 'name' : data.name or False,
+ 'subject' : data.name or False,
'email_to' : data.email_from or False,
'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or False,
- 'description' : '\n' + (tools.ustr(data.user_id.signature or '')),
+ 'body' : '\n' + (tools.ustr(data.user_id.signature or '')),
'email_cc' : tools.ustr(data.email_cc or ''),
'model': model or False,
'res_id': resource_id or False,
=== modified file 'crm_claim/crm_claim_view.xml'
--- crm_claim/crm_claim_view.xml 2011-04-04 09:45:52 +0000
+++ crm_claim/crm_claim_view.xml 2011-04-11 12:46:09 +0000
@@ -187,13 +187,13 @@
<field name="date"/>
<field name="email_to" widget="char" size="512"/>
<field name="email_cc" widget="char" size="512"/>
- <field name="name" colspan="4" widget="char" size="512"/>
+ <field name="subject" colspan="4" widget="char" size="512"/>
<field name="history" invisible="1"/>
</group>
<notebook colspan="4">
<page string="Details">
<group attrs="{'invisible': [('history', '!=', True)]}">
- <field name="description" colspan="4" nolabel="1" height="250"/>
+ <field name="body" colspan="4" nolabel="1" height="250"/>
<button colspan="4" string="Reply"
name="%(mail.action_email_compose_message_wizard)d"
context="{'mail':'reply', 'message_id':active_id}"
=== modified file 'crm_fundraising/crm_fundraising_view.xml'
--- crm_fundraising/crm_fundraising_view.xml 2011-04-04 09:45:52 +0000
+++ crm_fundraising/crm_fundraising_view.xml 2011-04-11 12:46:09 +0000
@@ -178,13 +178,13 @@
<field name="date"/>
<field name="email_to" widget="char" size="512"/>
<field name="email_cc" widget="char" size="512"/>
- <field name="name" colspan="4" widget="char" size="512"/>
+ <field name="subject" colspan="4" widget="char" size="512"/>
<field name="history" invisible="1"/>
</group>
<notebook colspan="4">
<page string="Details">
<group attrs="{'invisible': [('history', '!=', True)]}">
- <field name="description" colspan="4" nolabel="1" height="250"/>
+ <field name="body" colspan="4" nolabel="1" height="250"/>
<button colspan="4" string="Reply"
name="%(mail.action_email_compose_message_wizard)d"
context="{'mail':'reply', 'message_id':active_id}"
=== modified file 'crm_helpdesk/__init__.py'
--- crm_helpdesk/__init__.py 2011-01-14 00:11:01 +0000
+++ crm_helpdesk/__init__.py 2011-04-11 12:46:09 +0000
@@ -21,6 +21,7 @@
import crm_helpdesk
import report
+import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'crm_helpdesk/crm_helpdesk.py'
--- crm_helpdesk/crm_helpdesk.py 2011-04-06 11:16:47 +0000
+++ crm_helpdesk/crm_helpdesk.py 2011-04-11 12:46:09 +0000
@@ -26,7 +26,6 @@
import binascii
import tools
-wizard.email_compose_message.email_model.append('crm.helpdesk')
CRM_HELPDESK_STATES = (
crm.AVAILABLE_STATES[2][0], # Cancelled
crm.AVAILABLE_STATES[3][0], # Done
=== modified file 'crm_helpdesk/crm_helpdesk_view.xml'
--- crm_helpdesk/crm_helpdesk_view.xml 2011-04-04 09:45:52 +0000
+++ crm_helpdesk/crm_helpdesk_view.xml 2011-04-11 12:46:09 +0000
@@ -112,13 +112,13 @@
<field name="date"/>
<field name="email_to" widget="char" size="512"/>
<field name="email_cc" widget="char" size="512"/>
- <field name="name" colspan="4" widget="char" size="512"/>
+ <field name="subject" colspan="4" widget="char" size="512"/>
<field name="history" invisible="1"/>
</group>
<notebook colspan="4">
<page string="Details">
<group attrs="{'invisible': [('history', '!=', True)]}">
- <field name="description" colspan="4" nolabel="1" height="250"/>
+ <field name="body" colspan="4" nolabel="1" height="250"/>
<button colspan="4" string="Reply"
name="%(mail.action_email_compose_message_wizard)d"
context="{'mail':'reply', 'message_id':active_id}"
=== added directory 'crm_helpdesk/wizard'
=== added file 'crm_helpdesk/wizard/__init__.py'
--- crm_helpdesk/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ crm_helpdesk/wizard/__init__.py 2011-04-11 12:46:09 +0000
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+# 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/>.
+#
+##############################################################################
+
+import email_compose_message
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
=== added file 'crm_helpdesk/wizard/email_compose_message.py'
--- crm_helpdesk/wizard/email_compose_message.py 1970-01-01 00:00:00 +0000
+++ crm_helpdesk/wizard/email_compose_message.py 2011-04-11 12:46:09 +0000
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+import tools
+
+class email_compose_message(osv.osv_memory):
+ _inherit = 'email.compose.message'
+
+ def get_value(self, cr, uid, model, resource_id, context=None):
+ if context is None:
+ context = {}
+ result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context)
+ if model == 'crm.helpdesk' and resource_id:
+ model_obj = self.pool.get(model)
+ data = model_obj.browse(cr, uid , resource_id, context)
+ result.update({
+ 'subject' : data.name or False,
+ 'email_to' : data.email_from or False,
+ 'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or False,
+ 'body' : '\n' + (tools.ustr(data.user_id.signature or '')),
+ 'email_cc' : tools.ustr(data.email_cc or ''),
+ 'model': model or False,
+ 'res_id': resource_id or False,
+ })
+ return result
+
+email_compose_message()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'crm_partner_assign/wizard/crm_forward_to_partner.py'
--- crm_partner_assign/wizard/crm_forward_to_partner.py 2011-04-05 08:32:48 +0000
+++ crm_partner_assign/wizard/crm_forward_to_partner.py 2011-04-11 12:46:09 +0000
@@ -75,7 +75,7 @@
sender = 'From: %s' %(hist.email_from or '')
to = 'To: %s' % (hist.email_to or '')
sentdate = 'Date: %s' % (hist.date or '')
- desc = '\n%s'%(hist.description)
+ desc = '\n%s'%(hist.body)
original = [header, sender, to, sentdate, desc]
original = '\n'.join(original)
return original
@@ -171,13 +171,6 @@
email = self.pool.get('res.partner.address').browse(cr, uid, address_id).email
return {'value': {'email_to' : email}}
- def save_to_drafts(self, cr, uid, ids, context=None):
- if context is None:
- context = {}
- super(crm_lead_forward_to_partner, self).save_to_drafts(cr, uid, ids, context=context)
- self.action_forward(cr, uid, ids, context)
- return {'type': 'ir.actions.act_window_close'}
-
def send_mail(self, cr, uid, ids, context=None):
if context is None:
context = {}
=== modified file 'crm_partner_assign/wizard/crm_forward_to_partner_view.xml'
--- crm_partner_assign/wizard/crm_forward_to_partner_view.xml 2011-02-25 06:23:46 +0000
+++ crm_partner_assign/wizard/crm_forward_to_partner_view.xml 2011-04-11 12:46:09 +0000
@@ -31,12 +31,12 @@
<field name="email_cc" colspan="4"/>
<field name="email_bcc" colspan="4"/>
<field name="reply_to" colspan="4"/>
- <field name="name" colspan="4" widget="char" size="512"/>
+ <field name="subject" colspan="4" widget="char" size="512"/>
</group>
<separator string="" colspan="4"/>
<notebook colspan="4">
<page string="Body">
- <field name="description" colspan="4" nolabel="1"/>
+ <field name="body" colspan="4" nolabel="1"/>
</page>
<page string="Attachments">
<label string="Add here all attachments of the current document you want to include in the Email." colspan="4"/>
@@ -46,7 +46,6 @@
<group col="4" colspan="4">
<label string="" colspan="1"/>
<button icon="gtk-close" special="cancel" string="Close"/>
- <button icon="gtk-apply" name="save_to_drafts" string="Save in Drafts" type="object"/>
<button icon="gtk-ok" name="send_mail" string="Send now" type="object"/>
</group>
</form>
=== modified file 'email_template/wizard/email_compose_message.py'
--- email_template/wizard/email_compose_message.py 2011-04-06 05:45:13 +0000
+++ email_template/wizard/email_compose_message.py 2011-04-11 12:46:09 +0000
@@ -62,8 +62,8 @@
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
template_id = context.get('template_id', False)
vals = {}
- if template_id and context.get('email_model') and context.get('email_res_id'):
- vals = self.get_template_data(cr, uid, context.get('email_res_id'), template_id, context)
+ if template_id and context.get('active_model') and context.get('active_id'):
+ vals = self.get_template_data(cr, uid, context.get('active_id'), template_id, context)
if not vals:
return result
@@ -116,8 +116,8 @@
message_pool = self.pool.get('email.message')
message_data = message_pool.browse(cr, uid, int(context.get('message_id')), context)
model = message_data.model
- elif context.get('email_model',False):
- model = context.get('email_model')
+ elif context.get('active_model',False):
+ model = context.get('active_model')
if model:
record_ids = email_temp_pool.search(cr, uid, [('model','=',model)])
return email_temp_pool.name_get(cr, uid, record_ids, context) + [(False,'')]
@@ -127,13 +127,13 @@
'template_id': fields.selection(_get_templates, 'Template'),
}
- def on_change_template(self, cr, uid, ids, model, resource_id, template_id, context=None):
+ def on_change_template(self, cr, uid, ids, model, template_id, context=None):
if context is None:
context = {}
if context.get('mail') == 'reply':
return {'value':{}}
- result = self.on_change_referred_doc(cr, uid, [], model, resource_id, context=context)
- vals = result.get('value',{})
+ vals = {}
+ resource_id = context.get('active_id', False)
if template_id and resource_id:
vals.update(self.get_template_data(cr, uid, resource_id, template_id, context))
else:
=== modified file 'email_template/wizard/email_compose_message_view.xml'
--- email_template/wizard/email_compose_message_view.xml 2011-04-04 09:45:52 +0000
+++ email_template/wizard/email_compose_message_view.xml 2011-04-11 12:46:09 +0000
@@ -8,12 +8,9 @@
<field name="type">form</field>
<field name="inherit_id" ref="mail.email_compose_message_wizard_form"/>
<field name="arch" type="xml">
- <field name="res_id" position="replace">
+ <field name="model" position="after">
<field name="template_id" colspan="4"
- on_change="on_change_template(model, res_id, template_id, context)"/>
- <field name="res_id"
- invisible="context.get('active_model','') != 'ir.ui.menu'"
- colspan="4" on_change="on_change_template(model, res_id, template_id, context)"/>
+ on_change="on_change_template(model, template_id, context)"/>
</field>
</field>
</record>
=== modified file 'email_template/wizard/email_template_send_wizard.py'
--- email_template/wizard/email_template_send_wizard.py 2011-03-22 13:37:25 +0000
+++ email_template/wizard/email_template_send_wizard.py 2011-04-11 12:46:09 +0000
@@ -128,13 +128,6 @@
# result['attachment_ids']['domain'] = [('res_model','=',context['src_model']),('res_id','=',context['active_id'])]
# return result
- def save_to_drafts(self, cr, uid, ids, context=None):
- if context is None:
- context = {}
- mailid = self.save_to_mailbox(cr, uid, ids, context=context)
- self.pool.get('email.message').write(cr, uid, mailid, {'state': 'outgoing'}, context)
- return {'type': 'ir.actions.act_window_close'}
-
def send_mail(self, cr, uid, ids, context=None):
if context is None:
context = {}
=== modified file 'email_template/wizard/email_template_send_wizard_view.xml'
--- email_template/wizard/email_template_send_wizard_view.xml 2011-02-14 19:49:36 +0000
+++ email_template/wizard/email_template_send_wizard_view.xml 2011-04-11 12:46:09 +0000
@@ -33,7 +33,7 @@
<field name="attachment_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
-
+
</group>
<field name="state" invisible="1"/>
<group col="4" colspan="4" attrs="{'invisible':[('state','=','single')]}">
@@ -52,12 +52,8 @@
</group>
<group col="4" colspan="2" attrs="{'invisible':[('state','!=','single')]}">
<button icon="gtk-cancel" special="cancel" string="Discard"/>
- <button icon="gtk-apply" name="save_to_drafts" string="Save in Drafts" type="object"/>
<button icon="gtk-ok" name="send_mail" string="Send now" type="object"/>
</group>
-
-
-
</form>
</field>
</record>
=== modified file 'event/event.py'
--- event/event.py 2011-03-21 13:31:56 +0000
+++ event/event.py 2011-04-11 12:46:09 +0000
@@ -27,7 +27,6 @@
import decimal_precision as dp
from crm import wizard
-wizard.email_compose_message.email_model.append('event.registration')
class event_type(osv.osv):
""" Event Type """
=== modified file 'event/event_view.xml'
--- event/event_view.xml 2011-04-04 09:45:52 +0000
+++ event/event_view.xml 2011-04-11 12:46:09 +0000
@@ -403,13 +403,13 @@
<field name="date"/>
<field name="email_to" widget="char" size="512"/>
<field name="email_cc" widget="char" size="512"/>
- <field name="name" colspan="4" widget="char" size="512"/>
+ <field name="subject" colspan="4" widget="char" size="512"/>
<field name="history" invisible="1"/>
</group>
<notebook colspan="4">
<page string="Details">
<group attrs="{'invisible': [('history', '!=', True)]}">
- <field name="description" colspan="4" nolabel="1" height="250"/>
+ <field name="body" colspan="4" nolabel="1" height="250"/>
<button colspan="4" string="Reply"
name="%(mail.action_email_compose_message_wizard)d"
context="{'mail':'reply', 'message_id':active_id}"
=== modified file 'event/wizard/__init__.py'
--- event/wizard/__init__.py 2011-01-14 00:11:01 +0000
+++ event/wizard/__init__.py 2011-04-11 12:46:09 +0000
@@ -23,4 +23,5 @@
import event_confirm_registration
import event_confirm
import partner_event_registration
+import email_compose_message
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'event/wizard/email_compose_message.py'
--- event/wizard/email_compose_message.py 1970-01-01 00:00:00 +0000
+++ event/wizard/email_compose_message.py 2011-04-11 12:46:09 +0000
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+import tools
+
+class email_compose_message(osv.osv_memory):
+ _inherit = 'email.compose.message'
+
+ def get_value(self, cr, uid, model, resource_id, context=None):
+ if context is None:
+ context = {}
+ result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context)
+ if model == 'event.registration' and resource_id:
+ model_obj = self.pool.get(model)
+ data = model_obj.browse(cr, uid , resource_id, context)
+ result.update({
+ 'subject' : data.event_id.name or False,
+ 'email_to' : data.email_from or False,
+ 'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or False,
+ 'body' : '\n' + (tools.ustr(data.user_id.signature or '')),
+ 'email_cc' : tools.ustr(data.email_cc or ''),
+ 'model': model or False,
+ 'res_id': resource_id or False,
+ })
+ return result
+
+email_compose_message()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'hr_evaluation/wizard/email_compose_message.py'
--- hr_evaluation/wizard/email_compose_message.py 2011-03-01 09:50:57 +0000
+++ hr_evaluation/wizard/email_compose_message.py 2011-04-11 12:46:09 +0000
@@ -27,24 +27,6 @@
class email_compose_message(osv.osv_memory):
_inherit = 'email.compose.message'
- def _get_records(self, cr, uid, context=None):
- """
- Return Records of particular Model
- """
- if context is None:
- context = {}
- record_ids = []
- if context.get('email_model',False) and context.get('email_model') == 'hr.evaluation.interview':
- model_pool = self.pool.get(context.get('email_model'))
- record_ids = model_pool.search(cr, uid, [('state','=','waiting_answer')])
- return model_pool.name_get(cr, uid, record_ids, context)
- else:
- return super(email_compose_message, self)._get_records(cr, uid, context=context)
-
- _columns = {
- 'res_id':fields.selection(_get_records, 'Referred Document'),
- }
-
def get_value(self, cr, uid, model, resource_id, context=None):
if context is None:
context = {}
@@ -57,8 +39,8 @@
result.update({
'email_from': tools.config.get('email_from',''),
'email_to': record_data.user_to_review_id.work_email or False,
- 'name': _("Reminder to fill up Survey"),
- 'description': msg,
+ 'subject': _("Reminder to fill up Survey"),
+ 'body': msg,
'res_id': resource_id,
'email_cc': False,
'email_bcc': False,
=== modified file 'hr_recruitment/hr_recruitment.py'
--- hr_recruitment/hr_recruitment.py 2011-04-06 11:16:47 +0000
+++ hr_recruitment/hr_recruitment.py 2011-04-11 12:46:09 +0000
@@ -31,8 +31,6 @@
from tools.translate import _
from crm import wizard
-wizard.email_compose_message.email_model.append('hr.applicant')
-
AVAILABLE_STATES = [
('draft', 'New'),
('open', 'In Progress'),
=== modified file 'hr_recruitment/hr_recruitment_view.xml'
--- hr_recruitment/hr_recruitment_view.xml 2011-04-04 09:45:52 +0000
+++ hr_recruitment/hr_recruitment_view.xml 2011-04-11 12:46:09 +0000
@@ -157,13 +157,13 @@
<field name="date"/>
<field name="email_to" widget="char" size="512"/>
<field name="email_cc" widget="char" size="512"/>
- <field name="name" colspan="4" widget="char" size="512"/>
+ <field name="subject" colspan="4" widget="char" size="512"/>
<field name="history" invisible="1"/>
</group>
<notebook colspan="4">
<page string="Details">
<group attrs="{'invisible': [('history', '!=', True)]}">
- <field name="description" colspan="4" nolabel="1" height="250"/>
+ <field name="body" colspan="4" nolabel="1" height="250"/>
<button colspan="4" string="Reply"
name="%(mail.action_email_compose_message_wizard)d"
context="{'mail':'reply', 'message_id':active_id}"
=== modified file 'hr_recruitment/wizard/__init__.py'
--- hr_recruitment/wizard/__init__.py 2011-02-16 12:04:50 +0000
+++ hr_recruitment/wizard/__init__.py 2011-04-11 12:46:09 +0000
@@ -23,6 +23,7 @@
import hr_recruitment_phonecall
import hr_recruitment_create_partner_job
import hr_recruitment_employee_hired
+import email_compose_message
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'hr_recruitment/wizard/email_compose_message.py'
--- hr_recruitment/wizard/email_compose_message.py 1970-01-01 00:00:00 +0000
+++ hr_recruitment/wizard/email_compose_message.py 2011-04-11 12:46:09 +0000
@@ -0,0 +1,50 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+import tools
+
+
+class email_compose_message(osv.osv_memory):
+ _inherit = 'email.compose.message'
+
+ def get_value(self, cr, uid, model, resource_id, context=None):
+ if context is None:
+ context = {}
+ result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context)
+ if model == 'hr.applicant' and resource_id:
+ model_obj = self.pool.get(model)
+ data = model_obj.browse(cr, uid , resource_id, context)
+ result.update({
+ 'subject' : data.name or False,
+ 'email_to' : data.email_from or False,
+ 'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or False,
+ 'body' : '\n' + (tools.ustr(data.user_id.signature or '')),
+ 'email_cc' : tools.ustr(data.email_cc or ''),
+ 'model': model or False,
+ 'res_id': resource_id or False,
+ })
+ return result
+
+email_compose_message()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'mail/wizard/email_compose_message.py'
--- mail/wizard/email_compose_message.py 2011-04-06 09:15:50 +0000
+++ mail/wizard/email_compose_message.py 2011-04-11 12:46:09 +0000
@@ -33,12 +33,14 @@
context = {}
result = super(email_compose_message, self).default_get(cr, uid, fields, context=context)
vals = {}
- if context.get('email_model') and context.get('email_res_id'):
- vals = self.get_value(cr, uid, context.get('email_model'), context.get('email_res_id'), context)
- elif context.get('message_id', False):
- vals = self.get_message_data(cr, uid, int(context.get('message_id', False)), context)
+ if context.get('active_model') and context.get('active_id') and not context.get('mail')=='reply':
+ vals = self.get_value(cr, uid, context.get('active_model'), context.get('active_id'), context)
+
+ elif context.get('mail')=='reply' and context.get('active_id', False):
+ vals = self.get_message_data(cr, uid, int(context.get('active_id', False)), context)
+
else:
- result['model'] = context.get('email_model', False)
+ result['model'] = context.get('active_model', False)
if not vals:
return result
@@ -96,33 +98,8 @@
return result
- def _get_records(self, cr, uid, context=None):
- """
- Return Records of particular Model
- """
- if context is None:
- context = {}
- record_ids = []
- model_pool = False
- if context.get('message_id'):
- message_pool = self.pool.get('email.message')
- message_data = message_pool.browse(cr, uid, int(context.get('message_id')), context)
- model_pool = self.pool.get(message_data.model)
- record_ids = [message_data.res_id]
- elif context.get('email_model',False):
- model = context.get('email_model')
- model_pool = self.pool.get(model)
- record_ids = context.get('email_res_id') and [context.get('email_res_id')] or []
- if not record_ids:
- record_ids = model_pool.search(cr, uid, [])
- if model_pool:
- return model_pool.name_get(cr, uid, record_ids, context)
- return []
-
_columns = {
'attachment_ids': fields.many2many('ir.attachment','email_message_send_attachment_rel', 'wizard_id', 'attachment_id', 'Attachments'),
- 'debug':fields.boolean('Debug', readonly=True),
- 'res_id':fields.selection(_get_records, 'Referred Document'),
}
def get_value(self, cr, uid, model, res_id, context=None):
@@ -171,40 +148,48 @@
return result
- def on_change_referred_doc(self, cr, uid, ids, model, resource_id, context=None):
- if context is None:
- context = {}
- if context.get('mail') == 'reply':
- return {'value':{}}
- result = {}
- if resource_id and model:
- vals = self.get_value(cr, uid, model, resource_id, context)
- if vals:
- result.update({
- 'email_from': vals.get('email_from',''),
- 'email_to': vals.get('email_to',''),
- 'subject': vals.get('subject',''),
- 'body': vals.get('body',''),
- 'email_cc': vals.get('email_cc',''),
- 'email_bcc': vals.get('email_bcc',''),
- 'reply_to': vals.get('reply_to',''),
- })
- return {'value': result}
-
-
- def save_to_drafts(self, cr, uid, ids, context=None):
- if context is None:
- context = {}
- email_id = self.save_to_mailbox(cr, uid, ids, context=context)
- self.pool.get('email.message').write(cr, uid, email_id, {'state': 'outgoing'}, context)
- return {'type': 'ir.actions.act_window_close'}
-
def send_mail(self, cr, uid, ids, context=None):
if context is None:
context = {}
+
+ record = self.browse(cr, uid, ids[0], context=context)
+ if context.get('mass_mail') and context['active_ids'] and context.get('template_id'):
+ email_message_pool = self.pool.get('email.message')
+ email_temp_pool = self.pool.get('email.template')
+ for res_id in context['active_ids']:
+ subject = email_temp_pool.get_template_value(cr, uid, record.subject, context['active_model'], res_id)
+ body = email_temp_pool.get_template_value(cr, uid, record.body, context['active_model'], res_id)
+ email_to = email_temp_pool.get_template_value(cr, uid, record.email_to, context['active_model'], res_id)
+ email_from = email_temp_pool.get_template_value(cr, uid, record.email_from, context['active_model'], res_id)
+ email_cc = email_temp_pool.get_template_value(cr, uid, record.email_cc, context['active_model'], res_id)
+ reply_to = email_temp_pool.get_template_value(cr, uid, record.reply_to, context['active_model'], res_id)
+
+ email_id = email_message_pool.schedule_with_attach(cr, uid, email_from,
+ email_to, subject or False, body or False, context['active_model'], email_cc or False, openobject_id=int(res_id),
+ context=context)
+ return {'type': 'ir.actions.act_window_close'}
+
+ if context.get('mass_mail') and context.get('active_ids') and not context.get('template_id'):
+ self.do_mass_mail(cr, uid, context['active_ids'], record.subject or False, record.body or False, context=context)
+ return {'type': 'ir.actions.act_window_close'}
+
email_id = self.save_to_mailbox(cr, uid, ids, context)
return {'type': 'ir.actions.act_window_close'}
+ def do_mass_mail(self, cr, uid, ids, subject, body, context=None):
+ if context is None:
+ context = {}
+
+ if context.get('active_model'):
+ email_message_pool = self.pool.get('email.message')
+ model_pool = self.pool.get(context['active_model'])
+ for data in model_pool.browse(cr, uid, ids, context=context):
+ email_id = email_message_pool.schedule_with_attach(cr, uid,
+ data.user_id and data.user_id.address_id and data.user_id.address_id.email or False,
+ data.email_from or False, subject, body, model=context['active_model'],
+ email_cc=tools.ustr(data.email_cc or ''), openobject_id=int(data.id), context=context)
+ return True
+
def save_to_mailbox(self, cr, uid, ids, context=None):
email_ids = []
email_message_pool = self.pool.get('email.message')
@@ -220,7 +205,7 @@
message_id = mail.message_id
email_id = email_message_pool.schedule_with_attach(cr, uid, mail.email_from, mail.email_to, mail.subject, mail.body,
model=mail.model, email_cc=mail.email_cc, email_bcc=mail.email_bcc, reply_to=mail.reply_to,
- attach=attachment, message_id=message_id, references=references, openobject_id=int(mail.res_id), debug=mail.debug,
+ attach=attachment, message_id=message_id, references=references, openobject_id=int(mail.res_id),
subtype=mail.sub_type, x_headers=mail.headers, priority=mail.priority, smtp_server_id=mail.smtp_server_id and mail.smtp_server_id.id, context=context)
email_ids.append(email_id)
return email_ids
=== modified file 'mail/wizard/email_compose_message_view.xml'
--- mail/wizard/email_compose_message_view.xml 2011-03-22 13:37:25 +0000
+++ mail/wizard/email_compose_message_view.xml 2011-04-11 12:46:09 +0000
@@ -10,8 +10,6 @@
<form string="Reply Email">
<group col="6" colspan="4">
<field name="model" invisible="1"/>
- <field name="res_id" invisible="context.get('active_model','') != 'ir.ui.menu'"
- colspan="4" on_change="on_change_referred_doc(model, res_id, context)"/>
<field name="smtp_server_id" widget="selection" colspan="4"/>
<field name="email_from" colspan="4" required="1"/>
<field name="email_to" colspan="4" required="1"/>
@@ -33,7 +31,6 @@
<group col="4" colspan="4">
<label string="" colspan="1"/>
<button icon="gtk-close" special="cancel" string="Close"/>
- <button icon="gtk-apply" name="save_to_drafts" string="Save in Drafts" type="object"/>
<button icon="gtk-ok" name="send_mail" string="Send now" type="object"/>
</group>
</form>
=== modified file 'project/wizard/email_compose_message.py'
--- project/wizard/email_compose_message.py 2011-03-01 09:50:57 +0000
+++ project/wizard/email_compose_message.py 2011-04-11 12:46:09 +0000
@@ -54,9 +54,9 @@
if partner and len(partner.address):
result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + partner.address[0].email})
result.update({
- 'description': description or False,
+ 'body': description or False,
'email_to': task_data.project_id.user_id and task_data.project_id.user_id.user_email or False,
- 'name': _("Task '%s' Closed") % task_data.name,
+ 'subject': _("Task '%s' Closed") % task_data.name,
'model': model,
'res_id': resource_id,
})
=== modified file 'project_issue/project_issue.py'
--- project_issue/project_issue.py 2011-04-06 11:16:47 +0000
+++ project_issue/project_issue.py 2011-04-11 12:46:09 +0000
@@ -28,8 +28,6 @@
import tools
from crm import wizard
-wizard.email_compose_message.email_model.append('project.issue')
-
class project_issue_version(osv.osv):
_name = "project.issue.version"
_order = "name desc"
=== added directory 'project_issue/wizard'
=== added file 'project_issue/wizard/__init__.py'
--- project_issue/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ project_issue/wizard/__init__.py 2011-04-11 12:46:09 +0000
@@ -0,0 +1,25 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
+#
+# 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/>.
+#
+##############################################################################
+
+import email_compose_message
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'project_issue/wizard/email_compose_message.py'
--- project_issue/wizard/email_compose_message.py 1970-01-01 00:00:00 +0000
+++ project_issue/wizard/email_compose_message.py 2011-04-11 12:46:09 +0000
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+import tools
+
+class email_compose_message(osv.osv_memory):
+ _inherit = 'email.compose.message'
+
+ def get_value(self, cr, uid, model, resource_id, context=None):
+ if context is None:
+ context = {}
+ result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context)
+ if model == 'project.issue' and resource_id:
+ model_obj = self.pool.get(model)
+ data = model_obj.browse(cr, uid , resource_id, context)
+ result.update({
+ 'subject' : data.name or False,
+ 'email_to' : data.email_from or False,
+ 'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or False,
+ 'body' : '\n' + (tools.ustr(data.user_id.signature or '')),
+ 'email_cc' : tools.ustr(data.email_cc or ''),
+ 'model': model or False,
+ 'res_id': resource_id or False,
+ })
+ return result
+
+email_compose_message()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'project_planning/__init__.py'
--- project_planning/__init__.py 2011-01-14 00:11:01 +0000
+++ project_planning/__init__.py 2011-04-11 12:46:09 +0000
@@ -21,5 +21,6 @@
import project_planning
import report
+import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added directory 'project_planning/wizard'
=== added file 'project_planning/wizard/__init__.py'
--- project_planning/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ project_planning/wizard/__init__.py 2011-04-11 12:46:09 +0000
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
+#
+# 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/>.
+#
+##############################################################################
+
+import email_compose_message
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'project_planning/wizard/email_compose_message.py'
--- project_planning/wizard/email_compose_message.py 1970-01-01 00:00:00 +0000
+++ project_planning/wizard/email_compose_message.py 2011-04-11 12:46:09 +0000
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+import tools
+
+class email_compose_message(osv.osv_memory):
+ _inherit = 'email.compose.message'
+
+ def get_value(self, cr, uid, model, resource_id, context=None):
+ if context is None:
+ context = {}
+ result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context)
+ if model == 'project.task' and resource_id:
+ model_obj = self.pool.get(model)
+ data = model_obj.browse(cr, uid , resource_id, context)
+ result.update({
+ 'subject' : data.name or False,
+ 'email_to' : data.user_id.user_email or False,
+ 'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or False,
+ 'body' : '\n' + (tools.ustr(data.user_id.signature or '')),
+ 'model': model or False,
+ 'res_id': resource_id or False,
+ })
+ return result
+
+email_compose_message()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'project_scrum/wizard/email_compose_message.py'
--- project_scrum/wizard/email_compose_message.py 2011-03-01 06:57:48 +0000
+++ project_scrum/wizard/email_compose_message.py 2011-04-11 12:46:09 +0000
@@ -47,8 +47,8 @@
subject = _("Scrum Meeting : %s") %(meeting.date)
message = _("Hello , \nI am sending you Scrum Meeting : %s for the Sprint '%s' of Project '%s'") %(meeting.date, sprint.name, sprint.project_id.name)
result.update({
- 'name': subject,
- 'description': message,
+ 'subject': subject,
+ 'body': message,
'model': model,
'res_id': resource_id
})
Follow ups