done
https://github.com/web2py/web2py/issues/1101

thanks and best regards,
stifan

On Wednesday, November 11, 2015 at 9:59:12 PM UTC+7, Massimo Di Pierro 
wrote:
>
> I see the problem, the computed field is computed by the insert function 
> while f in the _after_insert_delivery_order are the record parameters as 
> passed to the insert function (before the field is computed). So I'd say 
> this is not supposed to work. Open a ticket with your code and we will 
> consider the improvement.
>
> On Thursday, 5 November 2015 05:13:46 UTC-6, 黄祥 wrote:
>>
>> compute field not work when using after insert callback too.
>> e.g. 
>> def __after_insert_delivery_order(f, id):
>> db(db.customer.id == f.customer).update(last_delivery_order_net = 
>> f.gross - f.tarra) # work
>> #db(db.customer.id == f.customer).update(last_delivery_order_net = f.net) 
>> # not work
>>
>> def on_define_delivery_order(table): 
>> table._after_insert.append(__after_insert_delivery_order)
>> table.net.compute = lambda r: r['gross'] - r['tarra']
>>
>> db.define_table('delivery_order', 
>> Field('delivery_order_no'), 
>> Field('customer', 'reference customer'), 
>> Field('tarra', 'integer'),
>> Field('gross', 'integer'),
>> Field('net', 'integer'),
>> on_define = on_define_delivery_order, 
>> format = '%(delivery_order_no)s')
>>
>> not sure is it bug, or normal behaviour.
>>
>> 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.

Reply via email to