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 to override nested methods

By
Jerome Guerriat
on 4/8/16, 7:49 AM 406 views

Hi everyone,

I would like to modify the behaviour of the SurveyMailComposeMessage wizard.
All i have to do is to add a parameter to the create survey answer object.


The problem is that the method that creates the object is nested inside another method:

class SurveyMailComposeMessage(osv.TransientModel):
[...]  
    def send_mail(self, cr, uid, ids, auto_commit=False, context=None): 
    [...]
        def create_token(wizard, partner_id, email):    
        [...]

would like to override the method create_token, without overriding its "parent" method send_mail. 
Does anyone know a way to do that? Overriding the whole send_mail method is working, but i would like to avoid having to copy/paste 100 lines of code to add a single line :-).


Thanks a lot :)

0

Temur

--Temur--
2896
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 4/8/16, 10:15 AM

you can not override nested function, using any standard approach. If you consider function itself as an object and hack into it's internal definition, then you should be able to "override" the internal function, but it's not actually what we generally mean under override. see following post. I mentioned the way here, just to say that it's somehow possible, however I do not recommend this way to you, you should avoid it as much as possible if there is an alternate way to go with.

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

2 follower(s)

Stats

Asked: 4/8/16, 7:49 AM
Seen: 406 times
Last updated: 4/8/16, 10:15 AM