Nice Catch, but I have commented the last field to apply what you suggested
and this also doesn't work:
db.define_table('compra_produto',
    Field('compra', 'reference compra'),
    Field('produto','reference produto'),
    Field('quantidade','integer'),
    Field('custo_em_dolar','double'),
    Field('cotacao_do_dolar','double'),
    Field('custo_em_real', compute=lambda cr:
cr['custo_em_dolar']*cr['valor_do_dolar']),
)

On Wed, Feb 29, 2012 at 6:06 PM, Richard Vézina <ml.richard.vez...@gmail.com
> wrote:

> You can't access valor_do_dolar from custo_em_real lambda computed since
> it is a computed field that get computed un submit... If you want to do
> that you will have to make a real function that get process on submit with
> form.process().accepted and the argument onsuccess or onvalidation
>
> See chapter 7 with both keyword here a link for the first keyword :
>
> http://web2py.com/books/default/chapter/29/7?search=onsuccess
>
> Richard
>
> On Wed, Feb 29, 2012 at 3:51 PM, Tito Garrido <titogarr...@gmail.com>wrote:
>
>> Hi Folks,
>>
>> I am trying a simple example using sqlite:
>>
>> db.define_table('compra_produto',
>>     Field('compra', 'reference compra'),
>>     Field('produto','reference produto'),
>>     Field('quantidade','integer'),
>>     Field('custo_em_dolar','double'),
>>     Field('cotacao_do_dolar','double'),
>>     Field('custo_em_real', compute=lambda cr:
>> cr['custo_em_dolar']*cr['valor_do_dolar']),
>>     Field('valor_total', compute=lambda vt:
>> vt['custo_em_real']*vt['quantidade'])
>>
>> But both computed fields are always set as "None"... I am trying it from
>> administrative database screen...
>>
>> Am I doing anything wrong?
>>
>> --
>>
>> Linux User #387870
>> .........____
>> .... _/_õ|__|
>> ..º[ .-.___.-._| . . . .
>> .__( o)__( o).:_______
>>
>
>


-- 

Linux User #387870
.........____
.... _/_õ|__|
..º[ .-.___.-._| . . . .
.__( o)__( o).:_______

Reply via email to