Hi, I dont work with Web2py on a daily basis but when I need a small
project, I tend to come back to it to do it. I always struggle with
computing/calculating values. This time I have two values, one from a db
and one from a form. I want to calculate both. This is what I have for now:
db.define_table('zona',
Field <http://127.0.0.1:8000/examples/global/vars/Field>('name'),
Field <http://127.0.0.1:8000/examples/global/vars/Field>('discount'))
db.define_table('supplier',
Field <http://127.0.0.1:8000/examples/global/vars/Field>('name'),
Field
<http://127.0.0.1:8000/examples/global/vars/Field>('zona',requires=IS_IN_DB
<http://127.0.0.1:8000/examples/global/vars/IS_IN_DB>(db,'zone.id','%(discount)s')),
Field
<http://127.0.0.1:8000/examples/global/vars/Field>('discount',requires=IS_FLOAT_IN_RANGE
<http://127.0.0.1:8000/examples/global/vars/IS_FLOAT_IN_RANGE>(0,100)))
def product_calc():
form = SQLFORM.factory(
Field('supplier',label='Supplier',requires=IS_IN_DB(db,db.supplier.id,'%(name)s')),
Field('costprice',label='Cost/Price',requires=[IS_FLOAT_IN_RANGE(0,100),IS_NOT_EMPTY()]),
Field('uom',label='SQF or
PC',default='PC',requires=(IS_IN_SET(UOM_SET))))
suplidor = db().select(db.supplier.id,db.supplier.discount)
thisrec = db.supplier(request.args)
if form.process().accepted:
response.flash = 'form accepted'
session.supplier = form.vars.supplier
session.costprice = form.vars.costprice
session.descuento = db.supplier.discount
if session.supplier == "1":
preciofinal=session.costprice * session.descuento
redirect(URL('resultado'))
elif form.errors:
response.flash = 'form has errors'
return dict()
def resultado():
return dict()
I highlighted what I just dont seem to get. On a side note, I tend to
always go to the manual for anything but I always find that there is no
answer to my questions when it comes to calculating values. Everything that
is presenting data is in the manual. Thanks in advance
--
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/d/optout.