the ondelete doesn't receive a single record: it receives the set that is
going to be deleted (remember, one can drop a whole bunch of rows with a
single delete())
i.e. when you fire db(cond).delete(), cond is passed.
If I understand what you're trying to do, you need to fetch the
corresponding receipt_order and update the purchase_order accordingly.....
this should work fine (untested)
def __ondelete_receipt_order(s):
receipt_order = db(s).select()
db(db.purchase_order_header.id ==
receipt_order.purchase_order_no).update(status='blablabla')
On Saturday, September 14, 2013 1:19:38 PM UTC+2, 黄祥 wrote:
>
> hi,
>
> i have a code :
> e.g.
> # ondelete_receipt_order
> def __ondelete_receipt_order(receipt_order):
> db(db.purchase_order_header.id==receipt_order.purchase_order_no).update(status='Purchase
>
> Order Authorized')
>
> # receipt_order_header
> db.receipt_order_header._before_delete.append(lambda s:
> __ondelete_receipt_order(s.select()[0], True) )
> ''' for test
> db.receipt_order_header._before_delete.append(lambda s:
> __ondelete_receipt_order(s.select()[0]) )
> '''
>
> i'm trying above code but the purchase_order_header table is not updated
> when i delete the receipt_order_header (no errors occured, just
> the purchase_order_header table is not updated).
> is there a way how to update the other table using _before_delete callback
> function?
>
> thanks and 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/groups/opt_out.