It was said that in OpenERP the functions def create(self, cr, user, vals, context=None) and def update(self, cr, user, vals, context=None) exist within the orm.Model that are called if you save a new record or if you update one. I need to inherit those functions to prevent ERP from saving or updating any records if certain typed-in data have the wrong format. I found the create function and was able to inherit and my implementation for this what I wanted works fine with that. However, I wasn't able to find the function that is called when I want to update a record. It is definitely not "update" I'm using OpenERP 7. What function is called for updating a record? Please can anybody help
That's what I tried now, but it is not called:
def write(self, cr, user, ids, vals, context=None):
tasks2 = vals['task_ids']
obj_task = self.pool.get('project.task')
date = datetime.datetime.now()
valid = False
if not tasks:
valid = False
else:
for t in tasks:
task_vals = t[2]
if not task_vals['date_deadline'] and vals['type'] == 'lead':
raise osv.except_osv(_('Error!'),_('You cannot have a task without a valid date.'))
elif datetime.datetime.strptime(task_vals['date_deadline'], '%Y-%m-%d') >= date:
valid = True
if not valid and vals['type'] == 'lead':
raise osv.except_osv(_('Error!'),_('You cannot create/edit a lead without any non-expired action.'))
else:
valid = True
if valid:
return super(crm_lead_inherit, self).write(self, cr,uid,vals,context=context)