I am building an accounting system. When I create a quotation, if the item is in 'subscription' category, i want to use SQLFORM.factory(db.item, db.subscription_item) to generate a create form for submitting the necessary values. Now i want to edit these 2 tables(item and subscription_item have 1-1 relationship), does SQLFORM.factory() takes any constraint or query to specify which item I want to edit? If not, what's the best way to do it? Thanks in advance!
db.define_table('company',
Field('company_name', requires=IS_NOT_EMPTY()), # unique=True
format='%(company_name)s')
db.define_table('quotation',
Field('company', 'reference company'),
Field('project_name', requires=IS_NOT_EMPTY()),
Field('quote_amount', 'double', default=0, writable=False),
auth.signature)
db.define_table('category',
Field('category_name', ondelete='NO ACTION'), # eg. project or subscription
format='%(category_name)s')
db.define_table('item',
Field('quotation', 'reference quotation', writable=False, label='Quote Id'),
Field('category', 'reference category', requires=IS_IN_DB(db, '
category.id', '%(category_name)s')),
Field('description'),
Field('amount', 'double', default=0),
auth.signature)
db.define_table('subscription_item',
Field('item', 'reference item', writable=False, label='Item Id'),
Field('start_date', 'date'),
Field('end_date', 'date'),
auth.signature)