How to override create and write method for an object in Odoo
We can override create and write method for an object.
In the example two methods given (create and write)
Example:
class MyClass(...): def create(cr, uid, vals, context=None): # Your logic goes here or call your method res_id = super(MyClass, self).create(cr, uid, vals, context=context) # Your logic goes here or call your method return res_id def write(cr, uid, ids, vals, context=None): # Your logic goes here or call your method super(MyClass, self).write(cr, uid, ids, vals, context=context) # Your logic goes here or call your method return True
create method will be called when you are creating a new record.
write method will be called when you are updating any existing record,
if you want to perform some action while creating a new record or updating an existing record, you can do it by following above example.
No comments:
Post a Comment