← Back to team overview

avanzosc team mailing list archive

[Merge] lp:~dani-ds/avanzosc/dos_email_multiple_account into lp:~avanzosc-security-team/avanzosc/72horas

 

Daniel Campos (Avanzosc) has proposed merging lp:~dani-ds/avanzosc/dos_email_multiple_account into lp:~avanzosc-security-team/avanzosc/72horas.

Requested reviews:
  Avanzosc_security (avanzosc-security-team)

For more details, see:
https://code.launchpad.net/~dani-ds/avanzosc/dos_email_multiple_account/+merge/225652

Migración dos_email_multiple_account
-- 
https://code.launchpad.net/~dani-ds/avanzosc/dos_email_multiple_account/+merge/225652
Your team Avanzosc_security is requested to review the proposed merge of lp:~dani-ds/avanzosc/dos_email_multiple_account into lp:~avanzosc-security-team/avanzosc/72horas.
=== modified file 'dos_email_multiple_account/__init__.py'
--- dos_email_multiple_account/__init__.py	2014-06-11 10:23:47 +0000
+++ dos_email_multiple_account/__init__.py	2014-07-04 12:13:49 +0000
@@ -21,5 +21,5 @@
 #
 ##############################################################################
 
-import email_multiple_account
-import wizard
\ No newline at end of file
+from . import models
+from . import wizard
\ No newline at end of file

=== modified file 'dos_email_multiple_account/__openerp__.py'
--- dos_email_multiple_account/__openerp__.py	2014-06-11 10:23:47 +0000
+++ dos_email_multiple_account/__openerp__.py	2014-07-04 12:13:49 +0000
@@ -19,25 +19,24 @@
 #
 ##############################################################################
 
-
 {
-    "name" : "DOS Email Multiple Account",
-    "version" : "1.0",
-    "author" : "DOS",
-    "category" : "Generic Modules",
-    "website" : "www.dos-sl.es",
-    "description": """Use Email client module to send to customers or suppliers
-the selected invoices attached by Email. 
-Historical and statistical data is recorded in the smtpclient module.""",
-    "depends" : ["smtpclient","account"],
-    "init_xml" : [],
-    "update_xml" : ['email_multiple_account_view.xml',
-                    'account_invoice_view.xml',
-                    'account_invoice_wizard.xml',
-                    'security/email_multiple_account_security.xml',
-                    'security/ir.model.access.csv'],
+    "name": "DOS Email Multiple Account",
+    "version": "1.0",
+    "author": "DOS",
+    "category": "Generic Modules",
+    "website": "www.dos-sl.es",
+    "description": """
+        Use Email client module to send to customers or suppliers
+        the selected invoices attached by Email.
+        Historical and statistical data is recorded in the
+         smtpclient module.""",
+    "depends": ["smtpclient", "account"],
+    "data": [
+        'views/email_multiple_account_view.xml',
+        'views/account_invoice_view.xml',
+        'wizard/account_invoice_wizard.xml',
+        'security/email_multiple_account_security.xml',
+        'security/ir.model.access.csv'],
     "active": False,
     "installable": True
 }
-
-

=== added directory 'dos_email_multiple_account/models'
=== added file 'dos_email_multiple_account/models/__init__.py'
--- dos_email_multiple_account/models/__init__.py	1970-01-01 00:00:00 +0000
+++ dos_email_multiple_account/models/__init__.py	2014-07-04 12:13:49 +0000
@@ -0,0 +1,25 @@
+
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2008-2014 AvanzOSC (Daniel). All Rights Reserved
+#    Date: 04/07/2014
+#
+#    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 General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see http://www.gnu.org/licenses/.
+#
+##############################################################################
+
+
+from . import email_multiple_account
\ No newline at end of file

=== renamed file 'dos_email_multiple_account/email_multiple_account.py' => 'dos_email_multiple_account/models/email_multiple_account.py'
--- dos_email_multiple_account/email_multiple_account.py	2014-06-11 10:23:47 +0000
+++ dos_email_multiple_account/models/email_multiple_account.py	2014-07-04 12:13:49 +0000
@@ -19,28 +19,24 @@
 #
 ##############################################################################
 
