I'm just a newbie in Odoo.I want to override the save method in creating customer in the sales tab(i'm using odoo 8). SO when i click save i will send an XML RPC message to some other system(ESB). I will do this kind of overriding in many odoo modules(including ad dons) but i don't know from where i start? I have right now installed odoo on my system as well as downloading the source code from the git repository ( https://github.com/odoo/odoo/tree/8.0 ) Any idea please how can i do that?
Thanks
Actually two ORM methods could be called. On creation the save button will call the models create()
and on update/write it will call write()
. So you have to create you own custom module and override these methods. You should call the super()
and then do what ever you want to do with your external system. There are a lot of examples in Odoo itself where such overrides are done, already.
A simple example :
from openerp import models, api
class ResUsers(models.Model):
_inherit = "res.users"
@api.model
def create(self, vals):
self.do_something_else()
return super(ResUsers, self).create(vals)
@api.multi
def write(self, vals):
res = super(ResUsers, self).write(vals)
self.do_something_writefully_different()
return res
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.