Sorry, if you want to include a computed field in a SQLFORM, you must
explicitly pass in the "fields" argument listing all the fields you want to
include (if you want to include all fields in the table, including computed
fields, just do fields=legacy_db.ordinipo.fields).
Note, for create forms, there will be no value to display yet in the
"total" field, so to avoid having "None" displayed there, you might need to
specify a "represent" attribute to display an alternative value (such as an
empty string or "N/A"):
Field('total', compute=lambda r: float(r['preco'] * r['quantidade']),
represent=lambda v, r: '' if v is None else v)
Anthony
On Saturday, May 30, 2015 at 6:33:34 AM UTC-4, goome wrote:
>
>
>
> Il giorno venerdì 29 maggio 2015 23:33:50 UTC+2, Anthony ha scritto:
>>
>> "writable", not "readable".
>>
> Thank for you help Anthony.
> I don't want the user should fill the field in the form, as ùits values is
> computed, i just want they see the computed value.
> In any case, even putting
> legacy_db.ordinipo.total.writable=True
> the field is not shown in the sqlform generated form
>
> On Friday, May 29, 2015 at 5:11:39 PM UTC-4, goome wrote:
>>
>>
>>
>> Il giorno venerdì 29 maggio 2015 21:40:27 UTC+2, Anthony ha scritto:
>>>
>>> You need to set the "writable" attribute to True for forms.
>>
>>
>> i put
>> legacy_db.ordinipo.total.readable = True
>> in the model (db.py).
>> Should i put it ont the form too? In this case, how?
>> Thanks
>>
>
--
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.