hi anthony,
here is the trace back :
TRACEBACK
1.
2.
3.
4.
5.
6.
Traceback (most recent call last):
File "/host/Downloads/web2py/gluon/restricted.py", line 212, in restricted
exec ccode in environment
File "/host/Downloads/web2py/applications/retail/views/default/bill.html",
line 83, in <module>
NameError: name 'form' is not defined
*an error occured when using return locals()*
for k, v in session.order.items():
if v==0:
del session.order[k]
* return locals() # the diference part*
*work fine*
for k, v in session.order.items():
if v==0:
del session.order[k]
* redirect(URL('order'))** # the diference part*
here is the full function that is work right now:
def bill():
if not session.order:
session.flash=T("Order Now!!!")
redirect(URL('product'))
for k, v in session.order.items():
if v==0:
del session.order[k]
redirect(URL('order'))
import datetime
import uuid
invoice_no=str(datetime.date.today())+'-'+str(uuid.uuid4())
grand_total=sum(db.product(id).unit_price*qty for id, qty in
session.order.items())
* form=SQLFORM.factory(Field('note', 'text')) # form is define after the
logical condition*
if form.accepts(request,session):
for key, value in session.order.items():
db.sale.insert(invoice_no=invoice_no,
product_id=key,
quantity=value,
unit_price=db.product(key).unit_price,
total_price=db.product(key).unit_price*value,
grand_total=grand_total,
note=form.vars.note)
db(db.product.id==key).update(quantity=db.product.quantity -
value)
session.order.clear()
session.flash=T("Thank you for your Order")
redirect(URL('invoice', args=invoice_no))
return dict(order=session.order, form=form, grand_total=grand_total)
i'm just curious where is the diference workflow when deal with del
session. is it better using return locals() or just use redirect when deal
with del session?
many thanks before
--
---
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.