I suppose use either an onaccept callback with the SQLFORM, or set up
_after_insert and _after_update callbacks on the db.item_batch table (those
will run any time db.item_batch is changed, even if not via a form).
Anthony
On Friday, June 28, 2013 1:41:05 PM UTC-4, Cliff Kachinske wrote:
>
> I have two tables something like this:
>
> db.define_table('item',
> Field('name'),
> Field('on_hand', integer),
> )
>
> db.define_table('item_batch',
> Field('item', 'reference db.item' ...),
> Field('batch_yield', integer),
> )
>
> Every time I insert a item_batch record, I increment the on_hand field of
> the item table by the quantity in tatch_yield. Easy to do using SQLFORM.
>
> But if I have to update the batch_yield I want to update the item.on_hand
> field as well. I also use an onvalidation function to make sanity checks
> on the updated batch_yield entry, such as verifying that the new value does
> not make item.on_hand a negative number.
>
> Using SQLFORM, when is the best time to update the item.on_hand field?
>
> I want to make sure all of the updates are in the same transaction, so
> that if one fails, they all get rolled back. How can I do this?
>
> Thanks,
> Cliff Kachinske
>
--
---
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.