[MERGE, IMP] merge with mma branch and small improvement

bzr revid: psi@tinyerp.com-20120816071452-5gl39inc3lwkh4wl
This commit is contained in:
Purnendu Singh (OpenERP) 2012-08-16 12:44:52 +05:30
commit 05609f24ff
1 changed files with 9 additions and 8 deletions

View File

@ -102,9 +102,9 @@ class hr_expense_expense(osv.osv):
def onchange_currency_id(self, cr, uid, ids, currency_id=False, company_id=False, context=None):
res = {'value': {'journal_id': False}}
journal = self.pool.get('account.journal').search(cr, uid, [('type','=','purchase'), ('currency','=',currency_id), ('company_id', '=', company_id)], context=context)
if journal:
res['value']['journal_id'] = journal[0]
journal_ids = self.pool.get('account.journal').search(cr, uid, [('type','=','purchase'), ('currency','=',currency_id), ('company_id', '=', company_id)], context=context)
if journal_ids:
res['value']['journal_id'] = journal_ids[0]
return res
def onchange_employee_id(self, cr, uid, ids, employee_id, context=None):
@ -168,11 +168,12 @@ class hr_expense_expense(osv.osv):
acc = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category', context={'force_company': company_id})
if not acc:
raise osv.except_osv(_('Error!'), _('Please configure Default Expense account for Product purchase: `property_account_expense_categ`.'))
total_amount = 0.0
if journal.currency and exp.currency_id.id != journal.currency.id:
total_amount = currency_obj.compute(cr, uid, exp.currency_id.id, journal.currency.id, line.total_amount, context=ctx)
else:
total_amount = line.total_amount
total_amount = line.total_amount
if journal.currency:
if exp.currency_id != journal.currency:
total_amount = currency_obj.compute(cr, uid, exp.currency_id.id, journal.currency.id, total_amount, context=ctx)
elif exp.currency_id != exp.company_id.currency_id:
total_amount = currency_obj.compute(cr, uid, exp.currency_id.id, exp.company_id.currency_id.id, total_amount, context=ctx)
lines.append((0, False, {
'name': line.name,
'account_id': acc.id,