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

many2many filtre domain based other many2many field

By
namiri
on 9/18/14, 8:39 PM 1,248 views

hi;

i want to do a many2many filtre domain baser other many2many field i dont know how to do it in this case:

class ec_document(osv.Model):

class ec_document(osv.Model):
    _name ='ec.document'
    _description='ec document'
    _columns = {

                'name':fields.char('Réfrence document',required=True),
                'datedoc':fields.datetime('Date du document', required=True),
                'titre':fields.char('Titre', size=200 , required=True),
                'desc':fields.text('Description'),
                'niveau':fields.many2many('ec.classe.niveau','niveau_doc_rel','niveau_id','docuement_id','Niveau', required=True),
                'allevel':fields.boolean('Pour tout le niveau'),
                'classe':fields.many2many('ec.classe','classe_doc_rel' ,'classe_id','docuement_id','Classes Concernés',domain="[('classe.niveau.id', 'in', niveau[0][2])]"),
                'doc':fields.binary('Document', required=True)

                }

class ec_classe(osv.Model):
    _name = 'ec.classe'
    _description= 'ec classe'
    _columns ={
                'name':fields.char('Libellé Classe', size=20 , required=True),
                'code':fields.integer('Code Classe', size=4, required=True),
                'type': fields.many2one('ec.classe.type','Type de Classe',required=True),
                'niveau': fields.many2one('ec.classe.niveau','Niveau de Classe',required=True),
                'serie': fields.many2one('ec.classe.serie','Serie de Classe',required=True),
                'classeDetail': fields.one2many('ec.classe.detail','classe_id','Detail de la classe',copy=True),

 

class ec_classe_niveau(osv.Model):
    _name = 'ec.classe.niveau'
    _description= 'ec classe niveau'
    _columns ={
                'name':fields.char('Niveau', size=20 , required=True),
                'serie':fields.many2one('ec.classe.serie','Serie', required=True),
                
                }

 

 

0

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 9/19/14, 4:25 AM

Write a functional field and also onchange_event to achieve it,

1. In Function: evaluate Many2many field ( 'classe') and get a list of ids of object('ec.classe.niveau'), then use this ids to filter your Many2Many field ('niveau')

2. Do the same thing in onchange event also, and return domain to (niveau) Many2many field...

 

And one more thing, syntax which you have used for Many2many is not correct... it should be like this

'niveau':fields.many2many('ec.classe.niveau','niveau_doc_rel','docuement_id','niveau_id','Niveau', required=True),

First Parent_object_id (i.e 'ec.document') and then Child_object_id (i.e 'ec.classe.niveau')

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: 9/18/14, 8:39 PM
Seen: 1248 times
Last updated: 3/16/15, 8:10 AM