On Monday, July 10, 2017 at 12:56:58 PM UTC-7, Ramesh Meda wrote: > > What would be the best approach to develop Parent-Child forms in Web2Py > please... > > Case in point... lets say, simple invoice application (over simplified for > the sake of discussion) > Invoice Header (Parent), with invoice information and > Invoice Items (Chid), with multiple line items (grid) > > Thanks in advance... >
I would use reference fields. <URL:http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Field-types> Something like db.define_table('customer', Field('name', 'text'), Field('address', 'text'), Field('city', 'text'), Field('etcetera', 'decimal(1,5)')) db.define_table('invoice', Field('reference', 'customer'), Field('opendate', 'date'), Field('shipdate', 'date'), Field('discount', 'decimal(2,5')) db.define_table('line_item', Field('reference', 'invoice'), Field('reference', 'catalog_item'), Field('quantity', 'integer'), Field('qty_shipped', integer), Field('backorder', 'boolean')) I've left off item charges and total due, but those would be simple to do as either a computed value, or a normal field not shown as an input but updated by an onvalidation method. Good luck! Dave S /dps -- 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.