I'm still trying to resolve my problem, and desperately need someone's help 
:)

When I try to add a new sku to a purchase order, I would like to 
prepopulate "CPU" field with the value from db.sku.cpu (determined by a 
dropdown).
http://127.0.0.1:8000/test/default/list_purchase_orders/purchase_order/po_sku.po_id/1/new/po_sku

Is it possible to do this through smartgrid, and how would I do it? Bellow 
is a short version of my code for this... I'm stuck... :(

#db.py
db.define_table('sku',
                Field('sku_number', 'string', label=T('SKU #')),
                Field('description', 'string', label=T('Description')),
                Field('cpu', 'double'),
                Field('note', 'text'), 
                format='%(sku_number)s - %(description)s',
                )

db.define_table('purchase_order',
                Field('po_number', 'string'),
                )

db.define_table('po_sku',
                Field('sku_id', db.sku, label=T('SKU #')),
                Field('po_id', db.purchase_order, label=T('Purchase Order 
#')),
                Field('qty', 'integer'),
                Field('cpu', 'double'),
                )
                
# default.py
def list_purchase_orders():
    db.purchase_order.id.readable = False

    db.purchase_order['_plural'] = 'Purchase Orders'

    grid=SQLFORM.smartgrid(db.purchase_order, details=True, 
links_in_grid=True, 
                        maxtextlengths={'purchase_order.po_number':15},
                        maxtextlength=20,
                        paginate=20, 
                        csv=False,
                        ui='jquery-ui',
                        user_signature=False, oncreate = auth.archive, 
onupdate=auth.archive)
    return dict(grid=grid)

Reply via email to