db.order_detail.total.compute=lambda r: r['qtd']*r['price']
On Jan 14, 8:51 am, Alexandre Andrade <alexandrema...@gmail.com>
wrote:
--
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
--
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
On Jan 14, 9:47 am, Alexandre Andrade <alexandrema...@gmail.com>
wrote:
> db.order_detail.total.compute=lambda r: r['qtd']*r['price']
>
> don't work on updates
>
> 2010/1/14 mdipierro <mdipie...@cs.depaul.edu>
> > web2py+un...@googlegroups.com<web2py%2Bunsu...@googlegroups.com>
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
I will test it again later today and, if it is a bug, release a fix by
tonight.
Massimo
On Jan 14, 10:04 am, Alexandre Andrade <alexandrema...@gmail.com>
wrote:
> still don't work. The value before still mantains.
>
> Maybe I have to drop the column and create it again?
>
> 2010/1/14 mdipierro <mdipie...@cs.depaul.edu>
> > <web2py%2Bunsu...@googlegroups.com<web2py%252Buns...@googlegroups.com>
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
When you submit a form, what you see is what should go in the DB, even
if some fields are readonly.
If you have quantity, price and total you should not display the same
total that is in DB before submission as readonly, because has you
change quantity or price the total should change but it does not. To a
user this is confusing. To the user it looks like they submit a form
with the wrong total (the previous one, not the one reflacing the
change in the other fields).
You should not use compute.
You should use JS
<script>
jQuery("input[name='quantity'],input[name='price']").change(function()
{
jQuery("input[name='total']").val(parseFloat(jQuery("input
[name='price']").val())*parseInt(jQuery("input[name='quantity']"));
});
</script>
when use a custom validator to make sure the user did not mess up this
field somehow.
there are many options.
On Jan 14, 12:57 pm, Alexandre Andrade <alexandrema...@gmail.com>
wrote:
> It don't show at form, without readable=False.
>
> I set readable=False, but it don't show the updated value.
>
> 2010/1/14 mdipierro <mdipie...@cs.depaul.edu>
> > <web2py%2Bunsu...@googlegroups.com<web2py%252Buns...@googlegroups.com>
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
jQuery("input[name='quantity'],input[name='price']").keyup(function()
{
jQuery("input[name='total']").val(parseFloat(jQuery("input
[name='price']").val())*parseInt(jQuery("input[name='quantity']"));
});
Use firebug in to debug the JS. compute should not be used if the
field is shown.
On Jan 14, 2:18 pm, Alexandre Andrade <alexandrema...@gmail.com>
wrote:
> 1. The total is not showed when editing. I don't need in this moment. When I
> set .compute, its hide (like writable=False and readable=False) the field in
> the form.
> 2. the main problem is .compute is not inserting/updating the field on db,
> and neither acting as represent when showing
>
> 2010/1/14 mdipierro <mdipie...@cs.depaul.edu>
> > > > <web2py%2Bunsu...@googlegroups.com<web2py%252Buns...@googlegroups.com>
> > <web2py%252Buns...@googlegroups.com<web2py%25252Bun...@googlegroups.com>
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
if form.accepts(request.vars, session,
onvalidation=lambda form: form.vars.valor_total =
form.vars.valor_custeio_concedente +
form.vars.valor_investimento_concedente +
form.vars.valor_custeio_contrapartida +
form.vars.valor_investimento_contrapartida):
which is 2 db queries less.
On Jan 14, 2:42 pm, Alexandre Andrade <alexandrema...@gmail.com>
wrote:
> Solved without jquery
>
> if form.accepts(request.vars, session):
> row = db.cronograma_desembolso[form.vars.id]
> total = row.valor_custeio_concedente +
> row.valor_investimento_concedente + row.valor_custeio_contrapartida +
> row.valor_investimento_contrapartida
> row.update_record(valor_total = total)
>
> 2010/1/14 mdipierro <mdipie...@cs.depaul.edu>
> > > > > > <web2py%2Bunsu...@googlegroups.com<web2py%252Buns...@googlegroups.com>
> > <web2py%252Buns...@googlegroups.com<web2py%25252Bun...@googlegroups.com>
>
> > > > <web2py%252Buns...@googlegroups.com<web2py%25252Bun...@googlegroups.com>
> > <web2py%25252Bun...@googlegroups.com<web2py%2525252Bu...@googlegroups.com>
1. | Traceback (most recent call last): |
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.