From f01f6e072c9fc169f82fd2fd4ee4f59c1cc22763 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 27 Mar 2013 11:15:49 +0100 Subject: [PATCH] [FIX] hr_expense: raised errors when an account is missing for the accounting entries generation bzr revid: qdp-launchpad@openerp.com-20130327101549-jefamzxljupbrte9 --- addons/hr_expense/hr_expense.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index cf6f14b2fc0..0c3421ddd72 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -231,6 +231,8 @@ class hr_expense_expense(osv.osv): for exp in self.browse(cr, uid, ids, context=context): if not exp.employee_id.address_home_id: raise osv.except_osv(_('Error!'), _('The employee must have a home address.')) + if not exp.employee_id.address_home_id.property_account_payable.id: + raise osv.except_osv(_('Error!'), _('The employee must have a payable account set on his home address.')) company_currency = exp.company_id.currency_id.id diff_currency_p = exp.currency_id.id <> company_currency @@ -336,6 +338,8 @@ class hr_expense_expense(osv.osv): acc = line.product_id.property_account_expense if not acc: acc = line.product_id.categ_id.property_account_expense_categ + if not acc: + raise osv.except_osv(_('Error!'), _('No purchase account found for the product %s (or for his category), please configure one.') % (line.product_id.name)) else: acc = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category', context={'force_company': company.id}) if not acc: