hi, i'm using sum for the query and it return an error : Traceback
1. 2. 3. 4. 5. 6. Traceback (most recent call last): File "C:\Users\sugizo\Desktop\web2py\web2py\gluon\restricted.py", line 217, in restricted exec ccode in environment File "C:\Users\sugizo\Desktop\web2py\web2py\applications\citifone\views\report/report_product.html", line 129, in <module> AttributeError: 'str' object has no attribute 'first' and if i'm not use first it return an error too : Traceback 1. 2. 3. 4. 5. 6. Traceback (most recent call last): File "C:\Users\sugizo\Desktop\web2py\web2py\gluon\restricted.py", line 217, in restricted exec ccode in environment File "C:\Users\sugizo\Desktop\web2py\web2py\applications\citifone\views\report/report_product.html", line 129, in <module> TypeError: string indices must be integers, not Expression i've checked on the book that sum is using first() for query select my code are : {{query_purchase = (db.purchase_header.purchase_date >= from_date) & (db.purchase_header.purchase_date <= to_date)}} {{query_sale = (db.sale_header.sale_date >= from_date) & (db.sale_header.sale_date <= to_date)}} {{purchase_result = 0}} {{sale_result = 0}} {{for row_product in db(db.product).select():}} {{for row_purchase_header in db(query_purchase).select():}} {{for row_purchase_detail in db(db.purchase_detail.purchase_no == row_purchase_header.id).select():}} {{sum_quantity_purchase = db.purchase_detail.quantity.sum()}} {{query_purchase_detail = (row_purchase_detail.product == db.product.id)}} {{purchase_result = db(query_purchase_detail)._select(sum_quantity_purchase).first()[sum_quantity_purchase] if db(query_purchase_detail).select() else 0}} {{for row_sale_header in db(query_sale).select():}} {{for row_sale_detail in db(db.sale_detail.sale_no == row_sale_header.id).select():}} {{sum_quantity_sale = db.sale_detail.quantity.sum()}} {{query_sale_detail = (row_sale_detail.product == db.product.id)}} {{sale_result = db(query_sale_detail)._select(sum_quantity_sale).first()[sum_quantity_sale] if db(query_sale_detail).select() else 0}} <tr> <td>{{=DIV(row_product.code)}} </td> <td>{{=DIV(row_product.name)}} </td> <td>{{=DIV(row_product.base_unit)}} </td> <td>{{=DIV(row_product.quantity + sale_result - purchase_result)}} </td> <td>{{=DIV(purchase_result)}} </td> <td>{{=DIV(sale_result)}} </td> <td>{{=DIV(row_product.quantity)}} </td> </tr> {{pass}} {{pass}} {{pass}} {{pass}} {{pass}} is there any way to achieve it? thanks and best regards, stifan -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.