From 1513a9ae77e9cba0909cfb97da4f5548b7012da1 Mon Sep 17 00:00:00 2001 From: "YSA (Openerp)" Date: Tue, 1 Feb 2011 17:13:08 +0530 Subject: [PATCH 001/564] [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 128/564] [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 129/564] [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 130/564] [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 131/564] [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 7675254982427108fd3e70bd2306b36c58660f11 Mon Sep 17 00:00:00 2001 From: Quentin THEURET Date: Fri, 25 Feb 2011 16:04:03 +0100 Subject: [PATCH 132/564] [FIX] Duplicated menus entries -- Call the good view on 'Synchronized object' wizard lp bug: https://launchpad.net/bugs/725033 fixed bzr revid: quentin@tempo-quentin-20110225150403-tsxsukf1wvmhkoam --- addons/base_synchro/wizard/base_synchro_view.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/base_synchro/wizard/base_synchro_view.xml b/addons/base_synchro/wizard/base_synchro_view.xml index c0c140f3791..e4ffc8e323c 100644 --- a/addons/base_synchro/wizard/base_synchro_view.xml +++ b/addons/base_synchro/wizard/base_synchro_view.xml @@ -25,22 +25,22 @@ base.synchro form form + new - Base Synchronization base.synchro form -
+
-
- 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 289/564] [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 a94a27fbb3b848d876626f5ed6cfad5177addc52 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 29 Apr 2011 17:38:28 +0530 Subject: [PATCH 290/564] [FIX]stock:locations cannot be sorted and put parent location field in search view lp bug: https://launchpad.net/bugs/765559 fixed bzr revid: ron@tinyerp.com-20110429120828-j33844o6a9qd7ien --- addons/stock/stock.py | 2 +- addons/stock/stock_view.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index d6cef8bc458..633a74923ec 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -164,7 +164,7 @@ class stock_location(osv.osv): \n* Production: Virtual counterpart location for production operations: this location consumes the raw material and produces finished products """, select = True), # temporarily removed, as it's unused: 'allocation_method': fields.selection([('fifo', 'FIFO'), ('lifo', 'LIFO'), ('nearest', 'Nearest')], 'Allocation Method', required=True), - 'complete_name': fields.function(_complete_name, method=True, type='char', size=100, string="Location Name"), + 'complete_name': fields.function(_complete_name, method=True, type='char', size=100, string="Location Name", store=True), 'stock_real': fields.function(_product_value, method=True, type='float', string='Real Stock', multi="stock"), 'stock_virtual': fields.function(_product_value, method=True, type='float', string='Virtual Stock', multi="stock"), diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index a22ece14fc5..3eb93cd6618 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -559,6 +559,7 @@ string="Supplier" domain="[('usage', '=', 'supplier')]" help="Supplier Locations" /> + 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 291/564] [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 292/564] [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 293/564] [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 364b09896623cf5cc061b96915ead68f0880dcca Mon Sep 17 00:00:00 2001 From: Osenda <> Date: Mon, 2 May 2011 11:55:04 +0200 Subject: [PATCH 294/564] [IMP] bareme rule, employee view bzr revid: osenda-20110502095504-oii83zji4mst0tjg --- .../data/hr.salary.rule.csv | 20 +++++++++---------- .../hr_payroll_l10n_be/hr_payroll_l10n_be.py | 4 ++-- .../hr_payroll_l10n_be_data.xml | 4 ++-- .../hr_payroll_l10n_be_view.xml | 5 +++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/addons/hr_payroll_l10n_be/data/hr.salary.rule.csv b/addons/hr_payroll_l10n_be/data/hr.salary.rule.csv index 1ce84969cb5..8788e7e060e 100644 --- a/addons/hr_payroll_l10n_be/data/hr.salary.rule.csv +++ b/addons/hr_payroll_l10n_be/data/hr.salary.rule.csv @@ -1422,13 +1422,13 @@ 1418,"fix",9,9,,1452,"Child Allowance Belgium","Child Allowance Belgium",140,"Ch.A","hr_payroll_rules_child","range","employee.children", 1419,"fix",10,10,,1673,"Child Allowance Belgium","Child Allowance Belgium",140,"Ch.A","hr_payroll_rules_child","range","employee.children", ,,,,,,,,,,,,, -1420,"fix",1,1,,62,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1421,"fix",2,2,,170,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1422,"fix",3,3,,458,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1423,"fix",4,4,,836,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1424,"fix",5,5,,1236,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1425,"fix",6,6,,1634,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1426,"fix",7,7,,2032,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1427,"fix",8,8,,2462,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1428,"fix",9,9,,2904,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1429,"fix",10,10,,3346,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1420,"fix",1,1,,85,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1421,"fix",2,2,,418,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1422,"fix",3,3,,817,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1423,"fix",4,4,,1231,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1424,"fix",5,5,,1673,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1425,"fix",6,6,,2115,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1426,"fix",7,7,,2557,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1427,"fix",8,8,,2999,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1428,"fix",9,9,,3441,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1429,"fix",10,10,,3883,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", diff --git a/addons/hr_payroll_l10n_be/hr_payroll_l10n_be.py b/addons/hr_payroll_l10n_be/hr_payroll_l10n_be.py index 2f667da1666..0dd0fcf5ac3 100644 --- a/addons/hr_payroll_l10n_be/hr_payroll_l10n_be.py +++ b/addons/hr_payroll_l10n_be/hr_payroll_l10n_be.py @@ -49,8 +49,8 @@ class hr_contract_be(osv.osv): 'advantage':fields.float('Benefits of various nature ', digits=(16,2)), 'suppl_net':fields.float('Net supplements', digits=(16,2)), 'retained_net':fields.float('Net retained ', digits=(16,2)), - 'vol_tax':fields.float('Voluntary tax ', digits=(16,2)), - 'horaire_effectif': fields.many2one('resource.calendar','Actual Work', help="Hours of work means the actual working time elapsing between the beginning and end of the workday, regardless of where it runs, excluding the stop work devoted to meals, breaks and, more generally, any interruptions between 2 sequences of work that are not actually worked since the employee can go freely about his personal affairs"), +# 'vol_tax':fields.float('Voluntary tax ', digits=(16,2)), +# 'horaire_effectif': fields.many2one('resource.calendar','Actual Work', help="Hours of work means the actual working time elapsing between the beginning and end of the workday, regardless of where it runs, excluding the stop work devoted to meals, breaks and, more generally, any interruptions between 2 sequences of work that are not actually worked since the employee can go freely about his personal affairs"), } hr_contract_be() diff --git a/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_data.xml b/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_data.xml index c0dd0417688..4c570704c75 100644 --- a/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_data.xml +++ b/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_data.xml @@ -76,7 +76,7 @@ python - result = (((employee.marital=='single') or (employee.marital=='married' and statut_fiscal=='with income')) and (employee.resident!=True)) + result = (((employee.marital=='single') or (employee.marital=='married' and employee.statut_fiscal=='with income')) and (employee.resident!=True))
@@ -88,7 +88,7 @@ 120 python - result = (employee.marital=='married' and statut_fiscal=='without income') + result = ((employee.marital=='married' and employee.statut_fiscal=='without income') and (employee.resident!=True)) diff --git a/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_view.xml b/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_view.xml index 769b6e8ea4a..fa14cb45b04 100644 --- a/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_view.xml +++ b/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_view.xml @@ -9,9 +9,10 @@ - + @@ -22,7 +23,7 @@ - + From d337219345fe7dd261d666095d6169ff1368ed04 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Mon, 2 May 2011 15:44:38 +0530 Subject: [PATCH 295/564] [IMP]stock:order by location complete name bzr revid: ron@tinyerp.com-20110502101438-g7kw8njfe1yaje4a --- addons/stock/stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 633a74923ec..d8042a3d5b1 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -71,7 +71,7 @@ class stock_location(osv.osv): _parent_name = "location_id" _parent_store = True _parent_order = 'posz,name' - _order = 'parent_left' + _order = 'complete_name' def name_get(self, cr, uid, ids, context=None): res = [] 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 296/564] [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 297/564] [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 298/564] [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 dd49fde2011a43574323a80ffa58a1c930d01c85 Mon Sep 17 00:00:00 2001 From: Osenda <> Date: Mon, 9 May 2011 10:26:05 +0200 Subject: [PATCH 299/564] [FIX] rectification de la dependance de l ONSS + ajout de la rule disabled spouse bzr revid: osenda-20110509082605-ijnlwtn3324parj2 --- .../data/hr.salary.rule.csv | 40 +++++++++---------- .../hr_payroll_l10n_be_data.xml | 22 +++++++++- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/addons/hr_payroll_l10n_be/data/hr.salary.rule.csv b/addons/hr_payroll_l10n_be/data/hr.salary.rule.csv index 8788e7e060e..471bcd5b77f 100644 --- a/addons/hr_payroll_l10n_be/data/hr.salary.rule.csv +++ b/addons/hr_payroll_l10n_be/data/hr.salary.rule.csv @@ -1411,24 +1411,24 @@ 1408,"fix",7485,7500,,-3480.71,"Precompte Professionnel","Precompte Professionnel Bareme 2011",130,"P.P","hr_payroll_rules_baremeIII","range","rules['GROSS']", 1409,"fix",7500,7500,,-3488.73,"Precompte Professionnel","Precompte Professionnel Bareme 2011",130,"P.P","hr_payroll_rules_baremeIII","range","rules['GROSS']", ,,,,,,,,,,,,, -1410,"fix",1,1,,31,"Child Allowance Belgium","Child Allowance Belgium",140,"Ch.A","hr_payroll_rules_child","range","employee.children", -1411,"fix",2,2,,85,"Child Allowance Belgium","Child Allowance Belgium",140,"Ch.A","hr_payroll_rules_child","range","employee.children", -1412,"fix",3,3,,229,"Child Allowance Belgium","Child Allowance Belgium",140,"Ch.A","hr_payroll_rules_child","range","employee.children", -1413,"fix",4,4,,418,"Child Allowance Belgium","Child Allowance Belgium",140,"Ch.A","hr_payroll_rules_child","range","employee.children", -1414,"fix",5,5,,618,"Child Allowance Belgium","Child Allowance Belgium",140,"Ch.A","hr_payroll_rules_child","range","employee.children", -1415,"fix",6,6,,817,"Child Allowance Belgium","Child Allowance Belgium",140,"Ch.A","hr_payroll_rules_child","range","employee.children", -1416,"fix",7,7,,1016,"Child Allowance Belgium","Child Allowance Belgium",140,"Ch.A","hr_payroll_rules_child","range","employee.children", -1417,"fix",8,8,,1231,"Child Allowance Belgium","Child Allowance Belgium",140,"Ch.A","hr_payroll_rules_child","range","employee.children", -1418,"fix",9,9,,1452,"Child Allowance Belgium","Child Allowance Belgium",140,"Ch.A","hr_payroll_rules_child","range","employee.children", -1419,"fix",10,10,,1673,"Child Allowance Belgium","Child Allowance Belgium",140,"Ch.A","hr_payroll_rules_child","range","employee.children", +1410,"fix",1,1,,31,"Child Allowance Belgium","Child Allowance Belgium",142,"Ch.A","hr_payroll_rules_child","range","employee.children", +1411,"fix",2,2,,85,"Child Allowance Belgium","Child Allowance Belgium",142,"Ch.A","hr_payroll_rules_child","range","employee.children", +1412,"fix",3,3,,229,"Child Allowance Belgium","Child Allowance Belgium",142,"Ch.A","hr_payroll_rules_child","range","employee.children", +1413,"fix",4,4,,418,"Child Allowance Belgium","Child Allowance Belgium",142,"Ch.A","hr_payroll_rules_child","range","employee.children", +1414,"fix",5,5,,618,"Child Allowance Belgium","Child Allowance Belgium",142,"Ch.A","hr_payroll_rules_child","range","employee.children", +1415,"fix",6,6,,817,"Child Allowance Belgium","Child Allowance Belgium",142,"Ch.A","hr_payroll_rules_child","range","employee.children", +1416,"fix",7,7,,1016,"Child Allowance Belgium","Child Allowance Belgium",142,"Ch.A","hr_payroll_rules_child","range","employee.children", +1417,"fix",8,8,,1231,"Child Allowance Belgium","Child Allowance Belgium",142,"Ch.A","hr_payroll_rules_child","range","employee.children", +1418,"fix",9,9,,1452,"Child Allowance Belgium","Child Allowance Belgium",142,"Ch.A","hr_payroll_rules_child","range","employee.children", +1419,"fix",10,10,,1673,"Child Allowance Belgium","Child Allowance Belgium",142,"Ch.A","hr_payroll_rules_child","range","employee.children", ,,,,,,,,,,,,, -1420,"fix",1,1,,85,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1421,"fix",2,2,,418,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1422,"fix",3,3,,817,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1423,"fix",4,4,,1231,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1424,"fix",5,5,,1673,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1425,"fix",6,6,,2115,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1426,"fix",7,7,,2557,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1427,"fix",8,8,,2999,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1428,"fix",9,9,,3441,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", -1429,"fix",10,10,,3883,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",141,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1420,"fix",1,1,,85,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",144,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1421,"fix",2,2,,418,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",144,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1422,"fix",3,3,,817,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",144,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1423,"fix",4,4,,1231,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",144,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1424,"fix",5,5,,1673,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",144,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1425,"fix",6,6,,2115,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",144,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1426,"fix",7,7,,2557,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",144,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1427,"fix",8,8,,2999,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",144,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1428,"fix",9,9,,3441,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",144,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", +1429,"fix",10,10,,3883,"Child Allowance for the Disabled Belgium","Child Allowance Belgium",144,"Ch.Handicap","hr_payroll_rules_child_handicap","range","employee.number_handicap", diff --git a/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_data.xml b/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_data.xml index 4c570704c75..fa7b85e9508 100644 --- a/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_data.xml +++ b/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_data.xml @@ -30,6 +30,13 @@ Ch.A + + + + Disabled Spouse + Sp.handicap + + @@ -39,7 +46,7 @@ MAJ none percentage - contract.wage + rules['MAJ'] 108.00
@@ -137,7 +144,7 @@ Child Allowance for the Disabled Belgium Ch.Handicap fix - 142 + 143 "Disabled child" means: the child reaches at least 66% of failure or reduced physical or mental capacity @@ -150,6 +157,17 @@ result = bool(employee.number_handicap)
+ + + Disabled Spouse Allowance + Sp.handicap + fix + 145 + 31 + python + result = employee.handicap==True + + From 9483dc163ea99ac054ab9ecb0bca740940145933 Mon Sep 17 00:00:00 2001 From: Osenda <> Date: Mon, 9 May 2011 15:03:04 +0200 Subject: [PATCH 300/564] [FIX] 4482 revision pour ONSS bzr revid: osenda-20110509130304-00a1n82d066oyo91 --- .../hr_payroll_l10n_be_data.xml | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_data.xml b/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_data.xml index fa7b85e9508..4f749e5d2d6 100644 --- a/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_data.xml +++ b/addons/hr_payroll_l10n_be/hr_payroll_l10n_be_data.xml @@ -2,10 +2,16 @@ - Salaire Majore + Premium pay 108% Worker MAJ + + + Employee Salary + NON-MAJ + + Office National Securite Sociale ONSS @@ -42,14 +48,21 @@ - Salaire Majore - MAJ + Premium pay 108% Worker + SALARY none - percentage - rules['MAJ'] - 108.00 + code + result = contract.wage * 1.08 + + + Salary Employee + SALARY + none + code + result = contract.wage * 1 + @@ -58,10 +71,12 @@ 41 none percentage - contract.wage + rules['SALARY'] -13.07 + + Precompte Professionnel Bareme 2011 @@ -319,7 +334,7 @@ C.P.218 Belgian Employee - + 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 301/564] [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 @@