-from osv import osv
-from osv import fields
-from tools.translate import _
-
-class email_multiple_account_config(osv.osv): 
-
-	_name = 'email.multiple.account.config'
-	_description = 'Email Multiple Account Config'
-
-	_columns = {
-		'subject': fields.char('Subject', size=256, required=True, help='Subject of the email.'),
-		'body': fields.text('Body', required=True, help='Body of the email.'),
-		'sequence': fields.integer('Sequence', required=True),
-	}
-	
-	_order = 'sequence asc'
-	
-	
-	def get_default(self, cr, uid, context):
-		templates_ids = self.search(cr, uid, [])
-		if templates_ids:
-			return self.browse(cr, uid, templates_ids[0], context)
-		return None
-	
-email_multiple_account_config()
\ No newline at end of file
+from openerp import orm, fields
+
+
+class EmailMultipleAccountConfig(orm.Model):
+    _name = 'email.multiple.account.config'
+    _description = 'Email Multiple Account Config'
+
+    _columns = {
+        'subject': fields.char('Subject', size=256, required=True,
+                               help='Subject of the email.'),
+        'body': fields.text('Body', required=True, help='Body of the email.'),
+        'sequence': fields.integer('Sequence', required=True),
+    }
+
+    _order = 'sequence asc'
+
+    def get_default(self, cr, uid, context):
+        templates_ids = self.search(cr, uid, [])
+        if templates_ids:
+            return self.browse(cr, uid, templates_ids[0], context)
+        return None

=== modified file 'dos_email_multiple_account/security/email_multiple_account_security.xml'
--- dos_email_multiple_account/security/email_multiple_account_security.xml	2014-06-11 10:23:47 +0000
+++ dos_email_multiple_account/security/email_multiple_account_security.xml	2014-07-04 12:13:49 +0000
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <openerp>
-  <data> 
-    <record id="group_email_multiple_account_user" model="res.groups">
-      <field name="name">Email Multiple Account / User</field>
-    </record>
-    <record id="group_email_multiple_account_manager" model="res.groups">
-      <field name="name">Email Multiple Account / Manager</field>
-    </record>
-  </data>
+	<data>
+		<record id="group_email_multiple_account_user" model="res.groups">
+			<field name="name">Email Multiple Account / User</field>
+		</record>
+		<record id="group_email_multiple_account_manager" model="res.groups">
+			<field name="name">Email Multiple Account / Manager</field>
+		</record>
+	</data>
 </openerp>

=== added directory 'dos_email_multiple_account/views'
=== renamed file 'dos_email_multiple_account/account_invoice_view.xml' => 'dos_email_multiple_account/views/account_invoice_view.xml'
--- dos_email_multiple_account/account_invoice_view.xml	2014-06-11 10:23:47 +0000
+++ dos_email_multiple_account/views/account_invoice_view.xml	2014-07-04 12:13:49 +0000
@@ -1,20 +1,19 @@
 <?xml version="1.0" encoding="utf-8"?>
 <openerp>
-    <data>
-    
-        <!--  Invoice Search View -->
-        <record id="view_account_invoice_filter_inherit" model="ir.ui.view">
-            <field name="name">account.invoice.select.inherit</field>
-            <field name="model">account.invoice</field>
+	<data>
+			<!--  Invoice Search View -->
+		<record id="view_account_invoice_filter_inherit" model="ir.ui.view">
+			<field name="name">account.invoice.select.inherit</field>
+			<field name="model">account.invoice</field>
 			<field name="inherit_id" ref="account.view_account_invoice_filter"/>
