Hi All, 

I have a products table:
 db.define_table('product',
                Field('product_name'),
                Field('active_ingredient'),
                Field('batch_no'),
                Field('expiry_date','date'),
                Field('product_type', 
requires=IS_IN_SET(PRODUCTTYPES),default= PRODUCTTYPES[0]),
                Field('withholding_period','integer'),
                Field('ESI_withholding','integer'),
                Field('qty','integer'),
                Field('date_purchased','date', default = request.now),
                Field('purchased_from', 
requires=IS_IN_DB(db,'company.company_name','%(company_name)s')),
                (auth.signature),
                format='%(product_name)s %(batch_no)s')

I can edit the product with the following controller:
def edit_product():
    product_id = request.args(0,cast=int)
    product = db.product(product_id) or error()
    if not product.created_by==me:
        product.created_by.writable = True
    else:
        product.created_by.writable = False
    form = SQLFORM(db.product,product,
                   showid=False,
                   
deletable=(product.created_by==me)).process(onsuccess=auth.archive)
    if form.accepted:
        session.flash="Edit Successful"
        redirect(URL('products'))
    return locals()

At times I need to add new products but only some of the fields change E.G. 
batch_no, expiry_date, and supplier. 
In short if need to add similar item that I already have in the products 
table 


thanks 

Anthony 


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