Thanks for the input everyone , I did get it to successfully update using 
the following 

def create_stock_task():
    form = SQLFORM (db.stock_task).process()
    if form.accepted:
        task = db(db.stock_task.id).select().last()
        pdays_row = db(db.product.withholding_period>0).select().last()
        pdays =  pdays_row.withholding_period
        esidays_row = db(db.product.ESI_withholding>0).select().last()
        esidays = esidays_row.ESI_withholding
        wdate_row = db(db.stock_task.completed_date>0).select().last()
        wdate = wdate_row.completed_date
        fdate = wdate + datetime.timedelta(days + pdays)
        esidate = wdate + datetime.timedelta(days + esidays)
        db(db.stock_task.id == task).update(withhold_until_date=fdate)
        db(db.stock_task.id == task).update(ESI_withhold_until_date=esidate)

On Wednesday, 28 October 2015 18:00:05 UTC+11, Anthony Smith wrote:
>
> added the following
>
> def create_stock_task():
>     form = SQLFORM (db.stock_task).process()
>     if form.accepted:
>         task = db(db.stock_task.id).select().first()
>         pdays_row = db(db.product.withholding_period>0).select().first()
>         pdays =  pdays_row.withholding_period
>         wdate_row = db(db.stock_task.completed_date>0).select().first()
>         wdate = wdate_row.completed_date
>         fdate = wdate + datetime.timedelta(days + pdays)
>         ndate_row = 
> db(db.stock_task.withhold_until_date>0).select().first()
>         ndate = ndate_row.withhold_until_date
>         db(db.stock_task.id == task).update(ndate=fdate)
>         session.flash="New Task Added"
>         redirect(URL('stock_tasks'))
>     return locals()
>
>
>  and now getting <type 'exceptions.KeyError'>('ndate')
>
> further would be great 
>
> thanks.
>
> On Monday, 26 October 2015 20:09:15 UTC+11, Niphlod wrote:
>>
>> an update operation NEEDS an update() call.
>>
>> given the records you want to update are defined by a condition, namely
>>
>> db.table.column_1 == somevalue
>>
>> and the update on column_2 resulting in all those records equal to 
>> "somevalue_2", you need to write
>>
>> db(db.table.column_1 == somevalue).update(column_2 = somevalue_2)
>>
>>  
>>
>> On Saturday, October 24, 2015 at 7:27:20 AM UTC+2, Anthony Smith wrote:
>>>
>>> what I want to is update the stock_task.withhold until date with the 
>>> result of db.product.withholding_
>>> period (int) + stock_task.completed date (date)
>>>
>>>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to