From 496a5803352815afc858b969005e513131f4f092 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Thu, 14 Feb 2013 18:31:56 +0100 Subject: [PATCH] [IMP] let the code breathe bzr revid: abo@openerp.com-20130214173156-e2o3ovrg6t8et90g --- addons/account/account_invoice.py | 6 ++++++ addons/auth_signup/res_users.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index ddca98bc3b7..fe10e10f7b4 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -564,22 +564,27 @@ class account_invoice(osv.osv): obj_journal = self.pool.get('account.journal') account_obj = self.pool.get('account.account') inv_line_obj = self.pool.get('account.invoice.line') + if company_id and part_id and type: acc_id = False partner_obj = self.pool.get('res.partner').browse(cr,uid,part_id) + if partner_obj.property_account_payable and partner_obj.property_account_receivable: if partner_obj.property_account_payable.company_id.id != company_id and partner_obj.property_account_receivable.company_id.id != company_id: property_obj = self.pool.get('ir.property') rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('res_id','=','res.partner,'+str(part_id)+''),('company_id','=',company_id)]) + if not rec_pro_id: rec_pro_id = property_obj.search(cr, uid, [('name','=','property_account_receivable'),('company_id','=',company_id)]) if not pay_pro_id: pay_pro_id = property_obj.search(cr, uid, [('name','=','property_account_payable'),('company_id','=',company_id)]) + rec_line_data = property_obj.read(cr, uid, rec_pro_id, ['name','value_reference','res_id']) pay_line_data = property_obj.read(cr, uid, pay_pro_id, ['name','value_reference','res_id']) rec_res_id = rec_line_data and rec_line_data[0].get('value_reference',False) and int(rec_line_data[0]['value_reference'].split(',')[1]) or False pay_res_id = pay_line_data and pay_line_data[0].get('value_reference',False) and int(pay_line_data[0]['value_reference'].split(',')[1]) or False + if not rec_res_id and not pay_res_id: raise osv.except_osv(_('Configuration Error!'), _('Cannot find a chart of account, you should create one from Settings\Configuration\Accounting menu.')) @@ -587,6 +592,7 @@ class account_invoice(osv.osv): acc_id = rec_res_id else: acc_id = pay_res_id + val= {'account_id': acc_id} if ids: if company_id: diff --git a/addons/auth_signup/res_users.py b/addons/auth_signup/res_users.py index 9718897ef82..077a0feded9 100644 --- a/addons/auth_signup/res_users.py +++ b/addons/auth_signup/res_users.py @@ -260,11 +260,13 @@ class res_users(osv.Model): template = self.pool.get('ir.model.data').get_object(cr, uid, 'auth_signup', 'reset_password_email') mail_obj = self.pool.get('mail.mail') assert template._name == 'email.template' + for user in self.browse(cr, uid, ids, context): if not user.email: raise osv.except_osv(_("Cannot send email: user has no email address."), user.name) mail_id = self.pool.get('email.template').send_mail(cr, uid, template.id, user.id, True, context=context) mail_state = mail_obj.read(cr, uid, mail_id, ['state'], context=context) + if mail_state and mail_state['state'] == 'exception': raise osv.except_osv(_("Cannot send email: no outgoing email server configured.\nYou can configure it under Settings/General Settings."), user.name) else: