From 1513a9ae77e9cba0909cfb97da4f5548b7012da1 Mon Sep 17 00:00:00 2001 From: "YSA (Openerp)" Date: Tue, 1 Feb 2011 17:13:08 +0530 Subject: [PATCH 001/278] [IMP] clean email_template module, merge email_template and mail_gateway module, developed email_gateway module. task ID-2007. bzr revid: ysa@tinyerp.com-20110201114308-nwb7qzj8ko99eerw --- addons/{mail_gateway => email}/__init__.py | 3 +- addons/email/__openerp__.py | 46 ++++ .../email_smtp_server.py} | 106 +++----- .../email_smtp_server_view.xml} | 55 ++--- .../email/email_template_scheduler_data.xml | 15 ++ .../email_view.xml} | 0 .../mail_gateway.py => email/emails.py} | 2 +- addons/{mail_gateway => email}/i18n/de.po | 0 addons/{mail_gateway => email}/i18n/es.po | 0 addons/{mail_gateway => email}/i18n/fr.po | 0 addons/{mail_gateway => email}/i18n/hu.po | 0 addons/{mail_gateway => email}/i18n/it.po | 0 addons/{mail_gateway => email}/i18n/lt.po | 0 addons/{mail_gateway => email}/i18n/lv.po | 0 .../i18n/mail_gateway.pot | 0 addons/{mail_gateway => email}/i18n/nl.po | 0 addons/{mail_gateway => email}/i18n/pl.po | 0 addons/{mail_gateway => email}/i18n/pt.po | 0 addons/{mail_gateway => email}/i18n/pt_BR.po | 0 addons/{mail_gateway => email}/i18n/ro.po | 0 addons/{mail_gateway => email}/i18n/ru.po | 0 addons/{mail_gateway => email}/i18n/sl.po | 0 .../{mail_gateway => email}/i18n/sr@latin.po | 0 addons/{mail_gateway => email}/i18n/sv.po | 0 addons/{mail_gateway => email}/i18n/zh_CN.po | 0 addons/{mail_gateway => email}/res_partner.py | 0 .../res_partner_view.xml | 0 .../scripts/__init__.py | 0 .../scripts/openerp_mailgate/__init__.py | 0 .../openerp_mailgate/openerp_mailgate.py | 0 .../security/ir.model.access.csv | 0 addons/email_gateway/__init__.py | 25 ++ .../__openerp__.py | 5 +- addons/email_gateway/email_gateway.py | 231 ++++++++++++++++++ addons/email_gateway/email_gateway_view.xml | 119 +++++++++ .../security/ir.model.access.csv | 1 + addons/email_template/__init__.py | 2 - addons/email_template/__openerp__.py | 6 +- addons/email_template/email_template.py | 126 +--------- .../email_template/email_template_mailbox.py | 213 ---------------- .../email_template_mailbox_view.xml | 134 ---------- addons/email_template/email_template_view.xml | 49 +--- .../email_template_workflow.xml | 64 ----- .../security/ir.model.access.csv | 3 - addons/email_template/wizard/__init__.py | 1 + .../wizard/email_template_preview.py | 135 ++++++++++ .../wizard/email_template_preview_view.xml | 50 ++++ .../wizard/email_template_send_wizard.py | 24 +- 48 files changed, 705 insertions(+), 710 deletions(-) rename addons/{mail_gateway => email}/__init__.py (96%) create mode 100644 addons/email/__openerp__.py rename addons/{email_template/email_template_account.py => email/email_smtp_server.py} (86%) rename addons/{email_template/email_template_account_view.xml => email/email_smtp_server_view.xml} (66%) create mode 100644 addons/email/email_template_scheduler_data.xml rename addons/{mail_gateway/mail_gateway_view.xml => email/email_view.xml} (100%) rename addons/{mail_gateway/mail_gateway.py => email/emails.py} (99%) rename addons/{mail_gateway => email}/i18n/de.po (100%) rename addons/{mail_gateway => email}/i18n/es.po (100%) rename addons/{mail_gateway => email}/i18n/fr.po (100%) rename addons/{mail_gateway => email}/i18n/hu.po (100%) rename addons/{mail_gateway => email}/i18n/it.po (100%) rename addons/{mail_gateway => email}/i18n/lt.po (100%) rename addons/{mail_gateway => email}/i18n/lv.po (100%) rename addons/{mail_gateway => email}/i18n/mail_gateway.pot (100%) rename addons/{mail_gateway => email}/i18n/nl.po (100%) rename addons/{mail_gateway => email}/i18n/pl.po (100%) rename addons/{mail_gateway => email}/i18n/pt.po (100%) rename addons/{mail_gateway => email}/i18n/pt_BR.po (100%) rename addons/{mail_gateway => email}/i18n/ro.po (100%) rename addons/{mail_gateway => email}/i18n/ru.po (100%) rename addons/{mail_gateway => email}/i18n/sl.po (100%) rename addons/{mail_gateway => email}/i18n/sr@latin.po (100%) rename addons/{mail_gateway => email}/i18n/sv.po (100%) rename addons/{mail_gateway => email}/i18n/zh_CN.po (100%) rename addons/{mail_gateway => email}/res_partner.py (100%) rename addons/{mail_gateway => email}/res_partner_view.xml (100%) rename addons/{mail_gateway => email}/scripts/__init__.py (100%) rename addons/{mail_gateway => email}/scripts/openerp_mailgate/__init__.py (100%) rename addons/{mail_gateway => email}/scripts/openerp_mailgate/openerp_mailgate.py (100%) rename addons/{mail_gateway => email}/security/ir.model.access.csv (100%) create mode 100644 addons/email_gateway/__init__.py rename addons/{mail_gateway => email_gateway}/__openerp__.py (94%) create mode 100644 addons/email_gateway/email_gateway.py create mode 100644 addons/email_gateway/email_gateway_view.xml create mode 100644 addons/email_gateway/security/ir.model.access.csv delete mode 100644 addons/email_template/email_template_mailbox.py delete mode 100644 addons/email_template/email_template_mailbox_view.xml delete mode 100644 addons/email_template/email_template_workflow.xml create mode 100644 addons/email_template/wizard/email_template_preview.py create mode 100644 addons/email_template/wizard/email_template_preview_view.xml diff --git a/addons/mail_gateway/__init__.py b/addons/email/__init__.py similarity index 96% rename from addons/mail_gateway/__init__.py rename to addons/email/__init__.py index 6526541a068..b78d77029a9 100644 --- a/addons/mail_gateway/__init__.py +++ b/addons/email/__init__.py @@ -19,8 +19,9 @@ # ############################################################################## -import mail_gateway +import emails import res_partner +import email_smtp_server # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/email/__openerp__.py b/addons/email/__openerp__.py new file mode 100644 index 00000000000..c15aef98a2a --- /dev/null +++ b/addons/email/__openerp__.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +{ + 'name': 'Email Gateway System', + 'version': '1.0', + 'category': 'Generic Modules/Mail Service', + 'description': """The generic email gateway system allows to send and receive emails + * History for Emails + * Easy Integration with any Module""", + 'author': 'OpenERP SA', + 'website': 'http://www.openerp.com', + 'depends': ['base', 'base_tools'], + 'init_xml': [], + 'update_xml': [ + "email_view.xml", + "res_partner_view.xml", + 'email_smtp_server_view.xml', + 'security/ir.model.access.csv', +# 'email_smtp_server_data.xml' + + ], + 'demo_xml': [], + 'installable': True, + 'active': False, + 'certificate': '001056784984222247309', +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/email_template/email_template_account.py b/addons/email/email_smtp_server.py similarity index 86% rename from addons/email_template/email_template_account.py rename to addons/email/email_smtp_server.py index 462baa1672d..baf5fcc0f40 100644 --- a/addons/email_template/email_template_account.py +++ b/addons/email/email_smtp_server.py @@ -65,11 +65,11 @@ def extract_emails_from_dict(addresses={}): result['all-recipients'].extend(emails) return result -class email_template_account(osv.osv): +class email_smtp_server(osv.osv): """ Object to store email account settings """ - _name = "email_template.account" + _name = "email.smtp_server" _known_content_types = ['multipart/mixed', 'multipart/alternative', 'multipart/related', @@ -81,14 +81,8 @@ class email_template_account(osv.osv): size=64, required=True, readonly=True, select=True, help="The description is used as the Sender name along with the provided From Email, \ -unless it is already specified in the From Email, e.g: John Doe ", +unless it is already specified in the From Email, e.g: John Doe ", states={'draft':[('readonly', False)]}), - 'auto_delete': fields.boolean('Auto Delete', size=64, readonly=True, - help="Permanently delete emails after sending", - states={'draft':[('readonly', False)]}), - 'user':fields.many2one('res.users', - 'Related User', required=True, - readonly=True, states={'draft':[('readonly', False)]}), 'email_id': fields.char('From Email', size=120, required=True, readonly=True, states={'draft':[('readonly', False)]} , @@ -112,33 +106,16 @@ unless it is already specified in the From Email, e.g: John Doe ", states={'draft':[('readonly', False)]}), 'smtptls':fields.boolean('TLS', states={'draft':[('readonly', False)]}, readonly=True), - + 'smtpssl':fields.boolean('SSL/TLS (only in python 2.6)', states={'draft':[('readonly', False)]}, readonly=True), - 'send_pref':fields.selection([ - ('html', 'HTML, otherwise Text'), - ('text', 'Text, otherwise HTML'), - ('alternative', 'Both HTML & Text (Alternative)'), - ('mixed', 'Both HTML & Text (Mixed)') - ], 'Mail Format', required=True), - 'company':fields.selection([ - ('yes', 'Yes'), - ('no', 'No') - ], 'Corporate', - readonly=True, - help="Select if this mail account does not belong " \ - "to specific user but to the organization as a whole. " \ - "eg: info@companydomain.com", - required=True, states={ - 'draft':[('readonly', False)] - }), - 'state':fields.selection([ ('draft', 'Initiated'), ('suspended', 'Suspended'), ('approved', 'Approved') ], 'State', required=True, readonly=True), + 'default': fields.boolean('Default', help="Only one account can be default at a time"), } _defaults = { @@ -154,12 +131,9 @@ unless it is already specified in the From Email, e.g: John Doe ", 'state':lambda * a:'draft', 'smtpport':lambda *a:25, 'smtpserver':lambda *a:'localhost', - 'company':lambda *a:'yes', - 'user':lambda self, cursor, user, context:user, - 'send_pref':lambda *a: 'html', 'smtptls':lambda *a:True, } - + _sql_constraints = [ ( 'email_uniq', @@ -167,46 +141,34 @@ unless it is already specified in the From Email, e.g: John Doe ", 'Another setting already exists with this email ID !') ] - def name_get(self, cr, uid, ids, context=None): - return [(a["id"], "%s (%s)" % (a['email_id'], a['name'])) for a in self.read(cr, uid, ids, ['name', 'email_id'], context=context)] - - def _constraint_unique(self, cursor, user, ids, context=None): - """ - This makes sure that you dont give personal - users two accounts with same ID (Validated in sql constaints) - However this constraint exempts company accounts. - Any no of co accounts for a user is allowed - """ - if self.read(cursor, user, ids, ['company'])[0]['company'] == 'no': - accounts = self.search(cursor, user, [ - ('user', '=', user), - ('company', '=', 'no') - ]) - if len(accounts) > 1 : - return False - else : - return True + def _constraint_unique(self, cr, uid, ids, context=None): + default_ids = self.search(cr, uid, [('default','=',True)]) + if len(default_ids) > 1: + return False else: return True - + _constraints = [ (_constraint_unique, - 'Error: You are not allowed to have more than 1 account.', + 'Error: You are not allowed to set default more than 1 account.', []) ] + def name_get(self, cr, uid, ids, context=None): + return [(a["id"], "%s (%s)" % (a['email_id'], a['name'])) for a in self.read(cr, uid, ids, ['name', 'email_id'], context=context)] + def get_outgoing_server(self, cursor, user, ids, context=None): """ Returns the Out Going Connection (SMTP) object - + @attention: DO NOT USE except_osv IN THIS METHOD @param cursor: Database Cursor @param user: ID of current user - @param ids: ID/list of ids of current object for + @param ids: ID/list of ids of current object for which connection is required First ID will be chosen from lists @param context: Context - + @return: SMTP server object or Exception """ #Type cast ids to integer @@ -214,7 +176,7 @@ unless it is already specified in the From Email, e.g: John Doe ", ids = ids[0] this_object = self.browse(cursor, user, ids, context=context) if this_object: - if this_object.smtpserver and this_object.smtpport: + if this_object.smtpserver and this_object.smtpport: try: if this_object.smtpssl: serv = smtplib.SMTP_SSL(this_object.smtpserver, this_object.smtpport) @@ -234,14 +196,14 @@ unless it is already specified in the From Email, e.g: John Doe ", return serv raise Exception(_("SMTP SERVER or PORT not specified")) raise Exception(_("Core connection for the given ID does not exist")) - + def check_outgoing_connection(self, cursor, user, ids, context=None): """ checks SMTP credentials and confirms if outgoing connection works (Attached to button) @param cursor: Database Cursor @param user: ID of current user - @param ids: list of ids of current object for + @param ids: list of ids of current object for which connection is required @param context: Context """ @@ -255,7 +217,7 @@ unless it is already specified in the From Email, e.g: John Doe ", _("Out going connection test failed"), _("Reason: %s") % error ) - + def do_approval(self, cr, uid, ids, context=None): #TODO: Check if user has rights self.write(cr, uid, ids, {'state':'approved'}, context=context) @@ -279,12 +241,12 @@ unless it is already specified in the From Email, e.g: John Doe ", else: logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:Account not approved") % id) return False - + #**************************** MAIL SENDING FEATURES ***********************# - + def send_mail(self, cr, uid, ids, addresses, subject='', body=None, payload=None, message_id=None, context=None): #TODO: Replace all this with a single email object if body is None: @@ -294,7 +256,7 @@ unless it is already specified in the From Email, e.g: John Doe ", if context is None: context = {} logger = netsvc.Logger() - for id in ids: + for id in ids: core_obj = self.browse(cr, uid, id, context) serv = self.smtp_connection(cr, uid, id) if serv: @@ -307,7 +269,7 @@ unless it is already specified in the From Email, e.g: John Doe ", text_part = MIMEMultipart(_subtype=text_subtype) payload_part.attach(text_part) else: - # otherwise a single multipart/mixed will do the whole job + # otherwise a single multipart/mixed will do the whole job payload_part = text_part = MIMEMultipart(_subtype=text_subtype) if subject: @@ -322,7 +284,7 @@ unless it is already specified in the From Email, e.g: John Doe ", payload_part['From'] = sender_name + " <" + core_obj.email_id + ">" payload_part['Organization'] = tools.ustr(core_obj.user.company_id.name) payload_part['Date'] = formatdate() - addresses_l = extract_emails_from_dict(addresses) + addresses_l = extract_emails_from_dict(addresses) if addresses_l['To']: payload_part['To'] = u','.join(addresses_l['To']) if addresses_l['CC']: @@ -430,28 +392,28 @@ unless it is already specified in the From Email, e.g: John Doe ", e) ) return date_as_date - + def send_receive(self, cr, uid, ids, context=None): for id in ids: ctx = context.copy() ctx['filters'] = [('account_id', '=', id)] self.pool.get('email_template.mailbox').send_all_mail(cr, uid, [], context=ctx) return True - + def decode_header_text(self, text): """ Decode internationalized headers RFC2822. - To, CC, BCC, Subject fields can contain + To, CC, BCC, Subject fields can contain text slices with different encodes, like: - =?iso-8859-1?Q?Enric_Mart=ED?= , + =?iso-8859-1?Q?Enric_Mart=ED?= , =?Windows-1252?Q?David_G=F3mez?= Sometimes they include extra " character at the beginning/ end of the contact name, like: "=?iso-8859-1?Q?Enric_Mart=ED?=" - and decode_header() does not work well, so we use regular + and decode_header() does not work well, so we use regular expressions (?= ? ? ?=) to split the text slices """ if not text: - return text + return text p = re.compile("(=\?.*?\?.\?.*?\?=)") text2 = '' try: @@ -465,6 +427,6 @@ unless it is already specified in the From Email, e.g: John Doe ", return text return text2 -email_template_account() +email_smtp_server() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/email_template/email_template_account_view.xml b/addons/email/email_smtp_server_view.xml similarity index 66% rename from addons/email_template/email_template_account_view.xml rename to addons/email/email_smtp_server_view.xml index 00429efc16c..f1504825327 100644 --- a/addons/email_template/email_template_account_view.xml +++ b/addons/email/email_smtp_server_view.xml @@ -2,19 +2,19 @@ - + - + - - email_template.account.form - email_template.account + + email.smtp_server.form + email.smtp_server form -
+ + @@ -25,18 +25,14 @@ - - - - @@ -51,53 +47,46 @@ - - email_template.account.tree - email_template.account + + email.smtp_server.tree + email.smtp_server tree - - - - email_template.account.search - email_template.account + + email_smtp.server.search + email.smtp_server search - + - - - - - - - Accounts - email_template.account + + Smtp Server + email.smtp_server form form,tree - + {'group_by': [], 'search_default_draft': 1, 'search_default_my': 1} - + - + @@ -113,8 +102,8 @@ - + diff --git a/addons/email/email_template_scheduler_data.xml b/addons/email/email_template_scheduler_data.xml new file mode 100644 index 00000000000..f2ee000c16a --- /dev/null +++ b/addons/email/email_template_scheduler_data.xml @@ -0,0 +1,15 @@ + + + + + Administrator + + + example@test.com + draft + + localhost + + + + diff --git a/addons/mail_gateway/mail_gateway_view.xml b/addons/email/email_view.xml similarity index 100% rename from addons/mail_gateway/mail_gateway_view.xml rename to addons/email/email_view.xml diff --git a/addons/mail_gateway/mail_gateway.py b/addons/email/emails.py similarity index 99% rename from addons/mail_gateway/mail_gateway.py rename to addons/email/emails.py index 156586c2edd..b23aea0c901 100644 --- a/addons/mail_gateway/mail_gateway.py +++ b/addons/email/emails.py @@ -220,7 +220,7 @@ class mailgate_message(osv.osv): action_data = False action_pool = self.pool.get('ir.actions.act_window') message_pool = self.browse(cr ,uid, ids, context=context)[0] - att_ids = [x.id for x in message_pool.attachment_ids] + att_ids = [x.id for x in message_pool.attachment_ids] action_ids = action_pool.search(cr, uid, [('res_model', '=', 'ir.attachment')]) if action_ids: action_data = action_pool.read(cr, uid, action_ids[0], context=context) diff --git a/addons/mail_gateway/i18n/de.po b/addons/email/i18n/de.po similarity index 100% rename from addons/mail_gateway/i18n/de.po rename to addons/email/i18n/de.po diff --git a/addons/mail_gateway/i18n/es.po b/addons/email/i18n/es.po similarity index 100% rename from addons/mail_gateway/i18n/es.po rename to addons/email/i18n/es.po diff --git a/addons/mail_gateway/i18n/fr.po b/addons/email/i18n/fr.po similarity index 100% rename from addons/mail_gateway/i18n/fr.po rename to addons/email/i18n/fr.po diff --git a/addons/mail_gateway/i18n/hu.po b/addons/email/i18n/hu.po similarity index 100% rename from addons/mail_gateway/i18n/hu.po rename to addons/email/i18n/hu.po diff --git a/addons/mail_gateway/i18n/it.po b/addons/email/i18n/it.po similarity index 100% rename from addons/mail_gateway/i18n/it.po rename to addons/email/i18n/it.po diff --git a/addons/mail_gateway/i18n/lt.po b/addons/email/i18n/lt.po similarity index 100% rename from addons/mail_gateway/i18n/lt.po rename to addons/email/i18n/lt.po diff --git a/addons/mail_gateway/i18n/lv.po b/addons/email/i18n/lv.po similarity index 100% rename from addons/mail_gateway/i18n/lv.po rename to addons/email/i18n/lv.po diff --git a/addons/mail_gateway/i18n/mail_gateway.pot b/addons/email/i18n/mail_gateway.pot similarity index 100% rename from addons/mail_gateway/i18n/mail_gateway.pot rename to addons/email/i18n/mail_gateway.pot diff --git a/addons/mail_gateway/i18n/nl.po b/addons/email/i18n/nl.po similarity index 100% rename from addons/mail_gateway/i18n/nl.po rename to addons/email/i18n/nl.po diff --git a/addons/mail_gateway/i18n/pl.po b/addons/email/i18n/pl.po similarity index 100% rename from addons/mail_gateway/i18n/pl.po rename to addons/email/i18n/pl.po diff --git a/addons/mail_gateway/i18n/pt.po b/addons/email/i18n/pt.po similarity index 100% rename from addons/mail_gateway/i18n/pt.po rename to addons/email/i18n/pt.po diff --git a/addons/mail_gateway/i18n/pt_BR.po b/addons/email/i18n/pt_BR.po similarity index 100% rename from addons/mail_gateway/i18n/pt_BR.po rename to addons/email/i18n/pt_BR.po diff --git a/addons/mail_gateway/i18n/ro.po b/addons/email/i18n/ro.po similarity index 100% rename from addons/mail_gateway/i18n/ro.po rename to addons/email/i18n/ro.po diff --git a/addons/mail_gateway/i18n/ru.po b/addons/email/i18n/ru.po similarity index 100% rename from addons/mail_gateway/i18n/ru.po rename to addons/email/i18n/ru.po diff --git a/addons/mail_gateway/i18n/sl.po b/addons/email/i18n/sl.po similarity index 100% rename from addons/mail_gateway/i18n/sl.po rename to addons/email/i18n/sl.po diff --git a/addons/mail_gateway/i18n/sr@latin.po b/addons/email/i18n/sr@latin.po similarity index 100% rename from addons/mail_gateway/i18n/sr@latin.po rename to addons/email/i18n/sr@latin.po diff --git a/addons/mail_gateway/i18n/sv.po b/addons/email/i18n/sv.po similarity index 100% rename from addons/mail_gateway/i18n/sv.po rename to addons/email/i18n/sv.po diff --git a/addons/mail_gateway/i18n/zh_CN.po b/addons/email/i18n/zh_CN.po similarity index 100% rename from addons/mail_gateway/i18n/zh_CN.po rename to addons/email/i18n/zh_CN.po diff --git a/addons/mail_gateway/res_partner.py b/addons/email/res_partner.py similarity index 100% rename from addons/mail_gateway/res_partner.py rename to addons/email/res_partner.py diff --git a/addons/mail_gateway/res_partner_view.xml b/addons/email/res_partner_view.xml similarity index 100% rename from addons/mail_gateway/res_partner_view.xml rename to addons/email/res_partner_view.xml diff --git a/addons/mail_gateway/scripts/__init__.py b/addons/email/scripts/__init__.py similarity index 100% rename from addons/mail_gateway/scripts/__init__.py rename to addons/email/scripts/__init__.py diff --git a/addons/mail_gateway/scripts/openerp_mailgate/__init__.py b/addons/email/scripts/openerp_mailgate/__init__.py similarity index 100% rename from addons/mail_gateway/scripts/openerp_mailgate/__init__.py rename to addons/email/scripts/openerp_mailgate/__init__.py diff --git a/addons/mail_gateway/scripts/openerp_mailgate/openerp_mailgate.py b/addons/email/scripts/openerp_mailgate/openerp_mailgate.py similarity index 100% rename from addons/mail_gateway/scripts/openerp_mailgate/openerp_mailgate.py rename to addons/email/scripts/openerp_mailgate/openerp_mailgate.py diff --git a/addons/mail_gateway/security/ir.model.access.csv b/addons/email/security/ir.model.access.csv similarity index 100% rename from addons/mail_gateway/security/ir.model.access.csv rename to addons/email/security/ir.model.access.csv diff --git a/addons/email_gateway/__init__.py b/addons/email_gateway/__init__.py new file mode 100644 index 00000000000..4ce06ccc868 --- /dev/null +++ b/addons/email_gateway/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## + +import email_gateway + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/mail_gateway/__openerp__.py b/addons/email_gateway/__openerp__.py similarity index 94% rename from addons/mail_gateway/__openerp__.py rename to addons/email_gateway/__openerp__.py index e91257fd148..6748493ebe7 100644 --- a/addons/mail_gateway/__openerp__.py +++ b/addons/email_gateway/__openerp__.py @@ -28,11 +28,10 @@ * Easy Integration with any Module""", 'author': 'OpenERP SA', 'website': 'http://www.openerp.com', - 'depends': ['base'], + 'depends': ['base','email'], 'init_xml': [], 'update_xml': [ - "mail_gateway_view.xml", - "res_partner_view.xml", + "email_gateway_view.xml", 'security/ir.model.access.csv' ], diff --git a/addons/email_gateway/email_gateway.py b/addons/email_gateway/email_gateway.py new file mode 100644 index 00000000000..b153d200e5c --- /dev/null +++ b/addons/email_gateway/email_gateway.py @@ -0,0 +1,231 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL () +# +# 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 osv import osv, fields +import time +import tools +import binascii +import email +from email.header import decode_header +from email.utils import parsedate +import base64 +import re +from tools.translate import _ +import logging +import xmlrpclib + +_logger = logging.getLogger('mailgate') + +def format_date_tz(date, tz=None): + if not date: + return 'n/a' + format = tools.DEFAULT_SERVER_DATETIME_FORMAT + return tools.server_to_local_timestamp(date, format, format, tz) + +class email_message(osv.osv): + ''' + Mailgateway Message + ''' + def open_document(self, cr, uid, ids, context=None): + """ To Open Document + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: the ID of messages + @param context: A standard dictionary + """ + action_data = False + if ids: + message_id = ids[0] + mailgate_data = self.browse(cr, uid, message_id, context=context) + model = mailgate_data.model + res_id = mailgate_data.res_id + + action_pool = self.pool.get('ir.actions.act_window') + action_ids = action_pool.search(cr, uid, [('res_model', '=', model)]) + if action_ids: + action_data = action_pool.read(cr, uid, action_ids[0], context=context) + action_data.update({ + 'domain' : "[('id','=',%d)]"%(res_id), + 'nodestroy': True, + 'context': {} + }) + return action_data + + def open_attachment(self, cr, uid, ids, context=None): + """ To Open attachments + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param ids: the ID of messages + @param context: A standard dictionary + """ + action_data = False + action_pool = self.pool.get('ir.actions.act_window') + message_pool = self.browse(cr ,uid, ids, context=context)[0] + att_ids = [x.id for x in message_pool.attachment_ids] + action_ids = action_pool.search(cr, uid, [('res_model', '=', 'ir.attachment')]) + if action_ids: + action_data = action_pool.read(cr, uid, action_ids[0], context=context) + action_data.update({ + 'domain': [('id','in',att_ids)], + 'nodestroy': True + }) + return action_data + + def truncate_data(self, cr, uid, data, context=None): + data_list = data and data.split('\n') or [] + if len(data_list) > 3: + res = '\n\t'.join(data_list[:3]) + '...' + else: + res = '\n\t'.join(data_list) + return res + + def _get_display_text(self, cr, uid, ids, name, arg, context=None): + if context is None: + context = {} + tz = context.get('tz') + result = {} + for message in self.browse(cr, uid, ids, context=context): + msg_txt = '' + if message.history: + msg_txt += (message.email_from or '/') + _(' wrote on ') + format_date_tz(message.date, tz) + ':\n\t' + if message.description: + msg_txt += self.truncate_data(cr, uid, message.description, context=context) + else: + msg_txt = (message.user_id.name or '/') + _(' on ') + format_date_tz(message.date, tz) + ':\n\t' + if message.name == _('Opportunity'): + msg_txt += _("Converted to Opportunity") + elif message.name == _('Note'): + msg_txt = (message.user_id.name or '/') + _(' added note on ') + format_date_tz(message.date, tz) + ':\n\t' + msg_txt += self.truncate_data(cr, uid, message.description, context=context) + elif message.name == _('Stage'): + msg_txt += _("Changed Stage to: ") + message.description + else: + msg_txt += _("Changed Status to: ") + message.name + result[message.id] = msg_txt + return result + + _name = 'email.message' + _description = 'Email Message' + _order = 'date desc' + _columns = { + 'name':fields.text('Subject', readonly=True), + 'model': fields.char('Object Name', size=128, select=1, readonly=True), + 'res_id': fields.integer('Resource ID', select=1, readonly=True), + 'ref_id': fields.char('Reference Id', size=256, readonly=True, help="Message Id in Email Server.", select=True), + 'date': fields.datetime('Date', readonly=True), + 'history': fields.boolean('Is History?', readonly=True), + 'user_id': fields.many2one('res.users', 'User Responsible', readonly=True), + 'message': fields.text('Description', readonly=True), + 'email_from': fields.char('From', size=128, help="Email From", readonly=True), + 'email_to': fields.char('To', help="Email Recipients", size=256, readonly=True), + 'email_cc': fields.char('Cc', help="Carbon Copy Email Recipients", size=256, readonly=True), + 'email_bcc': fields.char('Bcc', help='Blind Carbon Copy Email Recipients', size=256, readonly=True), + 'message_id': fields.char('Message Id', size=1024, readonly=True, help="Message Id on Email.", select=True), + 'references': fields.text('References', readonly=True, help="References emails."), + 'description': fields.text('Description', readonly=True), + 'partner_id': fields.many2one('res.partner', 'Partner', required=False), + 'attachment_ids': fields.many2many('ir.attachment', 'message_attachment_rel', 'message_id', 'attachment_id', 'Attachments', readonly=True), + 'display_text': fields.function(_get_display_text, method=True, type='text', size="512", string='Display Text'), + 'reply_to':fields.char('Reply-To', size=250, readonly=True), + } + + def init(self, cr): + cr.execute("""SELECT indexname + FROM pg_indexes + WHERE indexname = 'mailgate_message_res_id_model_idx'""") + if not cr.fetchone(): + cr.execute("""CREATE INDEX mailgate_message_res_id_model_idx + ON mailgate_message (model, res_id)""") + +# def run_mail_scheduler(self, cursor, user, context=None): +# """ +# This method is called by OpenERP Scheduler +# to periodically send emails +# """ +# try: +# self.send_all_mail(cursor, user, context=context) +# except Exception, e: +# LOGGER.notifyChannel( +# "Email Template", +# netsvc.LOG_ERROR, +# _("Error sending mail: %s") % e) +# +# def send_all_mail(self, cr, uid, ids=None, context=None): +# if ids is None: +# ids = [] +# if context is None: +# context = {} +# filters = [('folder', '=', 'outbox'), ('state', '!=', 'sending')] +# if 'filters' in context.keys(): +# for each_filter in context['filters']: +# filters.append(each_filter) +# ids = self.search(cr, uid, filters, context=context) +# self.write(cr, uid, ids, {'state':'sending'}, context) +# self.send_this_mail(cr, uid, ids, context) +# return True +# +# def send_this_mail(self, cr, uid, ids=None, context=None): +# #previous method to send email (link with email account can be found at the revision 4172 and below +# result = True +# attachment_pool = self.pool.get('ir.attachment') +# for id in (ids or []): +# try: +# account_obj = self.pool.get('email.smtp_server') +# values = self.read(cr, uid, id, [], context) +# payload = {} +# if values['attachments_ids']: +# for attid in values['attachments_ids']: +# attachment = attachment_pool.browse(cr, uid, attid, context)#,['datas_fname','datas']) +# payload[attachment.datas_fname] = attachment.datas +# result = account_obj.send_mail(cr, uid, +# [values['account_id'][0]], +# {'To':values.get('email_to') or u'', +# 'CC':values.get('email_cc') or u'', +# 'BCC':values.get('email_bcc') or u'', +# 'Reply-To':values.get('reply_to') or u''}, +# values['subject'] or u'', +# {'text':values.get('body_text') or u'', 'html':values.get('body_html') or u''}, +# payload=payload, +# message_id=values['message_id'], +# context=context) +# if result == True: +# account = account_obj.browse(cr, uid, values['account_id'][0], context=context) +# if account.auto_delete: +# self.write(cr, uid, id, {'folder': 'trash'}, context=context) +# self.unlink(cr, uid, [id], context=context) +# # Remove attachments for this mail +# attachment_pool.unlink(cr, uid, values['attachments_ids'], context=context) +# else: +# self.write(cr, uid, id, {'folder':'sent', 'state':'na', 'date_mail':time.strftime("%Y-%m-%d %H:%M:%S")}, context) +# else: +# error = result['error_msg'] +# +# except Exception, error: +# logger = netsvc.Logger() +# logger.notifyChannel("email-template", netsvc.LOG_ERROR, _("Sending of Mail %s failed. Probable Reason:Could not login to server\nError: %s") % (id, error)) +# self.write(cr, uid, id, {'state':'na'}, context) +# return result + +email_message() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/email_gateway/email_gateway_view.xml b/addons/email_gateway/email_gateway_view.xml new file mode 100644 index 00000000000..b8f8415c389 --- /dev/null +++ b/addons/email_gateway/email_gateway_view.xml @@ -0,0 +1,119 @@ + + + + + + email.message.form + email.message + form + + + + + + + + + + + + + + + + + + + + + + + + - - Forward to Partner crm.lead.forward.to.partner form form - + new From 204ecec4f28ca095de960de798ada77c16272e8d Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Fri, 25 Feb 2011 12:24:03 +0530 Subject: [PATCH 118/278] [IMP] crm, emails,crm_partner_assign:- change model name crm_send_new_email_attachment with crm_add_note_email_attachment in crm module, and bug fix of web-client wizard not close must return thy type:ir.action.act_window.close' in button click bzr revid: ysa@tinyerp.com-20110225065403-expnty80rkb9m2jr --- addons/crm/wizard/crm_add_note.py | 8 ++++---- .../crm_partner_assign/wizard/crm_forward_to_partner.py | 4 ++-- .../email_template/wizard/email_template_send_wizard.py | 4 ++-- addons/emails/wizard/email_compose_message.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/addons/crm/wizard/crm_add_note.py b/addons/crm/wizard/crm_add_note.py index e9919c059db..ff89f56cd9d 100644 --- a/addons/crm/wizard/crm_add_note.py +++ b/addons/crm/wizard/crm_add_note.py @@ -5,8 +5,8 @@ import base64 AVAILABLE_STATES = crm.AVAILABLE_STATES + [('unchanged', 'Unchanged')] -class crm_send_new_email_attachment(osv.osv_memory): - _name = 'crm.send.mail.attachment' +class crm_add_note_email_attachment(osv.osv_memory): + _name = 'crm.add.note.email.attachment' _columns = { 'binary' : fields.binary('Attachment', required=True), @@ -14,7 +14,7 @@ class crm_send_new_email_attachment(osv.osv_memory): 'wizard_id' : fields.many2one('crm.add.note', 'Wizard', required=True), } -crm_send_new_email_attachment() +crm_add_note_email_attachment() class crm_add_note(osv.osv_memory): """Adds a new note to the case.""" @@ -25,7 +25,7 @@ class crm_add_note(osv.osv_memory): 'body': fields.text('Note Body', required=True), 'state': fields.selection(AVAILABLE_STATES, string='Set New State To', required=True), - 'attachment_ids' : fields.one2many('crm.send.mail.attachment', 'wizard_id'), + 'attachment_ids' : fields.one2many('crm.add.note.email.attachment', 'wizard_id'), } def action_add(self, cr, uid, ids, context=None): diff --git a/addons/crm_partner_assign/wizard/crm_forward_to_partner.py b/addons/crm_partner_assign/wizard/crm_forward_to_partner.py index ae653ec9c92..9086750aeec 100644 --- a/addons/crm_partner_assign/wizard/crm_forward_to_partner.py +++ b/addons/crm_partner_assign/wizard/crm_forward_to_partner.py @@ -170,14 +170,14 @@ class crm_lead_forward_to_partner(osv.osv_memory): context = {} super(crm_lead_forward_to_partner, self).save_to_drafts(cr, uid, ids, context=context) self.action_forward(cr, uid, ids, context) - return {} + return {'type': 'ir.actions.act_window_close'} def send_mail(self, cr, uid, ids, context=None): if context is None: context = {} super(crm_lead_forward_to_partner, self).send_mail(cr, uid, ids, context=context) self.action_forward(cr, uid, ids, context) - return {} + return {'type': 'ir.actions.act_window_close'} def action_forward(self, cr, uid, ids, context=None): """ diff --git a/addons/email_template/wizard/email_template_send_wizard.py b/addons/email_template/wizard/email_template_send_wizard.py index 8911e406a85..4cd2e5294c2 100644 --- a/addons/email_template/wizard/email_template_send_wizard.py +++ b/addons/email_template/wizard/email_template_send_wizard.py @@ -133,13 +133,13 @@ class email_template_send_wizard(osv.osv_memory): context = {} mailid = self.save_to_mailbox(cr, uid, ids, context=context) self.pool.get('email.message').write(cr, uid, mailid, {'folder':'drafts', 'state': 'draft'}, context) - return {} + return {'type': 'ir.actions.act_window_close'} def send_mail(self, cr, uid, ids, context=None): if context is None: context = {} mailid = self.save_to_mailbox(cr, uid, ids, context) - return {} + return {'type': 'ir.actions.act_window_close'} def get_generated(self, cr, uid, ids=None, context=None): if ids is None: diff --git a/addons/emails/wizard/email_compose_message.py b/addons/emails/wizard/email_compose_message.py index 1f4dfb464be..96fe112c533 100644 --- a/addons/emails/wizard/email_compose_message.py +++ b/addons/emails/wizard/email_compose_message.py @@ -141,13 +141,13 @@ class email_compose_message(osv.osv_memory): context = {} email_id = self.save_to_mailbox(cr, uid, ids, context=context) self.pool.get('email.message').write(cr, uid, email_id, {'folder':'drafts', 'state': 'draft'}, context) - return {} + return {'type': 'ir.actions.act_window_close'} def send_mail(self, cr, uid, ids, context=None): if context is None: context = {} email_id = self.save_to_mailbox(cr, uid, ids, context) - return {} + return {'type': 'ir.actions.act_window_close'} def save_to_mailbox(self, cr, uid, ids, context=None): email_ids = [] From 900676436835ca3c8478e8252efd09ed5e85ad24 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Fri, 25 Feb 2011 13:44:18 +0530 Subject: [PATCH 119/278] [REM] email_template: remove email_template_security.xml bzr revid: hmo@tinyerp.com-20110225081418-91ynfdq1klcbv7zi --- addons/email_template/__openerp__.py | 1 - .../email_template/security/email_template_security.xml | 9 --------- 2 files changed, 10 deletions(-) delete mode 100644 addons/email_template/security/email_template_security.xml diff --git a/addons/email_template/__openerp__.py b/addons/email_template/__openerp__.py index fb89261f516..15ccec71ab7 100644 --- a/addons/email_template/__openerp__.py +++ b/addons/email_template/__openerp__.py @@ -32,7 +32,6 @@ """, "init_xml": [], "update_xml": [ - 'security/email_template_security.xml', 'wizard/email_template_preview_view.xml', 'email_template_view.xml', 'wizard/email_template_send_wizard_view.xml', diff --git a/addons/email_template/security/email_template_security.xml b/addons/email_template/security/email_template_security.xml deleted file mode 100644 index e16293f435d..00000000000 --- a/addons/email_template/security/email_template_security.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - Marketing / User - - - - From 5b28eaa8689e8c02dff790afc2d84f644f3ec059 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Fri, 25 Feb 2011 14:41:12 +0530 Subject: [PATCH 120/278] [FIX] fix problem in emails.compose.message wizard. bzr revid: ysa@tinyerp.com-20110225091112-t5pcq27rxk6ln0h3 --- addons/emails/wizard/email_compose_message.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/emails/wizard/email_compose_message.py b/addons/emails/wizard/email_compose_message.py index 96fe112c533..059e5f5e9b0 100644 --- a/addons/emails/wizard/email_compose_message.py +++ b/addons/emails/wizard/email_compose_message.py @@ -31,7 +31,6 @@ class email_compose_message(osv.osv_memory): def default_get(self, cr, uid, fields, context=None): if context is None: context = {} - result = super(email_compose_message, self).default_get(cr, uid, fields, context=context) message_pool = self.pool.get('email.message') message_id = context.get('message_id', False) @@ -120,7 +119,7 @@ class email_compose_message(osv.osv_memory): elif context.get('email_model',False): model = context.get('email_model') model_pool = self.pool.get(model) - record_ids = context.get('record_ids',[]) + record_ids = context.get('active_ids',[]) if not record_ids: record_ids = model_pool.search(cr, uid, []) if model_pool: From 35df09c02820dc3486009b8cf5a88e9c9285ae89 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Fri, 25 Feb 2011 17:27:15 +0530 Subject: [PATCH 121/278] [FIX] crm: set False value in email_from instead of None Value bzr revid: hmo@tinyerp.com-20110225115715-di6jxycn7wvvs5d1 --- addons/crm/wizard/email_compose_message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/wizard/email_compose_message.py b/addons/crm/wizard/email_compose_message.py index 595394478ba..f2241abfdcc 100644 --- a/addons/crm/wizard/email_compose_message.py +++ b/addons/crm/wizard/email_compose_message.py @@ -44,7 +44,7 @@ class email_compose_message(osv.osv_memory): result['email_to'] = data.email_from if 'email_from' in fields: - result['email_from'] = data.user_id and data.user_id.address_id and data.user_id.address_id.email + result['email_from'] = data.user_id and data.user_id.address_id and data.user_id.address_id.email or False if 'description' in fields: result['description'] = '\n' + (tools.ustr(data.user_id.signature or '')) From 0d5cc2663c9fc664f129ba72fe92d2caa17cfc3f Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 28 Feb 2011 14:33:44 +0530 Subject: [PATCH 122/278] [IMP] fetchmail :- imap and pop server fetchmail keep in try and server quit in finally block. bzr revid: ysa@tinyerp.com-20110228090344-uf965sg7hvkrv7o2 --- addons/fetchmail/fetchmail.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 892313c0102..bcd4448beca 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -167,8 +167,8 @@ class email_server(osv.osv): for server in self.browse(cr, uid, ids, context=context): count = 0 user = server.user_id.id or uid - try: - if server.type == 'imap': + if server.type == 'imap': + try: imap_server = self.button_confirm_login(cr, uid, [server.id], context=context) imap_server.select() result, data = imap_server.search(None, '(UNSEEN)') @@ -182,12 +182,17 @@ class email_server(osv.osv): count += 1 logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch/process %s email(s) from %s' % (count, server.name)) + except Exception, e: + logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) + + finally: imap_server.close() imap_server.logout() - elif server.type == 'pop': + elif server.type == 'pop': + try: pop_server = self.button_confirm_login(cr, uid, [server.id], context=context) - pop_server.list() (numMsgs, totalSize) = pop_server.stat() + pop_server.list() for num in range(1, numMsgs + 1): (header, msges, octets) = pop_server.retr(num) msg = '\n'.join(msges) @@ -196,14 +201,12 @@ class email_server(osv.osv): action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) pop_server.dele(num) - - pop_server.quit() - logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch %s email(s) from %s' % (numMsgs, server.name)) + except Exception, e: + logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) - except Exception, e: - logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) - + finally: + pop_server.quit() return True email_server() From 8df17faa84cd69bdb65b7824e936ec64fc37f921 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 28 Feb 2011 14:39:19 +0530 Subject: [PATCH 123/278] [IMP] emails :- add email_from field in search view and remove email filter. bzr revid: ysa@tinyerp.com-20110228090919-r68zey4af7u8btze --- addons/emails/email_view.xml | 1 + addons/fetchmail/fetchmail_view.xml | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/emails/email_view.xml b/addons/emails/email_view.xml index a88764dd883..2201b50dfd3 100644 --- a/addons/emails/email_view.xml +++ b/addons/emails/email_view.xml @@ -101,6 +101,7 @@ + diff --git a/addons/fetchmail/fetchmail_view.xml b/addons/fetchmail/fetchmail_view.xml index f03d8f91a72..fec467083a7 100644 --- a/addons/fetchmail/fetchmail_view.xml +++ b/addons/fetchmail/fetchmail_view.xml @@ -126,10 +126,6 @@ search - - - - From d5494f5ea4a7b50277a040ee22a8bab6741f00af Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 28 Feb 2011 17:09:19 +0530 Subject: [PATCH 124/278] [IMP] emails,crm,project,project_scrum :- improve email.compose.wizard and add blank value add in selection box of template_id field in wizard. if template_id blank then default value set based on current record. bzr revid: ysa@tinyerp.com-20110228113919-d7quaz8uqmjnkuzh --- addons/crm/wizard/email_compose_message.py | 58 +++++++++++-- .../wizard/email_compose_message.py | 24 +----- .../wizard/email_template_preview.py | 6 +- addons/emails/wizard/email_compose_message.py | 3 + .../wizard/email_compose_message.py | 15 ++-- .../project/wizard/email_compose_message.py | 85 +++++++++++++------ .../wizard/email_compose_message.py | 69 +++++++++++---- 7 files changed, 183 insertions(+), 77 deletions(-) diff --git a/addons/crm/wizard/email_compose_message.py b/addons/crm/wizard/email_compose_message.py index f2241abfdcc..27163e0931e 100644 --- a/addons/crm/wizard/email_compose_message.py +++ b/addons/crm/wizard/email_compose_message.py @@ -30,39 +30,79 @@ email_model = [ 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 not in email_model: + return result + model_obj = self.pool.get(context.get('email_model')) + data = model_obj.browse(cr, uid , resource_id, context) + result.update({ + 'name' : data.name, + 'email_to' : data.email_from, + '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 '')), + 'email_cc' : tools.ustr(data.email_cc or '') + }) + if hasattr(data, 'section_id'): + result.update({'reply_to' : data.section_id and data.section_id.reply_to or False}) + return result + def default_get(self, cr, uid, fields, context=None): if context is None: context = {} result = super(email_compose_message, self).default_get(cr, uid, fields, context=context) if context.get('active_id',False) and context.get('email_model',False) and context.get('email_model') in email_model: - model_obj = self.pool.get(context.get('email_model')) - data = model_obj.browse(cr, uid ,context.get('active_id'), context) + vals = self.get_value(cr, uid, context.get('email_model'), context.get('active_id'), context) if 'name' in fields: - result['name'] = data.name + result.update({'name' : vals.get('name','')}) if 'email_to' in fields: - result['email_to'] = data.email_from + result.update({'email_to' : vals.get('email_to','')}) if 'email_from' in fields: - result['email_from'] = data.user_id and data.user_id.address_id and data.user_id.address_id.email or False + result.update({'email_from' : vals.get('email_from','')}) if 'description' in fields: - result['description'] = '\n' + (tools.ustr(data.user_id.signature or '')) + result.update({'description' : vals.get('description','')}) if 'model' in fields: result['model'] = context.get('email_model','') if 'email_cc' in fields: - result['email_cc'] = tools.ustr(data.email_cc or '') + result.update({'email_cc' : vals.get('email_cc','')}) if 'res_id' in fields: result['res_id'] = context.get('active_id',0) - if 'reply_to' in fields and hasattr(data, 'section_id'): - result['reply_to'] = data.section_id and data.section_id.reply_to or False + if 'reply_to' in fields: + result['reply_to'] = vals.get('reply_to','') 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 = super(email_compose_message, self).on_change_referred_doc(cr, uid, ids, model, resource_id, context=context) + value = {} + if not result.get('value'): + result.update({'value':{}}) + if resource_id and model in email_model: + vals = self.get_value(cr, uid, model, resource_id, context) + result['value'].update({ + 'email_from': vals.get('email_from',''), + 'email_to': vals.get('email_to',''), + 'name': vals.get('name',''), + 'description': vals.get('description',''), + 'email_cc': vals.get('email_cc',''), + 'email_bcc': vals.get('email_bcc',''), + 'reply_to': vals.get('reply_to',''), + }) + return result + email_compose_message() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/email_template/wizard/email_compose_message.py b/addons/email_template/wizard/email_compose_message.py index 1214595c68e..f944c503a17 100644 --- a/addons/email_template/wizard/email_compose_message.py +++ b/addons/email_template/wizard/email_compose_message.py @@ -95,7 +95,7 @@ class email_compose_message(osv.osv_memory): model = context.get('email_model') if model: record_ids = email_temp_pool.search(cr, uid, [('model','=',model)]) - return email_temp_pool.name_get(cr, uid, record_ids, context) + return email_temp_pool.name_get(cr, uid, record_ids, context) + [(False,'')] return [] _columns = { @@ -110,31 +110,15 @@ class email_compose_message(osv.osv_memory): email_temp_previ_pool = self.pool.get('email_template.preview') result = self.on_change_referred_doc(cr, uid, [], model, resource_id, context=context) vals = result.get('value',{}) - if template_id: + if template_id and resource_id: email_temp_pool = self.pool.get('email.template') email_temp_data = email_temp_pool.browse(cr, uid, template_id, context) vals.update({'smtp_server_id': email_temp_data.smtp_server_id and email_temp_data.smtp_server_id.id or False}) - if template_id and resource_id: context.update({'template_id': template_id}) value = email_temp_previ_pool.on_change_ref(cr, uid, [], resource_id, context) - new_value = value.get('value',{}) - if vals.get('email_from'): - new_value.get('email_from') and new_value.update({'email_from': new_value.get('email_from') + ',' + vals.get('email_from')}) or vals.get('email_from') + vals.update(value.get('value',{})) + vals.update({'name': value.get('value',{}).get('subject','')}) - if vals.get('email_to'): - new_value.update({'email_to': new_value.get('email_to') + ',' + vals.get('email_to')}) or vals.get('email_to') - - if vals.get('email_cc'): - new_value.get('email_cc') and new_value.update({'email_cc': new_value.get('email_cc') + ',' + vals.get('email_cc')}) or vals.get('email_cc') - - if vals.get('email_bcc'): - new_value.get('email_bcc') and new_value.update({'email_bcc': new_value.get('email_bcc') + ',' + vals.get('email_bcc')}) or vals.get('email_bcc') - - if vals.get('reply_to'): - new_value.get('reply_to') and new_value.update({'reply_to': new_value.get('reply_to') + ',' + vals.get('reply_to')}) or vals.get('reply_to') - - vals.update(new_value) - vals.update({'name': new_value.get('subject','')}) return {'value': vals} email_compose_message() diff --git a/addons/email_template/wizard/email_template_preview.py b/addons/email_template/wizard/email_template_preview.py index 09abd9fe8ff..175722a2ea2 100644 --- a/addons/email_template/wizard/email_template_preview.py +++ b/addons/email_template/wizard/email_template_preview.py @@ -95,7 +95,11 @@ class email_template_preview(osv.osv_memory): elif template.track_campaign_item: vals['message_id'] = tools.misc.generate_tracking_message_id(res_id) vals['subject'] = self.get_template_value(cr, uid, template.subject, model, res_id, context) - vals['description'] = self.get_template_value(cr, uid, template.description, model, res_id, context) + description = self.get_template_value(cr, uid, template.description, model, res_id, context) or '' + if template.user_signature: + signature = self.pool.get('res.users').browse(cr, uid, uid, context).signature + description += '\n' + signature + vals['description'] = description vals['report_name'] = self.get_template_value(cr, uid, template.report_name, model, res_id, context) return {'value':vals} diff --git a/addons/emails/wizard/email_compose_message.py b/addons/emails/wizard/email_compose_message.py index 059e5f5e9b0..76eadaade5f 100644 --- a/addons/emails/wizard/email_compose_message.py +++ b/addons/emails/wizard/email_compose_message.py @@ -132,6 +132,9 @@ class email_compose_message(osv.osv_memory): 'res_id':fields.selection(_get_records, 'Referred Document'), } + def get_value(self, cr, uid, model, resource_id, context=None): + return {} + def on_change_referred_doc(self, cr, uid, ids, model, resource_id, context=None): return {'value':{}} diff --git a/addons/hr_evaluation/wizard/email_compose_message.py b/addons/hr_evaluation/wizard/email_compose_message.py index fda67e4131c..7095659f164 100644 --- a/addons/hr_evaluation/wizard/email_compose_message.py +++ b/addons/hr_evaluation/wizard/email_compose_message.py @@ -68,11 +68,16 @@ class email_compose_message(osv.osv_memory): record_data = model_pool.browse(cr, uid, resource_id, context) if record_data.state == "waiting_answer": msg = _("Hello %s, \n\n Kindly post your response for '%s' survey interview. \n\n Thanks,") %(record_data.user_to_review_id.name, record_data.survey_id.title) - result['value'].update({'email_from': tools.config.get('email_from','')}) - result['value'].update({'email_to': record_data.user_to_review_id.work_email or False}) - result['value'].update({'name': _("Reminder to fill up Survey")}) - result['value'].update({'description': msg }) - result['value'].update({'res_id': resource_id}) + result['value'].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, + 'res_id': resource_id, + 'email_cc': False, + 'email_bcc': False, + 'reply_to': False, + }) return result email_compose_message() diff --git a/addons/project/wizard/email_compose_message.py b/addons/project/wizard/email_compose_message.py index 042cdd61a30..59b7258eb9d 100644 --- a/addons/project/wizard/email_compose_message.py +++ b/addons/project/wizard/email_compose_message.py @@ -26,56 +26,91 @@ from tools.translate import _ 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': + return result + task_pool = self.pool.get('project.task') + task_data = task_pool.browse(cr, uid, resource_id, context=context) + partner = task_data.partner_id or task_data.project_id.partner_id + + result.update({'email_from': task_data.user_id and task_data.user_id.user_email or False}) + val = { + 'name': task_data.name, + 'user_id': task_data.user_id.name, + 'task_id': "%d/%d" % (task_data.project_id.id, task_data.id), + 'date_start': task_data.date_start, + 'date': task_data.date_end, + 'state': task_data.state + } + header = (task_data.project_id.warn_header or '') % val + footer = (task_data.project_id.warn_footer or '') % val + description = u'%s\n %s\n %s\n\n \n%s' % (header, task_data.description or '', footer, task_data.user_id and task_data.user_id.signature) + result.update({'description': description or False}) + result.update({'email_to': task_data.project_id.user_id and task_data.project_id.user_id.user_email or False}) + if partner and len(partner.address) and 'email_to' in fields: + result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + partner.address[0].email}) + result.update({'name': _("Task '%s' Closed") % task_data.name}) + + return result + def default_get(self, cr, uid, fields, context=None): if context is None: context = {} result = super(email_compose_message, self).default_get(cr, uid, fields, context=context) - if context.get('active_id',False) and context.get('active_model',False) and context.get('active_model') == 'project.task': + if context.get('active_id',False) and context.get('email_model',False) and context.get('email_model') == 'project.task': task_pool = self.pool.get('project.task') task_data = task_pool.browse(cr, uid, context.get('active_id'), context=context) - project = task_data.project_id - manager = project.user_id or False partner = task_data.partner_id or task_data.project_id.partner_id - if project.warn_manager and (not manager or manager and not manager.user_email) : + if task_data.project_id.warn_manager and (not task_data.project_id.user_id or task_data.project_id.user_id and not task_data.project_id.user_id.user_email) : raise osv.except_osv(_('Error'), _("Please specify the Project Manager or email address of Project Manager.")) - elif project.warn_customer and (not partner or not len(partner.address) or (partner and len(partner.address) and not partner.address[0].email)): + elif task_data.project_id.warn_customer and (not partner or not len(partner.address) or (partner and len(partner.address) and not partner.address[0].email)): raise osv.except_osv(_('Error'), _("Please specify the Customer or email address of Customer.")) - + vals = self.get_value(cr, uid, context.get('email_model'), context.get('active_id'), context) if 'email_from' in fields: - result.update({'email_from': task_data.user_id and task_data.user_id.user_email or False}) + result.update({'email_from': vals.get('email_from','')}) if 'description' in fields: - val = { - 'name': task_data.name, - 'user_id': task_data.user_id.name, - 'task_id': "%d/%d" % (project.id, task_data.id), - 'date_start': task_data.date_start, - 'date': task_data.date_end, - 'state': task_data.state - } - header = (project.warn_header or '') % val - footer = (project.warn_footer or '') % val - description = u'%s\n %s\n %s\n\n \n%s' % (header, task_data.description or '', footer, task_data.user_id and task_data.user_id.signature) - result.update({'description': description or False}) + result.update({'description': vals.get('description','')}) if 'email_to' in fields: - result.update({'email_to': manager and manager.user_email or False}) - - if partner and len(partner.address) and 'email_to' in fields: - result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + partner.address[0].email}) + result.update({'description': vals.get('description','')}) if 'name' in fields: - result.update({'name': _("Task '%s' Closed") % task_data.name}) + result.update({'description': vals.get('name','')}) if 'model' in fields: - result.update({'model':context.get('active_model')}) + result.update({'model':context.get('email_model')}) if 'res_id' in fields: result.update({'res_id':context.get('active_id')}) 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 = super(email_compose_message, self).on_change_referred_doc(cr, uid, ids, model, resource_id, context=context) + if not result.get('value'): + result.update({'value':{}}) + if resource_id and model == 'project.task': + vals = self.get_value(cr, uid, model, resource_id, context) + result.get('value',{}).update({ + 'email_from': vals.get('email_from',''), + 'email_to': vals.get('email_to',''), + 'description': vals.get('description',''), + 'name': vals.get('name',''), + 'email_cc': vals.get('email_cc',''), + 'email_bcc': vals.get('email_bcc',''), + 'reply_to': vals.get('reply_to',''), + }) + return result + email_compose_message() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/project_scrum/wizard/email_compose_message.py b/addons/project_scrum/wizard/email_compose_message.py index fc97709459d..1354196275a 100644 --- a/addons/project_scrum/wizard/email_compose_message.py +++ b/addons/project_scrum/wizard/email_compose_message.py @@ -26,35 +26,49 @@ from tools.translate import _ 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.scrum.meeting': + return result + meeting_pool = self.pool.get('project.scrum.meeting') + user_pool = self.pool.get('res.users') + meeting = meeting_pool.browse(cr, uid, resource_id, context=context) + + sprint = meeting.sprint_id + user_data = user_pool.browse(cr, uid, uid, context=context) + result.update({'email_from': user_data.address_id and user_data.address_id.email or False}) + + if sprint.scrum_master_id and sprint.scrum_master_id.user_email: + result.update({'email_to': sprint.scrum_master_id.user_email}) + if sprint.product_owner_id and sprint.product_owner_id.user_email: + result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + sprint.product_owner_id.user_email or sprint.product_owner_id.user_email}) + + subject = _("Scrum Meeting : %s") %(meeting.date) + result.update({'name': subject}) + 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({'description': message}) + return result + def default_get(self, cr, uid, fields, context=None): if context is None: context = {} result = super(email_compose_message, self).default_get(cr, uid, fields, context=context) if context.get('active_id',False) and context.get('email_model',False) and context.get('email_model') == 'project.scrum.meeting': - - meeting_pool = self.pool.get('project.scrum.meeting') - user_pool = self.pool.get('res.users') - meeting = meeting_pool.browse(cr, uid, context.get('active_id'), context=context) - sprint = meeting.sprint_id - + vals = self.get_value(cr, uid, context.get('email_model'), context.get('active_id'), context) if 'email_from' in fields: - user_data = user_pool.browse(cr, uid, uid, context=context) - result.update({'email_from': user_data.address_id and user_data.address_id.email or False}) + result.update({'email_from': vals.get('email_from','')}) - if 'email_to' in fields and sprint.scrum_master_id and sprint.scrum_master_id.user_email: - result.update({'email_to': sprint.scrum_master_id.user_email}) - - if sprint.product_owner_id and sprint.product_owner_id.user_email: - result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + sprint.product_owner_id.user_email or sprint.product_owner_id.user_email}) + if 'email_to' in fields: + result.update({'email_to': vals.get('email_to','')}) if 'name' in fields: - subject = _("Scrum Meeting : %s") %(meeting.date) - result.update({'name': subject}) + result.update({'name': vals.get('name','')}) if 'description' in fields: - 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({'description': message}) + result.update({'description': vals.get('description','')}) if 'model' in fields: result.update({'model':context.get('email_model')}) @@ -64,6 +78,27 @@ class email_compose_message(osv.osv_memory): 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 = super(email_compose_message, self).on_change_referred_doc(cr, uid, ids, model, resource_id, context=context) + if not result.get('value'): + result.update({'value':{}}) + if resource_id and model == 'project.scrum.meeting': + vals = self.get_value(cr, uid, model, resource_id, context) + result.get('value',{}).update({ + 'email_from': vals.get('email_from',''), + 'email_to': vals.get('email_to',''), + 'description': vals.get('description',''), + 'name': vals.get('name',''), + 'email_cc': vals.get('email_cc',''), + 'email_bcc': vals.get('email_bcc',''), + 'reply_to': vals.get('reply_to',''), + }) + return result + email_compose_message() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 9e752fb7f3d1a0a70cddccb9e9075acdff1f004c Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 28 Feb 2011 17:16:50 +0530 Subject: [PATCH 125/278] [FIX] fix problem bzr revid: ysa@tinyerp.com-20110228114650-sjis2yc17xrgq8ed --- addons/crm/wizard/email_compose_message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/crm/wizard/email_compose_message.py b/addons/crm/wizard/email_compose_message.py index 27163e0931e..c7e389e3470 100644 --- a/addons/crm/wizard/email_compose_message.py +++ b/addons/crm/wizard/email_compose_message.py @@ -36,7 +36,7 @@ class email_compose_message(osv.osv_memory): result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context) if model not in email_model: return result - model_obj = self.pool.get(context.get('email_model')) + model_obj = self.pool.get(model) data = model_obj.browse(cr, uid , resource_id, context) result.update({ 'name' : data.name, From 3f3bcfdca27209dfcf1c692a87553a5dbad3af29 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 28 Feb 2011 17:34:40 +0530 Subject: [PATCH 126/278] [IMP] default attachment_ids change based on onchange of template_id field. bzr revid: ysa@tinyerp.com-20110228120440-tpacaidf6371b898 --- addons/email_template/wizard/email_compose_message.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/email_template/wizard/email_compose_message.py b/addons/email_template/wizard/email_compose_message.py index f944c503a17..01f31b0a7fa 100644 --- a/addons/email_template/wizard/email_compose_message.py +++ b/addons/email_template/wizard/email_compose_message.py @@ -118,7 +118,9 @@ class email_compose_message(osv.osv_memory): value = email_temp_previ_pool.on_change_ref(cr, uid, [], resource_id, context) vals.update(value.get('value',{})) vals.update({'name': value.get('value',{}).get('subject','')}) - + vals.update({'attachment_ids' : email_temp_pool.read(cr, uid, template_id, ['attachment_ids'])['attachment_ids']}) + else: + vals.update({'attachment_ids' : []}) return {'value': vals} email_compose_message() From 494f1588b8b8993dc9ba6d22c97c78af64a031ac Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 28 Feb 2011 17:41:07 +0530 Subject: [PATCH 127/278] [IMP] emails:- folder in trash then record display in gray color in emails.message tree view. bzr revid: ysa@tinyerp.com-20110228121107-xqrrwntn9djiu6z3 --- addons/emails/email_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/emails/email_view.xml b/addons/emails/email_view.xml index 2201b50dfd3..1c6a0ad81ca 100644 --- a/addons/emails/email_view.xml +++ b/addons/emails/email_view.xml @@ -72,7 +72,7 @@ email.message tree - + From 7d782c5f6396e21dd13aa8a88a0d4c53dea7a238 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 28 Feb 2011 18:15:47 +0530 Subject: [PATCH 128/278] [IMP] emails:- add onchange method of smtp_server_id field. if email_from not exists then email_from value set baseon smtp_server_id field. bzr revid: ysa@tinyerp.com-20110228124547-2343wo9k3pd9oqop --- addons/emails/email_view.xml | 2 +- addons/emails/wizard/email_compose_message.py | 6 ++++++ addons/emails/wizard/email_compose_message_view.xml | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/emails/email_view.xml b/addons/emails/email_view.xml index 1c6a0ad81ca..09b723d991b 100644 --- a/addons/emails/email_view.xml +++ b/addons/emails/email_view.xml @@ -21,7 +21,7 @@ - + diff --git a/addons/emails/wizard/email_compose_message.py b/addons/emails/wizard/email_compose_message.py index 76eadaade5f..ba8ffea016d 100644 --- a/addons/emails/wizard/email_compose_message.py +++ b/addons/emails/wizard/email_compose_message.py @@ -138,6 +138,12 @@ class email_compose_message(osv.osv_memory): def on_change_referred_doc(self, cr, uid, ids, model, resource_id, context=None): return {'value':{}} + def on_change_smtp_server(self, cr, uid, ids, smtp_server_id, email_from, context=None): + if not email_from and smtp_server_id: + email_smtp_server_pool = self.pool.get("email.smtp_server") + email_from = email_smtp_server_pool.browse(cr, uid, smtp_server_id, context).email_id or False + return {'value':{'email_from': email_from}} + def save_to_drafts(self, cr, uid, ids, context=None): if context is None: context = {} diff --git a/addons/emails/wizard/email_compose_message_view.xml b/addons/emails/wizard/email_compose_message_view.xml index 9cb9a6d43fc..a4984ff1ad8 100644 --- a/addons/emails/wizard/email_compose_message_view.xml +++ b/addons/emails/wizard/email_compose_message_view.xml @@ -12,7 +12,8 @@ - + From 67e07f8bd3847b1948e254f03c155ec15c6054d5 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 1 Mar 2011 12:27:48 +0530 Subject: [PATCH 129/278] [IMP] email.compose.message wizard:- improve code. bzr revid: ysa@tinyerp.com-20110301065748-2mc5hygt3gcd0p70 --- addons/crm/wizard/email_compose_message.py | 81 +++------------- addons/emails/wizard/email_compose_message.py | 45 ++++++++- .../project/wizard/email_compose_message.py | 94 +++++-------------- .../wizard/email_compose_message.py | 81 ++++------------ 4 files changed, 99 insertions(+), 202 deletions(-) diff --git a/addons/crm/wizard/email_compose_message.py b/addons/crm/wizard/email_compose_message.py index c7e389e3470..d24c06ad70c 100644 --- a/addons/crm/wizard/email_compose_message.py +++ b/addons/crm/wizard/email_compose_message.py @@ -34,73 +34,20 @@ class email_compose_message(osv.osv_memory): if context is None: context = {} result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context) - if model not in email_model: - return result - model_obj = self.pool.get(model) - data = model_obj.browse(cr, uid , resource_id, context) - result.update({ - 'name' : data.name, - 'email_to' : data.email_from, - '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 '')), - 'email_cc' : tools.ustr(data.email_cc or '') - }) - if hasattr(data, 'section_id'): - result.update({'reply_to' : data.section_id and data.section_id.reply_to or False}) - return result - - def default_get(self, cr, uid, fields, context=None): - if context is None: - context = {} - result = super(email_compose_message, self).default_get(cr, uid, fields, context=context) - if context.get('active_id',False) and context.get('email_model',False) and context.get('email_model') in email_model: - vals = self.get_value(cr, uid, context.get('email_model'), context.get('active_id'), context) - if 'name' in fields: - result.update({'name' : vals.get('name','')}) - - if 'email_to' in fields: - result.update({'email_to' : vals.get('email_to','')}) - - if 'email_from' in fields: - result.update({'email_from' : vals.get('email_from','')}) - - if 'description' in fields: - result.update({'description' : vals.get('description','')}) - - if 'model' in fields: - result['model'] = context.get('email_model','') - - if 'email_cc' in fields: - result.update({'email_cc' : vals.get('email_cc','')}) - - if 'res_id' in fields: - result['res_id'] = context.get('active_id',0) - - if 'reply_to' in fields: - result['reply_to'] = vals.get('reply_to','') - - 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 = super(email_compose_message, self).on_change_referred_doc(cr, uid, ids, model, resource_id, context=context) - value = {} - if not result.get('value'): - result.update({'value':{}}) - if resource_id and model in email_model: - vals = self.get_value(cr, uid, model, resource_id, context) - result['value'].update({ - 'email_from': vals.get('email_from',''), - 'email_to': vals.get('email_to',''), - 'name': vals.get('name',''), - 'description': vals.get('description',''), - 'email_cc': vals.get('email_cc',''), - 'email_bcc': vals.get('email_bcc',''), - 'reply_to': vals.get('reply_to',''), - }) + if model in email_model and resource_id: + model_obj = self.pool.get(model) + data = model_obj.browse(cr, uid , resource_id, context) + result.update({ + 'name' : data.name, + 'email_to' : data.email_from, + '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 '')), + 'email_cc' : tools.ustr(data.email_cc or ''), + 'model': model, + 'res_id': resource_id, + }) + if hasattr(data, 'section_id'): + result.update({'reply_to' : data.section_id and data.section_id.reply_to or False}) return result email_compose_message() diff --git a/addons/emails/wizard/email_compose_message.py b/addons/emails/wizard/email_compose_message.py index ba8ffea016d..cc7b31cd7b2 100644 --- a/addons/emails/wizard/email_compose_message.py +++ b/addons/emails/wizard/email_compose_message.py @@ -32,6 +32,32 @@ class email_compose_message(osv.osv_memory): if context is None: context = {} result = super(email_compose_message, self).default_get(cr, uid, fields, context=context) + if context.get('email_model') and context.get('active_id'): + vals = self.get_value(cr, uid, context.get('email_model'), context.get('active_id'), context) + if 'name' in fields and vals: + result.update({'name' : vals.get('name','')}) + + if 'email_to' in fields and vals: + result.update({'email_to' : vals.get('email_to','')}) + + if 'email_from' in fields and vals: + result.update({'email_from' : vals.get('email_from','')}) + + if 'description' in fields and vals: + result.update({'description' : vals.get('description','')}) + + if 'model' in fields and vals: + result.update({'model' : vals.get('model','')}) + + if 'email_cc' in fields and vals: + result.update({'email_cc' : vals.get('email_cc','')}) + + if 'res_id' in fields and vals: + result.update({'res_id' : vals.get('res_id',0)}) + + if 'reply_to' in fields and vals: + result['reply_to'] = vals.get('reply_to','') + message_pool = self.pool.get('email.message') message_id = context.get('message_id', False) if message_id: @@ -136,7 +162,24 @@ class email_compose_message(osv.osv_memory): return {} def on_change_referred_doc(self, cr, uid, ids, model, resource_id, context=None): - return {'value':{}} + 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',''), + 'name': vals.get('name',''), + 'description': vals.get('description',''), + 'email_cc': vals.get('email_cc',''), + 'email_bcc': vals.get('email_bcc',''), + 'reply_to': vals.get('reply_to',''), + }) + return {'value': result} def on_change_smtp_server(self, cr, uid, ids, smtp_server_id, email_from, context=None): if not email_from and smtp_server_id: diff --git a/addons/project/wizard/email_compose_message.py b/addons/project/wizard/email_compose_message.py index 59b7258eb9d..2796dc602c1 100644 --- a/addons/project/wizard/email_compose_message.py +++ b/addons/project/wizard/email_compose_message.py @@ -30,85 +30,37 @@ class email_compose_message(osv.osv_memory): if context is None: context = {} result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context) - if model != 'project.task': - return result - task_pool = self.pool.get('project.task') - task_data = task_pool.browse(cr, uid, resource_id, context=context) - partner = task_data.partner_id or task_data.project_id.partner_id - - result.update({'email_from': task_data.user_id and task_data.user_id.user_email or False}) - val = { - 'name': task_data.name, - 'user_id': task_data.user_id.name, - 'task_id': "%d/%d" % (task_data.project_id.id, task_data.id), - 'date_start': task_data.date_start, - 'date': task_data.date_end, - 'state': task_data.state - } - header = (task_data.project_id.warn_header or '') % val - footer = (task_data.project_id.warn_footer or '') % val - description = u'%s\n %s\n %s\n\n \n%s' % (header, task_data.description or '', footer, task_data.user_id and task_data.user_id.signature) - result.update({'description': description or False}) - result.update({'email_to': task_data.project_id.user_id and task_data.project_id.user_id.user_email or False}) - if partner and len(partner.address) and 'email_to' in fields: - result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + partner.address[0].email}) - result.update({'name': _("Task '%s' Closed") % task_data.name}) - - return result - - def default_get(self, cr, uid, fields, context=None): - if context is None: - context = {} - result = super(email_compose_message, self).default_get(cr, uid, fields, context=context) - if context.get('active_id',False) and context.get('email_model',False) and context.get('email_model') == 'project.task': + if model == 'project.task' and resource_id: task_pool = self.pool.get('project.task') - task_data = task_pool.browse(cr, uid, context.get('active_id'), context=context) + task_data = task_pool.browse(cr, uid, resource_id, context=context) partner = task_data.partner_id or task_data.project_id.partner_id - if task_data.project_id.warn_manager and (not task_data.project_id.user_id or task_data.project_id.user_id and not task_data.project_id.user_id.user_email) : raise osv.except_osv(_('Error'), _("Please specify the Project Manager or email address of Project Manager.")) elif task_data.project_id.warn_customer and (not partner or not len(partner.address) or (partner and len(partner.address) and not partner.address[0].email)): raise osv.except_osv(_('Error'), _("Please specify the Customer or email address of Customer.")) - vals = self.get_value(cr, uid, context.get('email_model'), context.get('active_id'), context) - if 'email_from' in fields: - result.update({'email_from': vals.get('email_from','')}) - if 'description' in fields: - result.update({'description': vals.get('description','')}) - - if 'email_to' in fields: - result.update({'description': vals.get('description','')}) - - if 'name' in fields: - result.update({'description': vals.get('name','')}) - - if 'model' in fields: - result.update({'model':context.get('email_model')}) - - if 'res_id' in fields: - result.update({'res_id':context.get('active_id')}) - - 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 = super(email_compose_message, self).on_change_referred_doc(cr, uid, ids, model, resource_id, context=context) - if not result.get('value'): - result.update({'value':{}}) - if resource_id and model == 'project.task': - vals = self.get_value(cr, uid, model, resource_id, context) - result.get('value',{}).update({ - 'email_from': vals.get('email_from',''), - 'email_to': vals.get('email_to',''), - 'description': vals.get('description',''), - 'name': vals.get('name',''), - 'email_cc': vals.get('email_cc',''), - 'email_bcc': vals.get('email_bcc',''), - 'reply_to': vals.get('reply_to',''), + result.update({'email_from': task_data.user_id and task_data.user_id.user_email or False}) + val = { + 'name': task_data.name, + 'user_id': task_data.user_id.name, + 'task_id': "%d/%d" % (task_data.project_id.id, task_data.id), + 'date_start': task_data.date_start, + 'date': task_data.date_end, + 'state': task_data.state + } + header = (task_data.project_id.warn_header or '') % val + footer = (task_data.project_id.warn_footer or '') % val + description = u'%s\n %s\n %s\n\n \n%s' % (header, task_data.description or '', footer, task_data.user_id and task_data.user_id.signature) + if partner and len(partner.address) and 'email_to' in fields: + result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + partner.address[0].email}) + result.update({ + 'description': 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, + 'model': model, + 'res_id': resource_id, }) + return result email_compose_message() diff --git a/addons/project_scrum/wizard/email_compose_message.py b/addons/project_scrum/wizard/email_compose_message.py index 1354196275a..1a639fbd198 100644 --- a/addons/project_scrum/wizard/email_compose_message.py +++ b/addons/project_scrum/wizard/email_compose_message.py @@ -30,72 +30,27 @@ class email_compose_message(osv.osv_memory): if context is None: context = {} result = super(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context) - if model != 'project.scrum.meeting': - return result - meeting_pool = self.pool.get('project.scrum.meeting') - user_pool = self.pool.get('res.users') - meeting = meeting_pool.browse(cr, uid, resource_id, context=context) + if model == 'project.scrum.meeting' and resource_id: + meeting_pool = self.pool.get('project.scrum.meeting') + user_pool = self.pool.get('res.users') + meeting = meeting_pool.browse(cr, uid, resource_id, context=context) - sprint = meeting.sprint_id - user_data = user_pool.browse(cr, uid, uid, context=context) - result.update({'email_from': user_data.address_id and user_data.address_id.email or False}) + sprint = meeting.sprint_id + user_data = user_pool.browse(cr, uid, uid, context=context) + result.update({'email_from': user_data.address_id and user_data.address_id.email or False}) - if sprint.scrum_master_id and sprint.scrum_master_id.user_email: - result.update({'email_to': sprint.scrum_master_id.user_email}) - if sprint.product_owner_id and sprint.product_owner_id.user_email: - result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + sprint.product_owner_id.user_email or sprint.product_owner_id.user_email}) + if sprint.scrum_master_id and sprint.scrum_master_id.user_email: + result.update({'email_to': sprint.scrum_master_id.user_email}) + if sprint.product_owner_id and sprint.product_owner_id.user_email: + result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + sprint.product_owner_id.user_email or sprint.product_owner_id.user_email}) - subject = _("Scrum Meeting : %s") %(meeting.date) - result.update({'name': subject}) - 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({'description': message}) - return result - - def default_get(self, cr, uid, fields, context=None): - if context is None: - context = {} - result = super(email_compose_message, self).default_get(cr, uid, fields, context=context) - - if context.get('active_id',False) and context.get('email_model',False) and context.get('email_model') == 'project.scrum.meeting': - vals = self.get_value(cr, uid, context.get('email_model'), context.get('active_id'), context) - if 'email_from' in fields: - result.update({'email_from': vals.get('email_from','')}) - - if 'email_to' in fields: - result.update({'email_to': vals.get('email_to','')}) - - if 'name' in fields: - result.update({'name': vals.get('name','')}) - - if 'description' in fields: - result.update({'description': vals.get('description','')}) - - if 'model' in fields: - result.update({'model':context.get('email_model')}) - - if 'res_id' in fields: - result.update({'res_id':context.get('active_id')}) - - 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 = super(email_compose_message, self).on_change_referred_doc(cr, uid, ids, model, resource_id, context=context) - if not result.get('value'): - result.update({'value':{}}) - if resource_id and model == 'project.scrum.meeting': - vals = self.get_value(cr, uid, model, resource_id, context) - result.get('value',{}).update({ - 'email_from': vals.get('email_from',''), - 'email_to': vals.get('email_to',''), - 'description': vals.get('description',''), - 'name': vals.get('name',''), - 'email_cc': vals.get('email_cc',''), - 'email_bcc': vals.get('email_bcc',''), - 'reply_to': vals.get('reply_to',''), + 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, + 'model': model, + 'res_id': resource_id }) return result From 92864126a905fb401ac33ad07da7ebb57f9e5d7c Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 1 Mar 2011 15:58:52 +0530 Subject: [PATCH 130/278] [IMP] email_template :- create get_template_data method and remove code in on_change and default_get method. make generic method in email.compose.messageg wizard. bzr revid: ysa@tinyerp.com-20110301102852-c35165ydv2xuufb0 --- .../wizard/email_compose_message.py | 91 +++++++++++-------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/addons/email_template/wizard/email_compose_message.py b/addons/email_template/wizard/email_compose_message.py index a95e0e51f31..37e4c3df9f0 100644 --- a/addons/email_template/wizard/email_compose_message.py +++ b/addons/email_template/wizard/email_compose_message.py @@ -26,55 +26,82 @@ import tools class email_compose_message(osv.osv_memory): _name = 'email.compose.message' _inherit = 'email.compose.message' - def default_get(self, cr, uid, fields, context=None): + + def get_template_data(self, cr, uid, res_id, template_id, context=None): if context is None: context = {} - result = super(email_compose_message, self).default_get(cr, uid, fields, context=context) + result = {} template_pool = self.pool.get('email.template') - model_pool = self.pool.get('ir.model') - template_id = context.get('template_id', False) if template_id: template = template_pool.get_email_template(cr, uid, template_id=template_id, context=context) def _get_template_value(field): if not template: return False - if len(context['src_rec_ids']) > 1: # Multiple Mail: Gets original template values for multiple email change + if len(context.get('src_rec_ids',[])) > 1: # Multiple Mail: Gets original template values for multiple email change return getattr(template, field) else: # Simple Mail: Gets computed template values return template_pool.get_template_value(cr, uid, getattr(template, field), template.model, context.get('email_res_id'), context) + result.update({ + 'template_id' : template.id, + 'smtp_server_id' : template.smtp_server_id.id, + 'description' : _get_template_value('description') or False, + 'name' : _get_template_value('subject') or False, + 'attachment_ids' : template_pool.read(cr, uid, template.id, ['attachment_ids'])['attachment_ids'] or [], + 'res_id' : res_id or False, + 'email_to' : _get_template_value('email_to') or False, + 'email_cc' : _get_template_value('email_cc') or False, + 'email_bcc' : _get_template_value('email_bcc') or False, + 'reply_to' : _get_template_value('reply_to') or False, + 'model' : template.model or False, + }) + return result - if 'template_id' in fields: - result['template_id'] = template.id + def default_get(self, cr, uid, fields, context=None): + if context is None: + context = {} + 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) + else: + result['model'] = context.get('email_model', False) - if 'smtp_server_id' in fields: - result['smtp_server_id'] = template.smtp_server_id.id + if not vals: + return result - if 'attachment_ids' in fields: - result['attachment_ids'] = template_pool.read(cr, uid, template.id, ['attachment_ids'])['attachment_ids'] + if 'template_id' in fields: + result.update({'template_id' : vals.get('template_id', False)}) - if 'model' in fields: - result['model'] = context.get('email_model') + if 'smtp_server_id' in fields: + result.update({'smtp_server_id' : vals.get('smtp_server_id', False)}) - if 'res_id' in fields: - result['res_id'] = context.get('email_res_id') + if 'attachment_ids' in fields: + result.update({'attachment_ids' : vals.get('attachment_ids', False)}) - if 'email_to' in fields: - result['email_to'] = _get_template_value('email_to') + if 'model' in fields: + result.update({'model' : vals.get('model', False)}) - if 'email_cc' in fields: - result['email_cc'] = _get_template_value('email_cc') + if 'res_id' in fields: + result.update({'res_id' : vals.get('res_id', False)}) - if 'email_bcc' in fields: - result['email_bcc'] = _get_template_value('email_bcc') + if 'email_to' in fields: + result.update({'email_to' : vals.get('email_to', False)}) - if 'name' in fields: - result['name'] = _get_template_value('subject') + if 'email_cc' in fields: + result.update({'email_cc' : vals.get('email_cc', False)}) - if 'description' in fields: - result['description'] = _get_template_value('description') + if 'email_bcc' in fields: + result.update({'email_bcc' : vals.get('email_bcc', False)}) - if 'reply_to' in fields: - result['reply_to'] = _get_template_value('reply_to') + if 'name' in fields: + result.update({'name' : vals.get('name', False)}) + + if 'description' in fields: + result.update({'description' : vals.get('description', False)}) + + if 'reply_to' in fields: + result.update({'reply_to' : vals.get('reply_to', False)}) return result @@ -107,18 +134,10 @@ class email_compose_message(osv.osv_memory): context = {} if context.get('mail') == 'reply': return {'value':{}} - email_temp_previ_pool = self.pool.get('email_template.preview') result = self.on_change_referred_doc(cr, uid, [], model, resource_id, context=context) vals = result.get('value',{}) if template_id and resource_id: - email_temp_pool = self.pool.get('email.template') - email_temp_data = email_temp_pool.browse(cr, uid, template_id, context) - vals.update({'smtp_server_id': email_temp_data.smtp_server_id and email_temp_data.smtp_server_id.id or False}) - context.update({'template_id': template_id}) - value = email_temp_previ_pool.on_change_ref(cr, uid, [], resource_id, context) - vals.update(value.get('value',{})) - vals.update({'name': value.get('value',{}).get('subject','')}) - vals.update({'attachment_ids' : email_temp_pool.read(cr, uid, template_id, ['attachment_ids'])['attachment_ids']}) + vals.update(self.get_template_data(cr, uid, resource_id, template_id, context)) else: vals.update({'attachment_ids' : []}) return {'value': vals} From 062c57e4b0f6532ae1e80f2fbf2d0b27e2f020f2 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Tue, 1 Mar 2011 16:13:05 +0530 Subject: [PATCH 131/278] [REMOVE] fetchmail :- remove server_type in email.message object. bzr revid: ysa@tinyerp.com-20110301104305-qtfqy8fkr8xifime --- addons/fetchmail/fetchmail.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index e69bbdf87a2..296d592396a 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -117,7 +117,7 @@ class email_server(osv.osv): context = {} for server in self.browse(cr, uid, ids, context=context): logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) - context.update({'server_id': server.id, 'server_type': server.type}) + context.update({'server_id': server.id}) try: if server.type == 'imap': imap_server = None @@ -215,22 +215,14 @@ class email_message(osv.osv): _columns = { 'server_id': fields.many2one('email.server', "Mail Server", readonly=True, select=True), - 'server_type':fields.selection([ - ('pop', 'POP Server'), - ('imap', 'IMAP Server'), - ], 'Server Type', select=True, readonly=True), } - _order = 'id desc' def create(self, cr, uid, values, context=None): if context is None: context={} server_id = context.get('server_id',False) - server_type = context.get('server_type',False) if server_id: values['server_id'] = server_id - if server_type: - values['server_type'] = server_type res = super(email_message,self).create(cr, uid, values, context=context) return res @@ -238,11 +230,8 @@ class email_message(osv.osv): if context is None: context={} server_id = context.get('server_id',False) - server_type = context.get('server_type',False) if server_id: values['server_id'] = server_id - if server_type: - values['server_type'] = server_type res = super(email_message,self).write(cr, uid, ids, values, context=context) return res From a2875d6d0d5be8803001b9797e5809a255d9b3e2 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Thu, 3 Mar 2011 14:11:32 +0530 Subject: [PATCH 132/278] [IMP] emails: add smtp_server_id in message form view bzr revid: hmo@tinyerp.com-20110303084132-72blgo9sgpa0lykf --- addons/emails/email_view.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/emails/email_view.xml b/addons/emails/email_view.xml index 09b723d991b..66c749f69ca 100644 --- a/addons/emails/email_view.xml +++ b/addons/emails/email_view.xml @@ -54,6 +54,7 @@ + From 4ff5f75912df44cba5465a1db3f41ae88a9faccc Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Thu, 3 Mar 2011 16:07:40 +0530 Subject: [PATCH 133/278] [FIX] fetchmail: fix bzr revid: hmo@tinyerp.com-20110303103740-rza71diijr9hlysf --- addons/fetchmail/fetchmail.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 296d592396a..4b2b44a5414 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -185,8 +185,9 @@ class email_server(osv.osv): except Exception, e: logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) finally: - imap_server.close() - imap_server.logout() + if imap_server: + imap_server.close() + imap_server.logout() elif server.type == 'pop': try: pop_server = self.button_confirm_login(cr, uid, [server.id], context=context) @@ -204,7 +205,8 @@ class email_server(osv.osv): except Exception, e: logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) finally: - pop_server.quit() + if pop_server: + pop_server.quit() return True email_server() From e1afe5828aa5bc65a61ee6143a2dabd2fa6c0e33 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Thu, 10 Mar 2011 13:09:00 +0530 Subject: [PATCH 134/278] [IMP] change module name emails to email and related to changes in addons all module. move email_gateway module file in email module and also related changes in related module.. bzr revid: ysa@tinyerp.com-20110310073900-ivesygpb7cdwpp43 --- addons/account_followup/__openerp__.py | 2 +- addons/base_action_rule/__openerp__.py | 2 +- addons/base_calendar/__openerp__.py | 2 +- addons/crm/__openerp__.py | 2 +- addons/crm/crm_lead_view.xml | 8 ++++---- addons/crm/crm_opportunity_view.xml | 8 ++++---- addons/crm/security/ir.model.access.csv | 8 ++++---- addons/crm_claim/crm_claim_view.xml | 6 +++--- addons/crm_fundraising/crm_fundraising_view.xml | 6 +++--- addons/crm_helpdesk/crm_helpdesk_view.xml | 6 +++--- addons/{emails => email}/__init__.py | 1 + addons/{emails => email}/__openerp__.py | 1 + addons/{emails => email}/email_data.xml | 0 addons/{email_gateway => email}/email_gateway.py | 0 addons/{email_gateway => email}/email_gateway_view.xml | 0 addons/{emails => email}/email_message.py | 0 addons/{emails => email}/email_smtp_server.py | 0 addons/{emails => email}/email_view.xml | 0 addons/{emails => email}/i18n/ca.po | 0 addons/{emails => email}/i18n/de.po | 0 addons/{emails => email}/i18n/es.po | 0 addons/{emails => email}/i18n/fr.po | 0 addons/{emails => email}/i18n/hu.po | 0 addons/{emails => email}/i18n/it.po | 0 addons/{emails => email}/i18n/lt.po | 0 addons/{emails => email}/i18n/lv.po | 0 addons/{emails => email}/i18n/mail_gateway.pot | 0 addons/{emails => email}/i18n/nl.po | 0 addons/{emails => email}/i18n/pl.po | 0 addons/{emails => email}/i18n/pt.po | 0 addons/{emails => email}/i18n/pt_BR.po | 0 addons/{emails => email}/i18n/ro.po | 0 addons/{emails => email}/i18n/ru.po | 0 addons/{emails => email}/i18n/sl.po | 0 addons/{emails => email}/i18n/sr@latin.po | 0 addons/{emails => email}/i18n/sv.po | 0 addons/{emails => email}/i18n/zh_CN.po | 0 addons/{emails => email}/res_partner.py | 0 addons/{emails => email}/res_partner_view.xml | 0 addons/{email_gateway => email}/scripts/__init__.py | 0 .../scripts/openerp_mailgate/__init__.py | 0 .../scripts/openerp_mailgate/openerp_mailgate.py | 0 addons/{emails => email}/security/ir.model.access.csv | 3 ++- addons/{emails => email}/wizard/__init__.py | 0 addons/{emails => email}/wizard/email_compose_message.py | 0 .../wizard/email_compose_message_view.xml | 0 addons/email_gateway/__openerp__.py | 2 +- addons/email_template/__openerp__.py | 2 +- addons/email_template/email_template.py | 2 +- addons/email_template/email_template_view.xml | 4 ++-- .../email_template/wizard/email_compose_message_view.xml | 2 +- addons/event/__openerp__.py | 2 +- addons/event/event_view.xml | 6 +++--- addons/fetchmail/__openerp__.py | 2 +- addons/fetchmail/fetchmail_view.xml | 6 +++--- addons/hr_recruitment/hr_recruitment_view.xml | 6 +++--- addons/hr_recruitment/security/ir.model.access.csv | 2 +- addons/marketing_campaign/security/ir.model.access.csv | 4 ++-- addons/outlook/__openerp__.py | 2 +- addons/project/__openerp__.py | 2 +- addons/project_issue/project_issue_view.xml | 6 +++--- addons/project_issue/security/ir.model.access.csv | 4 ++-- addons/project_mailgate/__openerp__.py | 2 +- addons/project_mailgate/security/ir.model.access.csv | 4 ++-- addons/project_planning/project_planning_view.xml | 2 +- addons/project_scrum/__openerp__.py | 2 +- addons/project_scrum/project_scrum_view.xml | 2 +- addons/share/__openerp__.py | 2 +- addons/survey/__openerp__.py | 2 +- addons/thunderbird/__openerp__.py | 2 +- 70 files changed, 65 insertions(+), 62 deletions(-) rename addons/{emails => email}/__init__.py (98%) rename addons/{emails => email}/__openerp__.py (98%) rename addons/{emails => email}/email_data.xml (100%) rename addons/{email_gateway => email}/email_gateway.py (100%) rename addons/{email_gateway => email}/email_gateway_view.xml (100%) rename addons/{emails => email}/email_message.py (100%) rename addons/{emails => email}/email_smtp_server.py (100%) rename addons/{emails => email}/email_view.xml (100%) rename addons/{emails => email}/i18n/ca.po (100%) rename addons/{emails => email}/i18n/de.po (100%) rename addons/{emails => email}/i18n/es.po (100%) rename addons/{emails => email}/i18n/fr.po (100%) rename addons/{emails => email}/i18n/hu.po (100%) rename addons/{emails => email}/i18n/it.po (100%) rename addons/{emails => email}/i18n/lt.po (100%) rename addons/{emails => email}/i18n/lv.po (100%) rename addons/{emails => email}/i18n/mail_gateway.pot (100%) rename addons/{emails => email}/i18n/nl.po (100%) rename addons/{emails => email}/i18n/pl.po (100%) rename addons/{emails => email}/i18n/pt.po (100%) rename addons/{emails => email}/i18n/pt_BR.po (100%) rename addons/{emails => email}/i18n/ro.po (100%) rename addons/{emails => email}/i18n/ru.po (100%) rename addons/{emails => email}/i18n/sl.po (100%) rename addons/{emails => email}/i18n/sr@latin.po (100%) rename addons/{emails => email}/i18n/sv.po (100%) rename addons/{emails => email}/i18n/zh_CN.po (100%) rename addons/{emails => email}/res_partner.py (100%) rename addons/{emails => email}/res_partner_view.xml (100%) rename addons/{email_gateway => email}/scripts/__init__.py (100%) rename addons/{email_gateway => email}/scripts/openerp_mailgate/__init__.py (100%) rename addons/{email_gateway => email}/scripts/openerp_mailgate/openerp_mailgate.py (100%) rename addons/{emails => email}/security/ir.model.access.csv (74%) rename addons/{emails => email}/wizard/__init__.py (100%) rename addons/{emails => email}/wizard/email_compose_message.py (100%) rename addons/{emails => email}/wizard/email_compose_message_view.xml (100%) diff --git a/addons/account_followup/__openerp__.py b/addons/account_followup/__openerp__.py index 62624fa8801..c0c78ebae4f 100644 --- a/addons/account_followup/__openerp__.py +++ b/addons/account_followup/__openerp__.py @@ -43,7 +43,7 @@ """, 'author': 'OpenERP SA', 'website': 'http://www.openerp.com', - 'depends': ['account', 'emails'], + 'depends': ['account', 'email'], 'init_xml': [], 'update_xml': [ 'security/ir.model.access.csv', diff --git a/addons/base_action_rule/__openerp__.py b/addons/base_action_rule/__openerp__.py index 57818dddc5c..2611bcee042 100644 --- a/addons/base_action_rule/__openerp__.py +++ b/addons/base_action_rule/__openerp__.py @@ -26,7 +26,7 @@ 'description': "This module allows to implement action rules for any object.", 'author': 'OpenERP SA', 'website': 'http://www.openerp.com', - 'depends': ['base', 'emails'], + 'depends': ['base', 'email'], 'init_xml': [ 'base_action_rule_data.xml' ], diff --git a/addons/base_calendar/__openerp__.py b/addons/base_calendar/__openerp__.py index 9c0e4857d13..4b6cceb5f9c 100644 --- a/addons/base_calendar/__openerp__.py +++ b/addons/base_calendar/__openerp__.py @@ -22,7 +22,7 @@ { "name" : "Basic Calendar Functionality", "version" : "1.0", - "depends" : ["base", "emails"], + "depends" : ["base", "email"], 'description': """Full featured calendar system that supports: - Calendar of events - Alerts (create requests) diff --git a/addons/crm/__openerp__.py b/addons/crm/__openerp__.py index a6e42dd211e..338870f5006 100644 --- a/addons/crm/__openerp__.py +++ b/addons/crm/__openerp__.py @@ -56,7 +56,7 @@ Create dashboard for CRM that includes: 'base', 'base_action_rule', 'process', - 'email_gateway', + 'email', 'base_calendar', 'resource', 'board' diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 02d0ad646d0..c019c451f53 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -107,7 +107,7 @@ - - - Forward to Partner crm.lead.forward.to.partner From 6b38a3a097023fce6ef017001296acb568040cbb Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Thu, 28 Apr 2011 15:45:28 +0530 Subject: [PATCH 213/278] [FIX] outlook: removed encodeing for the attachment content bzr revid: rha@tinyerp.com-20110428101528-pljylyati4kq3xls --- addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index 90aa90fd09e..4bafe893704 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -336,9 +336,8 @@ class XMLRpcConn(object): att_path = os.path.join(att_folder_path,fn) attachments[i].SaveAsFile(att_path) f=open(att_path,"rb") - content = "".join(f.readlines()).encode('base64') + content = "".join(f.readlines()) f.close() - content = content.decode('base64') attachment[fn] = content return attachment From 96a33521da4a5a01440a31b95ec34aba3394999b Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Mon, 2 May 2011 12:28:49 +0530 Subject: [PATCH 214/278] [IMP] crm,crm_claim,crm_helpdesk,hr_recruitment,project_issue,project_mailgate: improvement in message_new() bzr revid: rha@tinyerp.com-20110502065849-19nilmvniw28n8ts --- addons/crm/crm_lead.py | 4 ++++ addons/crm_claim/crm_claim.py | 4 ++++ addons/crm_helpdesk/crm_helpdesk.py | 4 ++++ addons/hr_recruitment/hr_recruitment.py | 4 ++++ addons/project_issue/project_issue.py | 4 ++++ addons/project_mailgate/project_mailgate.py | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 132f95e3438..3f900c39045 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -378,6 +378,10 @@ class crm_lead(crm_case, osv.osv): references = msg.get('references', False) or msg.get('in-reply-to', False), attach = attachments, email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + priority = msg.get('priority', False), context = context) return res_id diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py index 04836a2ed79..26a7ac009b4 100644 --- a/addons/crm_claim/crm_claim.py +++ b/addons/crm_claim/crm_claim.py @@ -215,6 +215,10 @@ class crm_claim(crm.crm_case, osv.osv): references = msg.get('references', False) or msg.get('in-reply-to', False), attach = attachments, email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + priority = msg.get('priority', False), context = context) return res_id diff --git a/addons/crm_helpdesk/crm_helpdesk.py b/addons/crm_helpdesk/crm_helpdesk.py index 8c52618719d..59f19659d2c 100644 --- a/addons/crm_helpdesk/crm_helpdesk.py +++ b/addons/crm_helpdesk/crm_helpdesk.py @@ -138,6 +138,10 @@ class crm_helpdesk(crm.crm_case, osv.osv): references = msg.get('references', False) or msg.get('in-reply-to', False), attach = attachments, email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + priority = msg.get('priority', False), context = context) return res_id diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 3c2c5b9af0b..f7414f5229d 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -338,6 +338,10 @@ class hr_applicant(crm.crm_case, osv.osv): references = msg.get('references', False) or msg.get('in-reply-to', False), attach = attachments, email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + priority = msg.get('priority', False), context = context) return res_id diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 5bbd94c5a34..39c15bf85ca 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -420,6 +420,10 @@ class project_issue(crm.crm_case, osv.osv): references = msg.get('references', False) or msg.get('in-reply-to', False), attach = attachments, email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + priority = msg.get('priority', False), context = context) self.convert_to_bug(cr, uid, [res_id], context=context) return res_id diff --git a/addons/project_mailgate/project_mailgate.py b/addons/project_mailgate/project_mailgate.py index cea05b3fa44..c4698540053 100644 --- a/addons/project_mailgate/project_mailgate.py +++ b/addons/project_mailgate/project_mailgate.py @@ -65,6 +65,10 @@ class project_tasks(osv.osv): references = msg.get('references', False) or msg.get('in-reply-to', False), attach = attachments, email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + priority = msg.get('priority', False), context = context) return res_id From be4d3edd78cc3f98596591de63e4832a1316f309 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Mon, 2 May 2011 14:14:29 +0530 Subject: [PATCH 215/278] [FIX] mail: put attrs on page instead of field for the field body and body_html bzr revid: rha@tinyerp.com-20110502084429-075rjxhkvcvnl21g --- addons/mail/email_view.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/mail/email_view.xml b/addons/mail/email_view.xml index 7e52ec5a0af..3681202da07 100644 --- a/addons/mail/email_view.xml +++ b/addons/mail/email_view.xml @@ -40,11 +40,11 @@ - - + + - - + + From 48e0f09e685234fa48359e234a215ed32856fb6f Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Mon, 2 May 2011 15:00:40 +0530 Subject: [PATCH 216/278] [FIX] mail: removed variable has_plain_text variable from parse_message() so now be able to add html part in the email message bzr revid: rha@tinyerp.com-20110502093040-o3pamdy99a7porb8 --- addons/mail/email_message.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/addons/mail/email_message.py b/addons/mail/email_message.py index e68597eb851..d1d8ea37d75 100644 --- a/addons/mail/email_message.py +++ b/addons/mail/email_message.py @@ -399,18 +399,12 @@ class email_message(osv.osv): content = part.get_payload(decode=True) if filename: attachments[filename] = content - elif not has_plain_text: - # main content parts should have 'text' maintype - # and no filename. we ignore the html part if - # there is already a plaintext part without filename, - # because presumably these are alternatives. - content = tools.ustr(content, encoding) - if part.get_content_subtype() == 'html': - msg['body_html'] = content - body = tools.ustr(tools.html2plaintext(content)) - elif part.get_content_subtype() == 'plain': - body = content - #has_plain_text = True + content = tools.ustr(content, encoding) + if part.get_content_subtype() == 'html': + msg['body_html'] = content + body = tools.ustr(tools.html2plaintext(content)) + elif part.get_content_subtype() == 'plain': + body = content elif part.get_content_maintype() in ('application', 'image'): if filename : attachments[filename] = part.get_payload(decode=True) From 3a904e407b6b1a7122bac98470e3b9330926ffab Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Tue, 3 May 2011 12:08:44 +0530 Subject: [PATCH 217/278] [IMP] mail: able to retrive priority of an email message and related changes in message_new() and message_update() bzr revid: rha@tinyerp.com-20110503063844-yhlhlnpvciveh219 --- addons/crm/crm_lead.py | 7 ++++++- addons/crm_claim/crm_claim.py | 6 +++++- addons/crm_helpdesk/crm_helpdesk.py | 6 +++++- addons/hr_recruitment/hr_recruitment.py | 6 +++++- addons/mail/email_message.py | 12 ++++++++++-- addons/mail/email_thread.py | 7 ++++--- addons/project_issue/project_issue.py | 6 +++++- addons/project_mailgate/project_mailgate.py | 6 +++++- 8 files changed, 45 insertions(+), 11 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 3f900c39045..b95d00a101c 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -170,6 +170,7 @@ class crm_lead(crm_case, osv.osv): \nWhen the case is over, the state is set to \'Done\'.\ \nIf the case needs to be reviewed then the state is set to \'Pending\'.'), 'message_ids': fields.one2many('email.message', 'res_id', 'Messages', domain=[('model','=',_name)]), + 'subjects': fields.function(_get_email_subject, fnct_search=_history_search, string='Subject of Email', method=True, type='char', size=64), } @@ -381,7 +382,7 @@ class crm_lead(crm_case, osv.osv): body_html= msg.get('body_html'), sub_type = msg.get('sub_type'), headers = msg.get('headers'), - priority = msg.get('priority', False), + priority = msg.get('priority'), context = context) return res_id @@ -433,6 +434,10 @@ class crm_lead(crm_case, osv.osv): references = msg.get('references', False) or msg.get('in-reply-to', False), attach = attachments, email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + priority = msg.get('priority'), context = context) return res diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py index 26a7ac009b4..f6719edcb5b 100644 --- a/addons/crm_claim/crm_claim.py +++ b/addons/crm_claim/crm_claim.py @@ -218,7 +218,7 @@ class crm_claim(crm.crm_case, osv.osv): body_html= msg.get('body_html'), sub_type = msg.get('sub_type'), headers = msg.get('headers'), - priority = msg.get('priority', False), + priority = msg.get('priority'), context = context) return res_id @@ -270,6 +270,10 @@ class crm_claim(crm.crm_case, osv.osv): references = msg.get('references', False) or msg.get('in-reply-to', False), attach = attachments, email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + priority = msg.get('priority'), context = context) return res diff --git a/addons/crm_helpdesk/crm_helpdesk.py b/addons/crm_helpdesk/crm_helpdesk.py index 59f19659d2c..24ea1418bf8 100644 --- a/addons/crm_helpdesk/crm_helpdesk.py +++ b/addons/crm_helpdesk/crm_helpdesk.py @@ -141,7 +141,7 @@ class crm_helpdesk(crm.crm_case, osv.osv): body_html= msg.get('body_html'), sub_type = msg.get('sub_type'), headers = msg.get('headers'), - priority = msg.get('priority', False), + priority = msg.get('priority'), context = context) return res_id @@ -193,6 +193,10 @@ class crm_helpdesk(crm.crm_case, osv.osv): references = msg.get('references', False) or msg.get('in-reply-to', False), attach = attachments, email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + priority = msg.get('priority'), context = context) return res diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index f7414f5229d..ef44b22eb55 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -341,7 +341,7 @@ class hr_applicant(crm.crm_case, osv.osv): body_html= msg.get('body_html'), sub_type = msg.get('sub_type'), headers = msg.get('headers'), - priority = msg.get('priority', False), + priority = msg.get('priority'), context = context) return res_id @@ -391,6 +391,10 @@ class hr_applicant(crm.crm_case, osv.osv): references = msg.get('references', False) or msg.get('in-reply-to', False), attach = attachments, email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + priority = msg.get('priority'), context = context) return res diff --git a/addons/mail/email_message.py b/addons/mail/email_message.py index d1d8ea37d75..8ef0dde0228 100644 --- a/addons/mail/email_message.py +++ b/addons/mail/email_message.py @@ -60,6 +60,13 @@ email_content_types = [ ('html', 'text/html') ] +priorities = { + '1 (Highest)': '1', + '2 (High)': '2', + '3 (Normal)': '3', + '4 (Low)': '4', + '5 (Lowest)': '5', +} LOGGER = netsvc.Logger() _logger = logging.getLogger('mail') @@ -328,7 +335,6 @@ class email_message(osv.osv): msg_txt['message-id'] = message_id _logger.info('Parsing Message without message-id, generating a random one: %s', message_id) - fields = msg_txt.keys() msg['id'] = message_id msg['message-id'] = message_id @@ -364,7 +370,9 @@ class email_message(osv.osv): msg['in-reply-to'] = msg_txt.get('In-Reply-To') if 'X-Priority' in fields: - msg['priority'] = msg_txt.get('X-Priority', '3 (Normal)').split(' ')[0] #TOFIX: + msg['priority'] = priorities[msg_txt.get('X-Priority')] + else: + msg['priority'] = priorities['3 (Normal)'] msg['headers'] = {} for item in msg_txt.items(): diff --git a/addons/mail/email_thread.py b/addons/mail/email_thread.py index 0fb6f45819e..44d957c7ee1 100644 --- a/addons/mail/email_thread.py +++ b/addons/mail/email_thread.py @@ -96,6 +96,7 @@ class email_thread(osv.osv): sub_type = msg.get('sub_type', False), headers = msg.get('headers', False), reply = msg.get('reply', False), + priority = msg.get('priority'), context = context) return res_id @@ -125,6 +126,7 @@ class email_thread(osv.osv): sub_type = msg.get('sub_type', False), headers = msg.get('headers', False), reply = msg.get('reply', False), + priority = msg.get('priority'), context = context) return True @@ -168,8 +170,6 @@ class email_thread(osv.osv): if attach is None: attach = {} - - if email_date: edate = parsedate(email_date) if edate is not None: @@ -244,7 +244,8 @@ class email_thread(osv.osv): 'body_html': body_html, 'sub_type': sub_type, 'headers': headers, - 'reply_to': reply + 'reply_to': reply, + 'priority': priority } obj.create(cr, uid, data, context=context) return True diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 39c15bf85ca..def289ecc0f 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -423,7 +423,7 @@ class project_issue(crm.crm_case, osv.osv): body_html= msg.get('body_html'), sub_type = msg.get('sub_type'), headers = msg.get('headers'), - priority = msg.get('priority', False), + priority = msg.get('priority'), context = context) self.convert_to_bug(cr, uid, [res_id], context=context) return res_id @@ -481,6 +481,10 @@ class project_issue(crm.crm_case, osv.osv): references = msg.get('references', False) or msg.get('in-reply-to', False), attach = attachments, email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + priority = msg.get('priority'), context = context) return res diff --git a/addons/project_mailgate/project_mailgate.py b/addons/project_mailgate/project_mailgate.py index c4698540053..a7768fc862d 100644 --- a/addons/project_mailgate/project_mailgate.py +++ b/addons/project_mailgate/project_mailgate.py @@ -68,7 +68,7 @@ class project_tasks(osv.osv): body_html= msg.get('body_html'), sub_type = msg.get('sub_type'), headers = msg.get('headers'), - priority = msg.get('priority', False), + priority = msg.get('priority'), context = context) return res_id @@ -108,6 +108,10 @@ class project_tasks(osv.osv): references = msg.get('references', False) or msg.get('in-reply-to', False), attach = attachments, email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + priority = msg.get('priority'), context = context) return True From 9be4b6771cc185806e34766f58f48b17cceb4b15 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Wed, 4 May 2011 17:13:22 +0530 Subject: [PATCH 218/278] [FIX] thunderbird: parameters of the history() of partner.py bzr revid: rha@tinyerp.com-20110504114322-ijfo973i8ru6bxzq --- addons/thunderbird/partner/partner.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/thunderbird/partner/partner.py b/addons/thunderbird/partner/partner.py index 180499ae5b7..21b8dd94484 100644 --- a/addons/thunderbird/partner/partner.py +++ b/addons/thunderbird/partner/partner.py @@ -97,7 +97,12 @@ class thunderbird_partner(osv.osv_memory): message_id = msg.get('message-id'), references = msg.get('references', False) or msg.get('in-reply-to', False), attach = msg.get('attachments', {}), - email_date = msg.get('date')) + email_date = msg.get('date'), + body_html= msg.get('body_html'), + sub_type = msg.get('sub_type'), + headers = msg.get('headers'), + reply = msg.get('reply'), + priority = msg.get('priority'),) res_ids.append(res_id) return len(res_ids) From 3f694e2e6d537ebec5891466279ec5fd47455ea7 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Thu, 5 May 2011 17:22:42 +0530 Subject: [PATCH 219/278] [FIX]: crm: changes regarding *Merge opportunities wizard *Convert opportunities wizard, fix for cr and uid parameter passing bzr revid: rha@tinyerp.com-20110505115242-dsp2161zun8r2wmd --- addons/crm/wizard/crm_lead_to_opportunity.py | 6 +++--- addons/crm/wizard/crm_merge_opportunities.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py index f51016e0da7..e81e3006ef0 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity.py +++ b/addons/crm/wizard/crm_lead_to_opportunity.py @@ -140,13 +140,13 @@ class crm_lead2opportunity_partner(osv.osv_memory): }, context=context) leads.log(cr, uid, lead.id, _("Lead '%s' has been converted to an opportunity.") % lead.name) - def send_mail_to_salesman(self, lead): + def send_mail_to_salesman(self, cr, uid, lead): email_to = lead.user_id and lead.user_id.user_email if not email_to: return False message_pool = self.pool.get('email.message') email_from = lead.section_id and lead.section_id.user_id and lead.section_id.user_id.user_email or email_to - partner = lead.partner_id and lead.partner_id.name or lead.partner_name + partner = lead.partner_id and lead.partner_id.name or lead.partner_name subject = "lead %s converted into opportunity" % lead.name body = "Info \n Id : %s \n Subject: %s \n Partner: %s \n Description : %s " % (lead.id, lead.name, lead.partner_id.name, lead.description) return message_pool.schedule_with_attach(cr, uid, email_from, [email_to], subject, body) @@ -203,7 +203,7 @@ class crm_lead2opportunity_partner(osv.osv_memory): partner_id = False self._convert(cr, uid, ids, lead, partner_id, stage_ids, context=context) - self.send_mail_to_salesman(lead) + self.send_mail_to_salesman(cr, uid, lead) #If we convert in mass, don't merge if there is no other opportunity but no warning if data.name == 'merge' and (len(data.opportunity_ids) > 1 or not context.get('mass_convert') ): merge_obj = self.pool.get('crm.merge.opportunity') diff --git a/addons/crm/wizard/crm_merge_opportunities.py b/addons/crm/wizard/crm_merge_opportunities.py index fcc09e4a3b3..d339481da92 100644 --- a/addons/crm/wizard/crm_merge_opportunities.py +++ b/addons/crm/wizard/crm_merge_opportunities.py @@ -132,14 +132,14 @@ class crm_merge_opportunity(osv.osv_memory): 'partner_name' : self._get_first_not_null('partner_name', op_ids, oldest_opp), } - + #copy message into the first opportunity + merge attachement - + for opp in tail_opportunities + [first_opportunity]: attach_ids = self.get_attachments(cr, uid, opp, context=context) self.set_attachements_res_id(cr, uid, first_opportunity.id, attach_ids) for history in opp.message_ids: - new_history = message_obj.write(cr, uid, history.id, {'res_id': first_opportunity.id, 'name' : _("From %s : %s") % (opp.name, history.name) }, context=context) + new_history = message_obj.write(cr, uid, history.id, {'res_id': first_opportunity.id, 'name' : _("From %s : %s") % (opp.name, history.subject) }, context=context) #Notification about loss of information details = [] From 5c0308f078e30e5b6a2aa4d4bb5fba0682ecd760 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Tue, 10 May 2011 19:20:48 +0530 Subject: [PATCH 220/278] [FIX] bzr revid: rha@tinyerp.com-20110510135048-f044stg7gaij0867 --- addons/email_template/email_template.py | 4 +-- .../wizard/email_compose_message.py | 34 ++++++++++--------- .../wizard/email_template_preview.py | 2 +- .../wizard/email_compose_message_view.xml | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index 20a98c009ca..6169b7a2937 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -45,7 +45,7 @@ class email_template(osv.osv): "Return Template Object" if context is None: context = {} - + if not template_id: return False @@ -404,7 +404,7 @@ class email_template(osv.osv): # Add document attachments for attach in template.attachment_ids: #attach = attahcment_obj.browse(cr, uid, attachment_id, context) - attachment[attach.datas_fname] = attach.datas + attachment[attach.datas_fname] = base64.decodestring(attach.datas) values['attachment'] = attachment return values diff --git a/addons/email_template/wizard/email_compose_message.py b/addons/email_template/wizard/email_compose_message.py index 9dbb940d3da..ef6058ff892 100644 --- a/addons/email_template/wizard/email_compose_message.py +++ b/addons/email_template/wizard/email_compose_message.py @@ -61,22 +61,24 @@ class email_compose_message(osv.osv_memory): if context is None: context = {} att_ids = [] - res_id = context.get('active_id', False) - values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context) - if values['attachment']: - attachment = values['attachment'] - attachment_obj = self.pool.get('ir.attachment') - for fname, fcontent in attachment.items(): - data_attach = { - 'name': fname, - 'datas': binascii.b2a_base64(str(fcontent)), - 'datas_fname': fname, - 'description': _('Mail attachment'), - 'res_model' : self._name, - 'res_id' : ids and ids[0] or False - } - att_ids.append(attachment_obj.create(cr, uid, data_attach)) - values['attachment_ids'] = att_ids + values = {} + if template_id: + res_id = context.get('active_id', False) + values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context) + if values['attachment']: + attachment = values['attachment'] + attachment_obj = self.pool.get('ir.attachment') + for fname, fcontent in attachment.items(): + data_attach = { + 'name': fname, + 'datas': binascii.b2a_base64(str(fcontent)), + 'datas_fname': fname, + 'description': _('Mail attachment'), + 'res_model' : self._name, + 'res_id' : ids and ids[0] or False + } + att_ids.append(attachment_obj.create(cr, uid, data_attach)) + values['attachment_ids'] = att_ids return {'value': values} def save_as_template(self, cr, uid, ids, context=None): diff --git a/addons/email_template/wizard/email_template_preview.py b/addons/email_template/wizard/email_template_preview.py index 94b86deec8b..6b2b546c267 100644 --- a/addons/email_template/wizard/email_template_preview.py +++ b/addons/email_template/wizard/email_template_preview.py @@ -38,7 +38,7 @@ class email_template_preview(osv.osv_memory): if context is None: context = {} - template_id = context.get('active_id', False) + template_id = context.get('template_id', False) if not template_id: return [] template_pool = self.pool.get('email.template') diff --git a/addons/mail/wizard/email_compose_message_view.xml b/addons/mail/wizard/email_compose_message_view.xml index dd89d0267ff..0cc90f3e7c9 100644 --- a/addons/mail/wizard/email_compose_message_view.xml +++ b/addons/mail/wizard/email_compose_message_view.xml @@ -33,7 +33,7 @@