It is currently Sat Feb 11, 2012 10:27 am

All times are UTC + 2 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: inheriting class from osv.fields.one2many
PostPosted: Thu Feb 11, 2010 11:28 pm 
Offline

Joined: Mon Sep 21, 2009 2:20 pm
Posts: 31
I've tried without any success to inherit from one2many field. I wanted to override some methods in the new class but when openerp tries to load the module it shows a CRITICAL error in the log (no special message to understand what is the problem)

What I intended to do in my python source file is something like this:

Code:
from osv import fields

#class inherited from fields.one2many
class x_one2many(fields.one2many):

    _inout = None

    def __init__(self, obj, fields_id, string='unknown', limit=None, inout, **args):
        fields.one2many.__init__(self, obj, fields_id, string, limit, args)
        self._domain = [('type', '=', inout)]
        self._inout = inout
       

    def get(....)
        new get() code here

...
class X(osv.osv):
...
    _columns = {
        col1= fields. ...,
...
        coln= fields. ...,
        'coly': x_one2many('y', x_id', 'name', readonly=True, inout='in'),
    }

X()
...
class Y(osv.osv):
...

Y()
[/code]

even if I don't use x_one2many class in the code, the module doesn't load. What could be the problem?


Top
 Profile  
 
 Post subject: problem SOLVED
PostPosted: Fri Feb 12, 2010 4:03 pm 
Offline

Joined: Mon Sep 21, 2009 2:20 pm
Posts: 31
the problem was the order of the required parameters of the constructor

inout parameter must be placed must be placed before the string, first parameter with default value


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP