From aba97f892a5e3a699c3074b402445af5d68724c3 Mon Sep 17 00:00:00 2001 From: "pso (OpenERP)" Date: Mon, 25 Apr 2011 17:40:48 +0530 Subject: [FIX] analytic_user_function: Fixed KeyError ('amount') lp bug: https://launchpad.net/bugs/768968 fixed bzr revid: pso@tinyerp.com-20110425121048-rbur3dny3ou88tpf --- addons/analytic_user_function/analytic_user_function.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'addons/analytic_user_function/analytic_user_function.py') diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index 04f66fb8daa..79f3a17fdbc 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -66,7 +66,7 @@ class hr_analytic_timesheet(osv.osv): return False - def on_change_account_id(self, cr, uid, ids, account_id, user_id=False, unit_amount=0): + def on_change_account_id(self, cr, uid, ids, account_id, user_id=False, unit_amount=0.0): res = {} if not (account_id): #avoid a useless call to super @@ -98,11 +98,11 @@ class hr_analytic_timesheet(osv.osv): 'for this product: "%s" (id:%d)') % \ (r.product_id.name, r.product_id.id,)) # Compute based on pricetype - amount_unit = self.on_change_unit_amount(cr, uid, ids, - r.product_id.id, unit_amount, False, r.product_id.uom_id.id)['value']['amount'] - - amount = unit_amount * amount_unit - res ['value']['amount']= - round(amount, 2) + if unit_amount: + amount_unit = self.on_change_unit_amount(cr, uid, ids, + r.product_id.id, unit_amount, False, r.product_id.uom_id.id)['value']['amount'] + amount = unit_amount * amount_unit + res ['value']['amount']= - round(amount, 2) res ['value']['general_account_id']= a return res -- cgit v1.2.3