hi, i have a database callback when using bulk_insert it return an error :
db(db.product.id == f.product).update(quantity = db.product(f.product).quantity + f.quantity) AttributeError: 'list' object has no attribute 'product' here is the code that produce error above: *# error traceback* *models/db.py* def __after_insert_purchase_order_detail(f, id): db(db.product.id == f.product).update(quantity = db.product(f.product).quantity + f.quantity) # callbacks db.purchase_order_detail._after_insert.append(__after_insert_purchase_order_detail) *controllers/install.py* # purchase_order_detail db.purchase_order_detail.bulk_insert([{"purchase_order_no" : 1, "product" : 1, "quantity" : 1, "price" : 10000, "amount" : 10000, "total" : 20000}, {"purchase_order_no" : 1, "product" : 2, "quantity" : 1, "price" : 10000, "amount" : 10000, "total" : 20000}, ]) i run several test that is work are : *# callback work when using insert not bulk_insert* *models/db.py* def __after_insert_purchase_order_detail(f, id): db(db.product.id == f.product).update(quantity = db.product(f.product).quantity + f.quantity) # callbacks db.purchase_order_detail._after_insert.append(__after_insert_purchase_order_detail) *controllers/install.py* # purchase_order_detail db.purchase_order_detail.insert(purchase_order_no = 1, product = 1, quantity= 1, price = 10000, amount = 10000, total = 10000 ) *#using bulk_insert is work when i put the condition on callback* *models/db.py* def __after_insert_purchase_order_detail(f, id): db(db.product.id == f.product).update(quantity = db.product(f.product).quantity + f.quantity) if not request.controller == 'install': # callbacks purchase_order_detail._after_insert.append(__after_insert_purchase_order_detail) *controllers/install.py* # purchase_order_detail db.purchase_order_detail.bulk_insert([{"purchase_order_no" : 1, "product" : 1, "quantity" : 1, "price" : 10000, "amount" : 10000, "total" : 20000}, {"purchase_order_no" : 1, "product" : 2, "quantity" : 1, "price" : 10000, "amount" : 10000, "total" : 20000}, ]) my question is why the callback is not work when i use bulk_insert? 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/d/optout.