[IMP] web_preload js part
[odoo/odoo.git] / addons / analytic_user_function / analytic_user_function.py
old mode 100755 (executable)
new mode 100644 (file)
index 04f66fb..ca3e9ef
@@ -20,7 +20,6 @@
 ##############################################################################
 
 from osv import fields,osv
-from osv import orm
 from tools.translate import _
 
 class analytic_user_funct_grid(osv.osv):
@@ -98,11 +97,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
 
@@ -133,11 +132,12 @@ 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']
+                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)
+                    amount = unit_amount * amount_unit
+                    res ['value']['amount']= - round(amount, 2)
                 res ['value']['general_account_id']= a
         return res