Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How do I override dispatch_rpc function in netsvc.py with a module in openerp 7?

By
Daniel Gómez
on 8/11/15, 12:02 PM 366 views

I need to override dispatch_rpc function in server/openerp/netsvc.py to add code that sends error log by email. I have a function that do it and works, but I want to be able to apply this modification in future by applying a module with this. Thanks :)

PD. dispatch_rpc function is not part of any class, how can I inherit it?

0

Drees Far

--Drees Far--
1130
| 5 2 6
Tunis, Tunisia
--Drees Far--
Drees Far
On 8/11/15, 1:00 PM


This is pretty straight forward but you need to do a couple of things (assuming OpenERP 7)

1 Create your new module.

2 Create a class that inherits osv.Model

3 Add an _inherit = 'xxxxxxx'

4 Implement your new dispatch_rpc function.

5 Install your module and it should work.

A typical pattern is to call super and then process the results.


class MyModel(osv.Model):

_inherit = 'sale.order.line'

def product_id_change(self, cr, uid, ids, ...):

res = super(MyModel, self).product_id_change(cr, uid, ids...)

# do stuff with res.

return res

Here is an other useful link:

Regards.

thanks for your answer, but dispatch_rpc is not part of any class or module, is part from base, what can I inherit?

Daniel Gómez
on 3/4/16, 11:03 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/11/15, 12:02 PM
Seen: 366 times
Last updated: 8/11/15, 1:24 PM