*e.g.*
*models/db.py*
def __before_insert_cash_in(f):
chart_of_account = int(f['chart_of_account'] )

# get default value for branch field from coa table field branch
query_coa = (db.chart_of_account.id == chart_of_account) 
row_coa = db(query_coa).select().first()
#f['branch'] = '%s' % (row_coa.branch)
f['branch'] = row_coa.branch

db.cash_in._before_insert.append(__before_insert_cash_in)
db.cash_in.branch.required = True # set True if before insert is fixed like 
in 2.14.6

*error traceback :*
Traceback (most recent call last):
  File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 219, in 
restricted
    exec(ccode, environment)
  File 
"/Users/MacBookPro/site/web2py/applications/test/controllers/transaction.py", 
line 86, in <module>
  File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 414, in 
<lambda>
    self._caller = lambda f: f()
  File 
"/Users/MacBookPro/site/web2py/applications/test/controllers/transaction.py", 
line 51, in cash_in
    db.cash_in.insert(**db.cash_in._filter_fields(form.vars) )
  File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", 
line 731, in insert
    row = self._fields_and_values_for_insert(fields)
  File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py", 
line 709, in _fields_and_values_for_insert
    'Table: missing required field: %s' % name)
RuntimeError: Table: missing required field: branch

*temporary solution :*
db.cash_in.branch.required = False
or
db.cash_in.branch.default = 1

thanks and best regards,
stifan

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