← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 692698] Re: [6.0] purchase analysis - division by zero

 

[2010-12-21 08:08:09,472][test_1220] ERROR:db.cursor:bad query: SELECT min(purchase_report.id) AS id, count(purchase_report.id) AS  __count, sum(nbr) as nbr,sum(delay_pass) as delay_pass,sum(price_standard) as price_standard,sum(delay) as delay,avg(price_average) as price_average,avg(negociation) as negociation,sum(price_total) as price_total,sum(quantity) as quantity FROM "purchase_report"
Traceback (most recent call last):
  File "/home2/gass/OpenERP/trunk/openobject-server/bin/sql_db.py", line 129, in execute
    res = self._obj.execute(query, params)
DataError: division by zero

the problem comes from the purchase_report

                    (l.price_unit*l.product_qty*u.factor)::decimal(16,2) as price_total,
                    avg(100.0 * (l.price_unit*l.product_qty*u.factor) / (t.standard_price*l.product_qty*u.factor))::decimal(16,2) as negociation,
                    sum(t.standard_price*l.product_qty*u.factor)::decimal(16,2) as price_standard,
                    (sum(l.product_qty*l.price_unit)/sum(l.product_qty*u.factor))::decimal(16,2) as price_average

the client has products without standard_price

IMHO  decimal should be replaced by compute digits  in field definition
to be consistent

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/692698

Title:
  [6.0] purchase analysis - division by zero

Status in OpenObject Addons Modules:
  Incomplete

Bug description:
  in po lines qty and price_unit are all > 0 

Environment Information : 
System : Linux-2.6.34.7-0.5-desktop-x86_64-with-SuSE-11.3-x86_64
OS Name : posix
LSB Version:	core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-x86_64:core-3.2-x86_64:core-4.0-x86_64:desktop-4.0-amd64:desktop-4.0-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.2-amd64:graphics-3.2-noarch:graphics-4.0-amd64:graphics-4.0-noarch
Distributor ID:	SUSE LINUX
Description:	openSUSE 11.3 (x86_64)
Release:	11.3
Codename:	n/a
Operating System Release : 2.6.34.7-0.5-desktop
Operating System Version : #1 SMP PREEMPT 2010-10-25 08:40:12 +0200
Operating System Architecture : 64bit
Operating System Locale : en_US.UTF8
Python Version : 2.6.5
OpenERP-Client Version : 6.0.0-rc1-1
Last revision No. & ID :1726 launchpad_translations_on_behalf_of_openerp-20101220044941-n5qjgeqp6s98002l
Traceback (most recent call last):
  File "/home2/gass/OpenERP/trunk/openobject-server/bin/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/home2/gass/OpenERP/trunk/openobject-server/bin/service/web_services.py", line 598, in dispatch
    res = fn(db, uid, *params)
  File "/home2/gass/OpenERP/trunk/openobject-server/bin/osv/osv.py", line 122, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home2/gass/OpenERP/trunk/openobject-server/bin/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home2/gass/OpenERP/trunk/openobject-server/bin/osv/osv.py", line 167, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home2/gass/OpenERP/trunk/openobject-server/bin/osv/orm.py", line 2325, in read_group
    cr.execute('SELECT min(%s.id) AS id, count(%s.id) AS  %s_count, ' % (self._table, self._table, group_count) + flist + ' FROM ' + from_clause + where_clause + gb + limit_str + offset_str, where_clause_params)
  File "/home2/gass/OpenERP/trunk/openobject-server/bin/sql_db.py", line 76, in wrapper
    return f(self, *args, **kwargs)
  File "/home2/gass/OpenERP/trunk/openobject-server/bin/sql_db.py", line 129, in execute
    res = self._obj.execute(query, params)
DataError: division by zero





References