sorry, my bad. The Set is indeed not a Query ...

def __ondelete_receipt_order(s):
    receipt_order = s.select().first()
    
db(db.purchase_order_header.id==receipt_order.purchase_order_no).update(status='Purchase
 
Order Authorized')

db.receipt_order_header._before_delete.append(__ondelete_receipt_order)

On Sunday, September 15, 2013 12:46:27 AM UTC+2, 黄祥 wrote:
>
> yeah, my goal is when i delete receipt order it will update the purchase 
> order status.
> i've followed your suggestion, but still not update the status of purchase 
> order when i delete the receipt order (no error occured, just not update 
> the purchase order).
>
> def __ondelete_receipt_order(s):
> receipt_order=db(s).select()
> # for test # receipt_order=db(s).select().first()
> db(db.purchase_order_header.id==receipt_order.purchase_order_no).update(status='Purchase
>  
> Order Authorized')
>
> db.receipt_order_header._before_delete.append(lambda s: 
> __ondelete_receipt_order(s.select()[0]) )
>
> and here is the table field :
> db.define_table('purchase_order_header', 
>     Field('purchase_order_no'), 
> Field('purchase_order_date', 'date', notnull=True),
>     Field('supplier', 'reference supplier', notnull=True), 
>     Field('payment_type', 'reference payment_type', notnull=True), 
>     Field('is_delivery', 'boolean'),
>     Field('notes', 'text'),
>     Field('is_authorized', 'boolean'),
>     Field('status', notnull=True),
>     Field('grand_total', 'decimal(10,2)'), 
>     format='%(purchase_order_no)s')
>
> db.define_table('receipt_order_header', 
>     Field('receipt_order_no'), 
> Field('receipt_order_date', 'date', notnull=True),
>     Field('purchase_order_no', 'reference purchase_order_header', 
> notnull=True), 
>     Field('supplier', 'reference supplier', notnull=True), 
>     Field('payment_type', 'reference payment_type', notnull=True), 
>     Field('notes', 'text'),
>     Field('is_authorized', 'boolean'),
>     Field('status', notnull=True),
>     format='%(receipt_order_no)s')
>
> any other idea how to accomplished this?
>
> 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.

Reply via email to