Hello.
I have two models: "order (fields: id,cost)" and "order_item (fields: id,
order, price, quantity)".
"order_item.order" looks like:
Field('order', db.order)
i'll try to add "total_price" field to "order" table:
Field('total_price', 'integer' ,compute=lambda row: calc(row))
where "calc(row)" looks like:
def calc(order):
result = 0
for item in order.order_item.select()
result += item.price
return result
But this code doesn't work. Completely - there are no any errors and log
messages.
I found that invocation of "order.order_item" stops execution of "calc"
function.
It looks like back referenced fields are not available during "compute"
invocation...
Any ideas ?
P.S. I don't want to use virtual fields because them slow down object list
rendering (each virtual field invocation makes new query to db)