-            <field name="arch" type="xml">
+			<field name="arch" type="xml">
 				<filter name="unpaid" position="after">
 					<separator orientation="vertical" />
 					<filter name="send_email" icon="terp-mail-message-new" string="Send Email" domain="[('partner_id.tipo_envio_correo','in',['electronico','postal_electronico'])]" help="Customers who want the invoice sent by email"/>
 					<filter name="send_paper" icon="terp-emblem-documents" string="Send Paper" domain="[('partner_id.tipo_envio_correo','in',['postal','postal_electronico'])]" help="Customers who want the invoice sent by post"/>
 				</filter>
-            </field>
-        </record>
-        
-    </data>
+			</field>
+		</record>
+
+	</data>
 </openerp>

=== renamed file 'dos_email_multiple_account/email_multiple_account_view.xml' => 'dos_email_multiple_account/views/email_multiple_account_view.xml'
--- dos_email_multiple_account/email_multiple_account_view.xml	2014-06-11 10:23:47 +0000
+++ dos_email_multiple_account/views/email_multiple_account_view.xml	2014-07-04 12:13:49 +0000
@@ -1,39 +1,36 @@
 <?xml version="1.0" encoding="utf-8"?>
 <openerp>
 	<data>
-	
+
 		<!-- Email Multiple Account Config Search View-->
-        <record id="view_email_multiple_account_config_search" model="ir.ui.view">
-            <field name="name">view.email.multiple.account.config.search</field>
-            <field name="model">email.multiple.account.config</field>
-            <field name="type">search</field>
-            <field name="arch" type="xml">
-                <search string="Search">
-                	<field name="sequence" select="1"/>
-                    <field name="subject" select="1"/>
-               </search>
-            </field>
-        </record>
-        
+		<record id="view_email_multiple_account_config_search" model="ir.ui.view">
+			<field name="name">view.email.multiple.account.config.search</field>
+			<field name="model">email.multiple.account.config</field>
+			<field name="arch" type="xml">
+				<search string="Search">
+					<field name="sequence" select="1"/>
+					<field name="subject" select="1"/>
+				</search>
+			</field>
+		</record>
+
 		<!-- Email Multiple Account Config Tree View-->
-        <record id="view_email_multiple_account_config_tree" model="ir.ui.view">
-            <field name="name">view.email.multiple.account.config.tree</field>
-            <field name="model">email.multiple.account.config</field>
-            <field name="type">tree</field>
-            <field name="arch" type="xml">
-                <tree string="Email Template">
-                	<field name="sequence" />
-                    <field name="subject" />
+		<record id="view_email_multiple_account_config_tree" model="ir.ui.view">
+			<field name="name">view.email.multiple.account.config.tree</field>
+			<field name="model">email.multiple.account.config</field>
+			<field name="arch" type="xml">
+				<tree string="Email Template">
+					<field name="sequence" />
+					<field name="subject" />
 					<field name="body" />
-                </tree>
-            </field>
-        </record>
-		
+				</tree>
+			</field>
+		</record>
+
 		<!-- Email Multiple Account Config Form View -->
 		<record id="view_email_multiple_account_config_form" model="ir.ui.view" >
 			<field name="name">view.email.multiple.account.config.form</field>
 			<field name="model">email.multiple.account.config</field>
-			<field name="type">form</field>
 			<field name="arch" type="xml">
 				<form string="Email Template Config">
 					<group colspan="4" col="4">
@@ -46,16 +43,16 @@
 				</form>
 			</field>
 		</record>
-		
-        <record id="action_email_multiple_account_config" model="ir.actions.act_window">
-            <field name="name">Email Configuration</field>
-            <field name="type">ir.actions.act_window</field>
-            <field name="res_model">email.multiple.account.config</field>
-            <field name="view_type">form</field>
-            <field name="view_id" ref="view_email_multiple_account_config_tree"/>
-        </record>
-        
-        <menuitem name="Email Configuration" id="menu_email_multiple_configuration" parent="base.menu_config"/>
+
+		<record id="action_email_multiple_account_config" model="ir.actions.act_window">
+			<field name="name">Email Configuration</field>
+			<field name="type">ir.actions.act_window</field>
+			<field name="res_model">email.multiple.account.config</field>
+			<field name="view_type">form</field>
+			<field name="view_id" ref="view_email_multiple_account_config_tree"/>
+		</record>
+
+		<menuitem name="Email Configuration" id="menu_email_multiple_configuration" parent="base.menu_config"/>
 		<menuitem name="Email Templates" id="menu_email_template" action="action_email_multiple_account_config" parent="menu_email_multiple_configuration" sequence="1"/>
 
 	</data>

