From ab6882dc3cfb4c941ac96d093ca5c95cf64745f4 Mon Sep 17 00:00:00 2001 From: Quentin De Paoli <> Date: Thu, 24 Jun 2010 16:12:25 +0530 Subject: [PATCH 1/3] [FIX] l10n_be: vat declaration: the tax code 91 can only be send for the declaration of December bzr revid: ach@tinyerp.com-20100624104225-14w73gpdj3j8quoe --- addons/l10n_be/wizard/l10n_be_account_vat_declaration.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py b/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py index a5e664c833a..155e40b256b 100644 --- a/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py +++ b/addons/l10n_be/wizard/l10n_be_account_vat_declaration.py @@ -106,6 +106,9 @@ class l10n_be_vat_declaration(osv.osv_memory): data_of_file +='\n\t\t\n\t\t\t' for item in tax_info: + if item['code'] == '91' and ending_month != 12: + #the tax code 91 can only be send for the declaration of December + continue if item['code']: if item['code'] == '71-72': item['code']='71' From e2a068e03f9a05dbd21cf3602acdadf074775139 Mon Sep 17 00:00:00 2001 From: Dhara Date: Thu, 24 Jun 2010 16:22:26 +0530 Subject: [PATCH 2/3] [FIX] email_tempalte : view and error on email bzr revid: dhara@dhara-laptop-20100624105226-4n11kv5289wnt96p --- addons/email_template/email_template.py | 12 +++-- .../email_template/email_template_account.py | 8 ++-- .../email_template/email_template_mailbox.py | 7 +-- addons/email_template/email_template_view.xml | 44 +++++++++---------- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index 37b38774a7d..9190bd17e2b 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -108,7 +108,8 @@ class email_template(osv.osv): 'enforce_from_account':fields.many2one( 'email_template.account', string="Enforce From Account", - help="Emails will be sent only from this account."), + help="Emails will be sent only from this account(which are approved).", + domain=[('state','=','approved')]), 'from_email' : fields.related('enforce_from_account', 'email_id', type='char', string='From',), 'def_to':fields.char( @@ -580,8 +581,8 @@ class email_template(osv.osv): context) print 'Sending', mailbox_id - self.pool.get('email_template.mailbox').send_this_mail(cursor, user, [mailbox_id], context) return mailbox_id + def generate_mail(self, cursor, @@ -595,6 +596,7 @@ class email_template(osv.osv): if not template: raise Exception("The requested template could not be loaded") print 'loaded', record_ids + result = True for record_id in record_ids: mailbox_id = self._generate_mailbox_item_from_template( cursor, @@ -625,7 +627,9 @@ class email_template(osv.osv): {'folder':'outbox'}, context=context ) - return True + # TODO : manage return value of all the records + result = self.pool.get('email_template.mailbox').send_this_mail(cursor, user, [mailbox_id], context) + return result email_template() @@ -641,7 +645,7 @@ class email_template_preview(osv.osv_memory): if 'template_id' in context.keys(): ref_obj_id = self.pool.get('email.template').read(cr, uid, context['template_id'], ['object_name'], context) ref_obj_name = self.pool.get('ir.model').read(cr, uid, ref_obj_id['object_name'][0], ['model'], context)['model'] - ref_obj_ids = self.pool.get(ref_obj_name).search(cr, uid, [], context=context) + ref_obj_ids = self.pool.get(ref_obj_name).search(cr, uid, [], 0, 20, 'id desc', context=context) ref_obj_recs = self.pool.get(ref_obj_name).name_get(cr, uid, ref_obj_ids, context) return ref_obj_recs diff --git a/addons/email_template/email_template_account.py b/addons/email_template/email_template_account.py index 0bcf3c3d099..52cff384ec4 100644 --- a/addons/email_template/email_template_account.py +++ b/addons/email_template/email_template_account.py @@ -266,7 +266,7 @@ class email_template_account(osv.osv): return result def send_mail(self, cr, uid, ids, addresses, subject='', body=None, payload=None, context=None): - #TODO: Replace all this crap with a single email object + #TODO: Replace all this with a single email object if body is None: body = {} if payload is None: @@ -320,19 +320,20 @@ class email_template_account(osv.osv): msg.attach(part) except Exception, error: logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:MIME Error\nDescription: %s") % (id, error)) - return error + return {'error_msg': "Server Send Error\nDescription: %s"%error} try: #print msg['From'],toadds serv.sendmail(msg['From'], addresses_l['all'], msg.as_string()) except Exception, error: logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:Server Send Error\nDescription: %s") % (id, error)) - return error + return {'error_msg': "Server Send Error\nDescription: %s"%error} #The mail sending is complete serv.close() logger.notifyChannel(_("Email Template"), netsvc.LOG_INFO, _("Mail from Account %s successfully Sent.") % (id)) return True else: logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:Account not approved") % id) + return {'error_msg':"Mail from Account %s failed. Probable Reason:Account not approved"% id} def extracttime(self, time_as_string): """ @@ -394,7 +395,6 @@ class email_template_account(osv.osv): return date_as_date def send_receive(self, cr, uid, ids, context=None): - self.get_mails(cr, uid, ids, context) for id in ids: ctx = context.copy() ctx['filters'] = [('account_id', '=', id)] diff --git a/addons/email_template/email_template_mailbox.py b/addons/email_template/email_template_mailbox.py index fe9ca334d21..b89a9aeda26 100644 --- a/addons/email_template/email_template_mailbox.py +++ b/addons/email_template/email_template_mailbox.py @@ -56,18 +56,19 @@ class email_template_mailbox(osv.osv): values['subject'] or u'', {'text':values.get('body_text', u'') or u'', 'html':values.get('body_html', u'') or u''}, payload=payload, context=context) - if result == True: self.write(cr, uid, id, {'folder':'sent', 'state':'na', 'date_mail':time.strftime("%Y-%m-%d %H:%M:%S")}, context) self.historise(cr, uid, [id], "Email sent successfully", context) else: - self.historise(cr, uid, [id], result, context) + error = result['error_msg'] + self.historise(cr, uid, [id], error, context) + except Exception, error: logger = netsvc.Logger() logger.notifyChannel(_("Power Email"), netsvc.LOG_ERROR, _("Sending of Mail %s failed. Probable Reason:Could not login to server\nError: %s") % (id, error)) self.historise(cr, uid, [id], error, context) self.write(cr, uid, id, {'state':'na'}, context) - return True + return result def historise(self, cr, uid, ids, message='', context=None): for id in ids: diff --git a/addons/email_template/email_template_view.xml b/addons/email_template/email_template_view.xml index 934a7324b07..12a24ca0934 100644 --- a/addons/email_template/email_template_view.xml +++ b/addons/email_template/email_template_view.xml @@ -8,33 +8,29 @@ form
- - - - - - - - - - - - - - - - - - - - - - -