I think there is a problem in field type in Days because the default is a
string so days have a string value, you are multiplying string with an
integer in the computed field.
# 1
db.define_table('ClientDetails',
Field('CheckIn', 'date', label=SPAN('Check-In Date',
_style="font-weight:
bold;")),
Field('CheckOut', 'date', label=SPAN('Check-Out Date',
_style="font-weight: bold;")),
Field('Days', compute=lambda r: (r['CheckOut']-r['CheckIn'
]).days),
Field('Amount', compute=lambda r: int(r['Days'])*int(r[
'Number_of_Guests'])*650))
# 2
db.define_table('ClientDetails',
Field('CheckIn', 'date', label=SPAN('Check-In Date',
_style="font-weight:
bold;")),
Field('CheckOut', 'date', label=SPAN('Check-Out Date',
_style="font-weight: bold;")),
Field('Days', compute=lambda r: (r['CheckOut']-r['CheckIn'
]).days),
Field('Amount', compute=lambda r: ((r['CheckOut']-r[
'CheckIn']).days)*int(r['Number_of_Guests'])*650))
Let me know this will work for you.
Thanks
SP
On Fri, Oct 26, 2018 at 10:27 AM mostwanted <[email protected]> wrote:
> With this one there was no error traceback, the form just failed to submit
> showed a message that read *Error in form, please check it out *and i do
> have a field Number_of_Guests i just didnt include it coz i thought i was
> minimizing the whole code to show what could the root cause of the problem.
> When i remove the *Days *and* Amount *fields I am able to update the form
> but when put them back it gives an error!
>
> On Friday, October 26, 2018 at 12:13:55 AM UTC+2, 黄祥 wrote:
>>
>> pls show the error traceback, it's hard to know what the root cause.
>> just a quick analyze (guess), perhaps it's no Number_of_Guests field in
>> your table definition, so it can't be calculated
>>
>> 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/d/optout.
>
--
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.