=== renamed file 'dos_email_multiple_account/account_invoice_wizard.xml' => 'dos_email_multiple_account/wizard/account_invoice_wizard.xml'
--- dos_email_multiple_account/account_invoice_wizard.xml	2014-06-11 10:23:47 +0000
+++ dos_email_multiple_account/wizard/account_invoice_wizard.xml	2014-07-04 12:13:49 +0000
@@ -1,7 +1,46 @@
 <?xml version="1.0" encoding="utf-8"?>
 <openerp>
-    <data>
-        <!-- Redeclaration of the wizards defined in auto_email_account -->
-        <wizard string="Send Multiple Invoices by Email" model="account.invoice" name="account.invoice.multiple_email_send" id="account_invoice_multiple_email_send_wizard"/>
-    </data>
+	<data>
+
+		<record id="email_send_form_view" model="ir.ui.view">
+		<field name="name">email.send.form.view</field>
+		<field name="model">wizard.send.email</field>
+		<field name="arch" type="xml">
+			<form string="Send Multiple Invoices by Email">
+				<separator string="The following invoices will be sent:" colspan="4"/>
+				<field name="text_sent" nolabel="1" colspan="4" width="600" height="250" />
+				<newline />
+				<separator string="The following invoices do not have an email address defined:" colspan="4"/>
+				<field name="text_error" nolabel="1" colspan="4" width="600" height="100" />
+				<footer>
+					<button class="oe_link" special="cancel" string="Cancel"/>
+					<button  icon="gtk-ok" name="_send_mails" string="Send Email" type="object"/>
+				</footer>
+			</form>
+		</field>
+	</record>
+	
+	<record id="email_done_form_view" model="ir.ui.view">
+		<field name="name">email.done.form.view</field>
+		<field name="model">wizard.send.email</field>
+		<field name="arch" type="xml">
+			<form string="Send Multiple Invoices by Email">
+				<field name="email_sent"/>
+				<button class="oe_link" special="cancel" string="Done"/>
+			</form>
+		</field>
+	</record>
+	
+	<!-- Redeclaration of the wizards defined in auto_email_account -->
+
+	<act_window 
+		id= "account_invoice_multiple_email_send"
+		name= "Invoice Multipl Email Send" 
+		res_model= "wizard.send.email"
+		src_model= "account.invoice"
+		key2= "client_action_multi"
+		view_id = "email_send_form_view"
+		target ="new" />
+
+	</data>
 </openerp>

=== modified file 'dos_email_multiple_account/wizard/wizard_multiple_send_email.py'
--- dos_email_multiple_account/wizard/wizard_multiple_send_email.py	2014-06-11 10:23:47 +0000
+++ dos_email_multiple_account/wizard/wizard_multiple_send_email.py	2014-07-04 12:13:49 +0000
@@ -19,209 +19,195 @@
 #
 ##############################################################################
 
-import wizard
-import pooler
-import tools
-
-from tools.translate import _
-from osv import fields,osv
-import time
+from openerp.tools.translate import _
+from openerp import fields, orm
 import netsvc
