It is currently Tue May 22, 2012 11:34 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: many2many some noob doubts
PostPosted: Thu Jun 23, 2011 12:45 pm 
Offline

Joined: Thu Feb 17, 2011 8:32 pm
Posts: 24
If I understand the documentation this should work:
class A:
columns{
col1,
col2,
col3 -- m2m (through A_B_rel) --> B
}

class B:
columns{
col1,
col2,
col3 -- m2m (through A_B_rel) --> A
}

This should create A and B objects and so A_B_rel; am I right, or something missing?

Another one:
is it posible to extend A_B_rel like other model?
I mean:
class A_B_rel_data:
_name='A_B_rel'
_inherit='A_B_rel'
_columns{
col1,
col2
}
??
I had no success following documentation and searching through forums ended with diferent workarounds and totally confused... So any clues about this would be great.

AH! And finally:
is it posible to use a functional field as a model _rec_name field?

Thanks in advance...


Top
 Profile  
 
 Post subject: Re: many2many some noob doubts
PostPosted: Thu Jun 23, 2011 10:30 pm 
Offline

Joined: Thu Feb 17, 2011 8:32 pm
Posts: 24
I'm going mad...

I'm tryin with this:

Code:
class mtom_objecta:
    _name='mtom.objecta'
    _columns={
        'data':fields.char('Valor de a', size=5),
        'bs_ids': fields.many2many('mtom.objectb','mtom_abobjects_rel','objecta_id','objectb_id','beses')
    }
mtom_objecta()

class mtom_objectb:
    _name='mtom.objectb'
    _columns={
        'data':fields.char('Valor de b', size=5),
        'as_ids':fields.many2many('mtom.objecta','mtom_abobjects_rel','objectb_id','objecta_id','ases')
    }
mtom_objectb()


But It doesn't work...

Plz help...


Top
 Profile  
 
 Post subject: Re: many2many some noob doubts
PostPosted: Fri Jun 24, 2011 2:15 pm 
Offline

Joined: Wed Jan 27, 2010 6:21 pm
Posts: 797
Location: Auckland, NZ
you need to inherit from osv.osv for a start.

e.g.

class objecta(osv.osv)

_________________
Graeme


Top
 Profile  
 
 Post subject: Re: many2many some noob doubts
PostPosted: Fri Jun 24, 2011 7:49 pm 
Offline

Joined: Thu Feb 17, 2011 8:32 pm
Posts: 24
OMG! I can't believe it! I need to rest more... (how embarrasing)
Thanks a lot!!! And sorry for the stupid question...


Top
 Profile  
 
 Post subject: Re: many2many some noob doubts
PostPosted: Fri Jun 24, 2011 11:29 pm 
Offline

Joined: Thu Feb 17, 2011 8:32 pm
Posts: 24
Well... I managed to build models as needed:

Code:
class manytest_ambos_rel(osv.osv):
    _name='manytest.ambos.rel'
    _columns={
        'primero_id':fields.integer('Primero'),
        'segundo_id':fields.integer('Segundo'),
        'value':fields.float('Valor', digits=(16,3))
    }
manytest_ambos_rel()

class manytest_primero(osv.osv):
    _name='manytest.primero'
    _columns={
        'name':fields.char('Nombre Primero',size=15),
    }
manytest_primero()

class manytest_segundo(osv.osv):
    _name='manytest.segundo'
    _columns={
        'name':fields.char('Nombre Segundo',size=15),
        'primero_ids':fields.many2many('manytest.primero','manytest_ambos_rel','segundo_id', 'primero_id','Primeros')
    }
manytest_segundo()

class manytest_primero_x(osv.osv):
    _name='manytest.primero'
    _inherit='manytest.primero'
    _columns={
        'segundo_ids':fields.many2many('manytest.segundo','manytest_ambos_rel','primero_id', 'segundo_id','Segundos')
    }
manytest_primero_x()


Now I want to show in the segundo_ids m2m widget related manytest.primero and value from manytest.ambos.rel corresponding to relation between them.

I tried to asign a custom view for manytest.ambos.rel model but I can't get nothing to work... Just name field... (in both tree and form view) I have no clues about this so I would apreciate any help.

Tanks again to all


Top
 Profile  
 
 Post subject: Re: many2many some noob doubts
PostPosted: Fri Jul 01, 2011 12:18 pm 
Offline

Joined: Fri Jul 01, 2011 11:53 am
Posts: 1
Hi,

I made this field many2one called name.
And i want to take name to fill in other field automaticly
but i don't know how to do that


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 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