The traceback complains about sql_db.py line 358 in __getattr__ and before that it is line 162 in wrapper which is inside the decorator function 'check'. I agree with it, class Cursor has no attribute 'write'. However, my function (app_approve) is trying to write and it is in the traceback prior to the above. I just don't understand how it thinks I am trying to call 'write' on the cursor when I'm explicitly calling self.write. Or am I not myself here? This is getting too metaphysical anybody have any ideas?
def _create_application_history(self, cr, uid, ids, vals, context=None):
""" Creates new application history objects """
current_application = self.browse(cr, uid, ids, context=context)[0]
# we are only working with a single record here
vals['application_id'] = current_application.id
vals['current_status'] = current_application.state
vals['completion'] = current_application.completion
vals['note'] = current_application.note
# get id from the ORM browse record since ORM can't recognize its own objects
vals['dbe_specialist'] = current_application.dbe_specialist.id
vals['onsite_visit_date'] = current_application.onsite_visit_date
vals['onsite_visit_notes'] = current_application.onsite_visit_notes
vals['visit_approved'] = current_application.visit_approved
vals['docs_completed'] = current_application.docs_completed
# get application history object and call its create
_logger.debug("Application history create called with ids %s and vals %s", str(ids), str(vals))
history_id = self.pool.get('dbe.application.history').create(cr, uid, vals, context=context)
return history_id
def _transaction_history(func):
""" Decorator function for historical logging of transactions """
@functools.wraps(func) # ensuring we still have a name after wrapping
def wrapped(self, cr, uid, ids, vals, context=None):
func_name = func.__name__
# if the wrapped function name matches a transaction type create a corresponding history record
if func_name in _transaction_types.keys():
vals['transaction_type'] = _transaction_types[func_name]
history_id = self._create_application_history(cr, uid, ids, vals, context)
if history_id:
_logger.debug("Application history created for transaction type %s with record #%d", _transaction_types[func_name], history_id)
# call wrapped function without explicit self
return func(cr, uid, ids, vals, context)
return wrapped
@_transaction_history
def app_approve(self, cr, uid, ids, context={}):
""" Setting the application record state to 'approve' from form action """
return self.write(cr, uid, ids, {'state': 'approve'}, context=context)