-from tools.misc import UpdateableStr, UpdateableDict
-
-email_send_form = '''<?xml version="1.0" encoding="utf-8"?>
-<form string="Send Multiple Invoices by Email">
-    <separator string="The following invoices will be sent:" colspan="4"/>
-    <field name="text_sent" nolabel="1" colspan="4" width="600" height="250" />
-    <newline />
-    <separator string="The following invoices do not have an email address defined:" colspan="4"/>
-    <field name="text_error" nolabel="1" colspan="4" width="600" height="100" />
-</form>'''
-
-email_send_fields = {
-    'text_sent': {'string':'Message', 'type':'text', 'readonly':True},
-    'text_error': {'string':'Message', 'type':'text', 'readonly':True}
-}
-
-email_done_form = '''<?xml version="1.0" encoding="utf-8"?>
-<form string="Send Multiple Invoices by Email">
-    <field name="email_sent"/>
-</form>'''
-
-email_done_fields = {
-    'email_sent': {'string':'Quantity of Emails sent', 'type':'integer', 'readonly': True},
-}
-
-
-def _get_defaults(self, cr, uid, data, context):
-    p = pooler.get_pool(cr.dbname)
-    user = p.get('res.users').browse(cr, uid, uid, context)
-    
-    text_sent = ''
-    text_error = ''
-    i = 0
-    j = 0
-    invoices = p.get(data['model']).browse(cr, uid, data['ids'], context)
- 
-    for inv in invoices:
-        to = []
-        email = None
-        name = None
-        
-        if inv.address_invoice_id and inv.address_invoice_id.email:
-            name = inv.address_invoice_id.name or inv.address_invoice_id.partner_id.name
-            to.extend(['"%s" <%s>' % (name, email) for email in inv.address_invoice_id.email.split(',')])
-            email = ','.join(to)
-        elif inv.address_contact_id and inv.address_contact_id.email:
-            name = inv.address_contact_id.name or inv.address_contact_id.partner_id.name
-            to.extend(['"%s" <%s>' % (name, email) for email in inv.address_contact_id.email.split(',')])
-            email = ','.join(to)
-            
-        if email:
-            i += 1
-            
-            inv_number = inv.number or '-'
-            inv_name = inv.name or '-'
-            
-            text_sent += str(i) + '. ' + _('Invoice Num.: ') + inv_number + ' // ' + _('Name: ') + inv_name + '\n'
-            text_sent += '\t' + email + '\n\n'
-            
+# from tools.misc import UpdateableStr, UpdateableDict
+
+
+class WizardSendEmail(orm.TransientModel):
+
+    def _get_defaults(self, cr, uid, data, context):
+
+        # user = self.pool['res.users'].browse(cr, uid, uid, context)
+        text_sent = ''
+        text_error = ''
+        i = 0
+        j = 0
+        invoices = self.pool[data['model']].browse(cr, uid, data['ids'],
+                                                   context)
+        for inv in invoices:
+            to = []
+            name = None
+            if inv.address_invoice_id and inv.address_invoice_id.email:
+                name = (inv.address_invoice_id.name or
+                        inv.address_invoice_id.partner_id.name)
+                to.extend(['"%s" <%s>' % (name, email) for email in
+                           inv.address_invoice_id.email.split(',')])
+                email = ','.join(to)
+            elif inv.address_contact_id and inv.address_contact_id.email:
+                name = (inv.address_contact_id.name or
+                        inv.address_contact_id.partner_id.name)
+                to.extend(['"%s" <%s>' % (name, email) for email in
+                           inv.address_contact_id.email.split(',')])
+                email = ','.join(to)
+            if email:
+                i += 1
+                inv_number = inv.number or '-'
+                inv_name = inv.name or '-'
+                text_sent += (
+                    str(i) + '. ' + _('Invoice Num.: ') + inv_number
+                    + ' // ' + _('Name: ') + inv_name + '\n')
+                text_sent += '\t' + email + '\n\n'
+            else:
+                j += 1
+                inv_number = inv.number or '-'
+                inv_name = inv.name or '-'
+                name = (inv.partner_id.name or inv.address_invoice_id.name or
+                        inv.address_invoice_id.partner_id.name)
+                text_error += (
+                    str(j) + '. ' + _('Invoice Num.: ') + inv_number + ' // '
+                    + _('Name: ') + inv_name + ' // ' + _('Partner: ')
+                    + name + '\n\n')
+        return {'text_sent': text_sent, 'text_error': text_error}
+
+    _columns = {
+        'text_sent': fields.text('Message', readonly=True),
+        'text_error': fields.text('Message', readonly=True),
+        'email_sent': fields.integer('Quantity of Emails sent', readonly=True),
+    }
+
+    def create_csv(self, cr, uid, res_ids, file_name=False):
+        if not res_ids:
+            return (False, Exception('Resources ids are required !!!'))
+        try:
+            ret_file_name = '/tmp/' + file_name + '.csv'
+            invoice_obj = self.pool['account.invoice']
+            csv = invoice_obj.get_phones_csv(cr, uid, res_ids)
+            fp = open(ret_file_name, 'w+')
+            fp.write(csv.encode('utf-8'))
+            fp.close()
+        except Exception, e:
+            print 'Exception in create csv:', e
+            return (False, str(e))
+        return (True, ret_file_name)
+
+    def create_report(self, cr, uid, res_ids, report_name=False,
+                      file_name=False):
+        if not report_name or not res_ids:
+            return (
+                False,
+                Exception(_('Report name and Resources ids are required !!!')))
+        try:
+            ret_file_name = '/tmp/' + file_name + '.pdf'
+            service = netsvc.LocalService("report." + report_name)
+            # TODO no se si esto es correcto
+            (result, format) = service.create(cr, uid, res_ids, {}, {})
+            fp = open(ret_file_name, 'wb+')
+            fp.write(result)
+            fp.close()
+        except Exception, e:
+            print 'Exception in create report:', e
+            return (False, str(e))
+        return (True, ret_file_name)
+
+    def _send_mails(self, cr, uid, data, context):
+        nbr = 0
+        # Verificamos configuracion del servidor SMTP
+        data_obj = self.pool['ir.model.data']
+        mail_obj = self.pool['email.smtpclient']
+        mail_conf_obj = self.pool['email.multiple.account.config']
+        canal_obj = self.pool['res.partner.canal']
+        event_obj = self.pool['res.partner.event']
+        account_smtpserver_id = mail_obj.search(cr, uid, [
+            ('type', '=', 'account'), ('state', '=', 'confirm'),
+            ('active', '=', True)], context=False)
+        if not account_smtpserver_id:
+            default_smtpserver_id = mail_obj.search(cr, uid, [
+                ('type', '=', 'default'), ('state', '=', 'confirm'),
+                ('active', '=', True)], context=False)
+        smtpserver_id = account_smtpserver_id or default_smtpserver_id
+        if smtpserver_id:
+            smtpserver_id = smtpserver_id[0]
         else:
