Here is the field def:
 
 
              Field('quantity_on_hand', 'decimal(12,3)', default=0.0,
                     writable=False, readable= False,
                     requires=IS_EMPTY_OR(IS_DECIMAL_IN_RANGE(0, 
99999999.999)),
                     ),



On Wednesday, March 6, 2013 9:45:20 AM UTC-5, Cliff Kachinske wrote:
>
> V 2.4.2
>
> Apparently I can add a negative number in an update expression but I cannot 
> subtract a positive number.  
>
>
> Snippet:
>
> delta = new_allocation - record.quantity_allocated 
> db(db.production_jobs.id==record.production_job_id).update(
>         quantity_on_hand=db.production_jobs.quantity_on_hand - delta # 
> subtraction.  DAL will not like it
>         )
>
> Snippet raises this exception:
>
> File 
> "/home/cjk/pybin/w-2-4-2/web2py/applications/Inventory/controllers/customer_order_product_lots.py",
>  line 70, in update_lot_record
>  quantity_on_hand=db.production_jobs.quantity_on_hand - delta
>  File "/home/cjk/pybin/w-2-4-2/web2py/gluon/dal.py", line 8820, in __sub__
>  raise SyntaxError("subtraction operation not supported for type")
> SyntaxError: subtraction operation not supported for type
>
> Hackish workaround:
>
> delta = -(new_allocation - record.quantity_allocated) # flip value to negative
> db(db.production_jobs.id==record.production_job_id).update(
>         quantity_on_hand=db.production_jobs.quantity_on_hand + delta # add 
> negative number.  DAL okay with this
>         )
>
>
> Is this the expected behavior?
>
> Or am I missing something?
>
>
>

-- 

--- 
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