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

Why does web controller inheritance does not work?

By
Andrius Preimantas
on 4/9/14, 8:31 AM 3,226 views

I'm trying to inherit an Export controller on OpenERP v7.0. I've tried some suggestions found on the web but with no success. Could someone point me to the right direction cuz I can't find a problem with my code.

The code below is within my custom module and it gets loaded during server launch.

import openerp.addons.web.controllers.main as main


class ExportFormatInherited(main.Export):
    _cp_path = "/web/export"

    @main.openerpweb.jsonrequest
    def get_fields(self, req, model, prefix='', parent_name= '',
                   import_compat=True, parent_field_type=None,
                   exclude=None):
        print 'inherited'
        super(ExportFormatInherited, self).get_fields(req, model, prefix,
                                                      parent_name, import_compat,
                                                      parent_field_type, exclude)
0

Med Said BARA

--Med Said BARA--
2664
| 5 5 7
Algeria
--Med Said BARA--
Med Said BARA
On 4/9/14, 12:04 PM

Python super() and the MRO !!!

Not seeing what's in your code and in your log, all i can say is:

You should read the following:

Understanding Python’s ‘super’

Python’s super() considered super!

How to use super() effectively -- Python 2.7 version (Python recipe)

Method Resolution Order

I'm pretty sure this problem is due to OpenERP related issue, not Python itself. Although your links are interesting but they are not very useful in this case.

Andrius Preimantas
on 4/10/14, 6:55 AM

I said "Not seeing what's in your code and in your log". You didn't give any details on, why this code (which seems correct) doesn't work, nor on the errors you get. How could us give you an answer or a help. And I didn't say that this issue is "due" to python itself, but according to the informations given in the above links, it's due to the way super() is used (this is a common pitfall). Now if you are still sure that this is an OpenERP Bug, You should report this at https://bugs.launchpad.net/openerp-web or ask a question at https://answers.launchpad.net/openerp-web/+addquestion.

Med Said BARA
on 4/10/14, 8:23 AM
0
Andrius Preimantas
On 4/10/14, 8:10 AM

The problem was that there was no static folder within my module. The absence of this folder meant that my module was not treated as "web addon". So I had defined a web controller but it was never registered because it eventually "was not in the web addon". This is tricky and unfortunately under documented. Be careful!

Can you please add your working code as an example? I am stuck trying to inherit class Reports from main.py

riess82
on 10/3/14, 2:26 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: 4/9/14, 8:31 AM
Seen: 3226 times
Last updated: 3/16/15, 8:10 AM