-            j += 1
-            
-            inv_number = inv.number or '-'
-            inv_name = inv.name or '-'
-            name = inv.partner_id.name or inv.address_invoice_id.name or inv.address_invoice_id.partner_id.name
-            
-            text_error += str(j) + '. ' + _('Invoice Num.: ') + inv_number + ' // ' + _('Name: ') + inv_name  + ' // ' + _('Partner: ') + name + '\n\n'
-        
-    return {'text_sent': text_sent, 'text_error': text_error}
-
-
-def create_report(cr, uid, res_ids, report_name=False, file_name=False):
-    if not report_name or not res_ids:
-        return (False, Exception('Report name and Resources ids are required !!!'))
-    try:
-        ret_file_name = '/tmp/' + file_name + '.pdf'
-        service = netsvc.LocalService("report." + report_name)
-        (result, format) = service.create(cr, uid, res_ids, {}, {})
-        fp = open(ret_file_name, 'wb+')
-        fp.write(result)
-        fp.close()
-    except Exception,e:
-        print 'Exception in create report:',e
-        return (False, str(e))
-    return (True, ret_file_name)
-
-
-def create_csv(cr, uid, res_ids, file_name=False):
-    if not res_ids:
-        return (False, Exception('Resources ids are required !!!'))
-    try:
-        ret_file_name = '/tmp/' + file_name + '.csv'
-        invoice_obj = pooler.get_pool(cr.dbname).get('account.invoice')
-        csv = invoice_obj.get_phones_csv(cr, uid, res_ids)
-        fp = open(ret_file_name, 'w+')
-        fp.write(csv.encode('utf-8'))
-        fp.close()
-    except Exception,e:
-        print 'Exception in create csv:', e
-        return (False, str(e))
-    return (True, ret_file_name)
-
-
-def _send_mails(self, cr, uid, data, context):
-    import re
-    p = pooler.get_pool(cr.dbname)
-    user = p.get('res.users').browse(cr, uid, uid, context)
-    nbr = 0
-
-    # Verificamos configuracion del servidor SMTP
-    account_smtpserver_id = p.get('email.smtpclient').search(cr, uid, [('type','=','account'),('state','=','confirm'),('active','=',True)], context=False)
-    if not account_smtpserver_id:
-        default_smtpserver_id = p.get('email.smtpclient').search(cr, uid, [('type','=','default'),('state','=','confirm'),('active','=',True)], context=False)
-        
-    smtpserver_id = account_smtpserver_id or default_smtpserver_id
-    
-    if smtpserver_id:
-        smtpserver_id = smtpserver_id[0]
-    else:
-        raise osv.except_osv(_('Error'), _('No SMTP Server has been defined!'))
-    
-    # Verificamos configuracion de plantilla de correo
-    email_template = p.get('email.multiple.account.config').get_default(cr, uid, context)
-    
-    if not email_template:
-        raise osv.except_osv(_('Error'), _('No Template Email has been defined!'))
-    
-    subject = email_template.subject
-    text = email_template.body
-
-    invoices = p.get(data['model']).browse(cr, uid, data['ids'], context)
-    
-    for inv in invoices:
-        to = []
-        email = None
-        name = None
-
-        if inv.address_invoice_id and inv.address_invoice_id.email:
-            name = inv.address_invoice_id.name or inv.address_invoice_id.partner_id.name
-            to.extend(['"%s" <%s>' % (name, email) for email in inv.address_invoice_id.email.split(',')])
-            email = ','.join(to)
-        elif inv.address_contact_id and inv.address_contact_id.email:
-            name = inv.address_contact_id.name or inv.address_contact_id.partner_id.name
-            to.extend(['"%s" <%s>' % (name, email) for email in inv.address_contact_id.email.split(',')])
-            email = ','.join(to)
-        
-        if email:
-            #subject = user.company_id.name + _('. Invoice Num.: ') + (inv.number or '-')
-            #text = _('Account Invoice Report.') + '\n--\n' + user.signature
-            
-            file_name = inv.number
-
-            # Create report to send as file attachments
-            report = create_report(cr, uid, [inv.id], data['model'] + ".custom", file_name)
-            attachments = report[0] and [report[1]] or []
-
-            # Attach CSV files
-            if inv.partner_id.csv_correo:
-                csv = create_csv(cr, uid, [inv.id], file_name)
-                if csv[0]:
-                    attachments.append(csv[1])
-            
-            #Send mail
-            state = p.get('email.smtpclient').send_email(cr, uid, smtpserver_id, to, subject, text, attachments)
-            if not state:
-                raise osv.except_osv(_('Error sending email'), _('Please check the Server Configuration!'))
-            nbr += 1
-            
-            # Add a partner event
-            docs = p.get(data['model']).browse(cr, uid, [inv.id], context)
-            partner_id = docs[0].partner_id.id
-            c_id = p.get('res.partner.canal').search(cr ,uid, [('name','ilike','EMAIL'),('active','=',True)])
-            c_id = c_id and c_id[0] or False
-            p.get('res.partner.event').create(cr, uid,
-                    {'name': _('Email sent through invoice wizard'),
-                     'partner_id': partner_id,
-                     'description': _('To: ').encode('utf-8') + email +
-                                    _('\n\nSubject: ').encode('utf-8') + subject +
-                                    _('\n\nText:\n').encode('utf-8') + text,
-                     'document': data['model']+','+str(docs[0].id),
-                     'canal_id': c_id,
-                     'user_id': uid, })
-        
-    return {'email_sent': nbr}
-    
-class send_email(wizard.interface):
-    states = {
-        'init': {
-            'actions': [_get_defaults],
-            'result': {'type': 'form', 'arch': email_send_form, 'fields': email_send_fields, 'state':[('end','Cancel'), ('send','Send Email')]}
-        },
-        'send': {
-            'actions': [_send_mails],
-            'result': {'type': 'form', 'arch': email_done_form, 'fields': email_done_fields, 'state': [('end', 'End')] }
-        }
-    }
-
-send_email('account.invoice.multiple_email_send')
+            raise orm.except_orm(_('Error'),
+                                 _('No SMTP Server has been defined!'))
+        # Verificamos configuracion de plantilla de correo
+        email_template = mail_conf_obj.get_default(cr, uid, context)
+        if not email_template:
+            raise orm.except_orm(_('Error'),
+                                 _('No Template Email has been defined!'))
+        subject = email_template.subject
+        text = email_template.body
+        invoices = self.pool[data['model']].browse(cr, uid, data['ids'],
+                                                   context)
+        for inv in invoices:
+            to = []
+            name = None
+            if inv.address_invoice_id and inv.address_invoice_id.email:
+                name = (inv.address_invoice_id.name or
+                        inv.address_invoice_id.partner_id.name)
+                to.extend(['"%s" <%s>' % (name, email) for email in
+                           inv.address_invoice_id.email.split(',')])
+                email = ','.join(to)
+            elif inv.address_contact_id and inv.address_contact_id.email:
+                name = (inv.address_contact_id.name or
+                        inv.address_contact_id.partner_id.name)
+                to.extend(['"%s" <%s>' % (name, email) for email in
+                           inv.address_contact_id.email.split(',')])
+                email = ','.join(to)
+            if email:
+                # subject = user.company_id.name + _('. Invoice Num.: ')
+                # + (inv.number or '-')
+                # text = _('Account Invoice Report.') + '\n--\n'
+                # + user.signature
+                file_name = inv.number
+                # Create report to send as file attachments
+                report = self.create_report(cr, uid, [inv.id],
+                                            data['model'] + ".custom",
+                                            file_name)
+                attachments = report[0] and [report[1]] or []
+                # Attach CSV files
+                if inv.partner_id.csv_correo:
+                    csv = self.create_csv(cr, uid, [inv.id], file_name)
+                    if csv[0]:
+                        attachments.append(csv[1])
+                # Send mail
+                state = mail_obj.send_email(cr, uid, smtpserver_id, to,
+                                            subject, text, attachments)
+                if not state:
+                    raise orm.except_orm(_('Error sending email'),
+                                         _('Please check the Server '
+                                           'Configuration!'))
+                nbr += 1
+                # Add a partner event
+                docs = self.pool[data['model']].browse(cr, uid, [inv.id],
+                                                       context)
+                partner_id = docs[0].partner_id.id
+                c_id = canal_obj.search(cr, uid, [('name', 'ilike', 'EMAIL'),
+                                                  ('active', '=', True)])
+                c_id = c_id and c_id[0] or False
+                event_obj.create(cr, uid, {
+                    'name': _('Email sent through invoice wizard'),
+                    'partner_id': partner_id,
+                    'description': _('To: ').encode('utf-8') + email +
+                    _('\n\nSubject: ').encode('utf-8') + subject +
+                    _('\n\nText:\n').encode('utf-8') + text,
+                    'document': data['model']+','+str(docs[0].id),
+                    'canal_id': c_id,
+                    'user_id': uid, })
+        id2 = data_obj._get_id(cr, uid, 'dos_email_multiple_<ccount',
+                               'email_done_form_view"')
+        if id2:
+            id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+            context['email_sent'] = nbr
+        return {
+            'view_type': 'form',
+            'view_mode': 'form',
+            'res_model': 'wizard.send.email',
+            'views': [(id2, 'form')],
+            'view_id': False,
+            'type': 'ir.actions.act_window',
+            'target': 'new',
+            'context': context
+            }


Follow ups