Odoo Help

0

How to override nested methods

By
Jerome Guerriat
on 4/8/16, 7:49 AM 675 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--
2932
| 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.

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

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