yes, you are right, i know where is the root cause, btw, it's funny the
length of db(db.rent_detail.id.belongs(ids)) is return 0, yet i still can
insert the value to other table.
e.g.
def outstanding_rent():
grid = SQLFORM.grid(db.rent_detail.status == 'Rent',
selectable = lambda ids : redirect(URL('checkout', vars = dict(ids = ids) )
) )
return locals()
def checkout():
ids = request.vars.ids
return dict(ids = ids)
def compensation():
ids = request.vars.ids
#grand_total = sum(item.dvd.acquisition_price * item.quantity for item in
db(db.rent_detail.id.belongs(ids) ).select(db.rent_detail.dvd,
db.rent_detail.quantity) ) ## result 0
#grand_total = sum(2 * 2 for item in db(db.rent_detail.id.belongs(ids)
).select(db.rent_detail.dvd, db.rent_detail.quantity) ) ## result 0
grand_total = len(db(db.rent_detail.id.belongs(ids) ).select() ) ## result 0
db.compensation_header.insert(grand_total = grand_total)
for id in ids:
detail = db(db.rent_detail.id == id).select().first()
dvd = db(db.dvd.id == detail.dvd).select().first()
db.compensation_detail.insert(rent_no = detail.rent_no,
customer = detail.customer,
dvd = detail.dvd,
quantity = detail.quantity,
price = dvd.acquisition_price,
grand_total = grand_total)
redirect(URL('report', 'report_compensation') )
in code above the grand_total result is 0 (base on print length of
db(db.rent_detail.id.belongs(ids)), but i still can insert the
compensation_detail table with the correct value got from rent_detail value.
i'm not sure where my error on code above, because no traceback occured.
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.