Odoo Help


how to do for many2many domain filter?

shridhar b ivani
on 6/20/15, 1:51 AM 2,915 views

i have domain filter code for many2one field. this is working fine for many2one field so i wanted 'area_id' i.e hindu_data_super class should be in many2many or please let me know how can i select multiple item in one field...

class hindu_desh(osv.Model):


_description="Define districts"

_columns={ 'name':fields.char('District Name',size=64,required=True) }


class hindu_state(osv.Model):


_description="Define sub districts"

_columns={ 'name':fields.char('Sub District Name',size=64,required=True), 'hindu_state_id': fields.many2one('hindu.desh','District Name',select=True,required=True,ondelete="restrict") }


class hindu_dist(osv.Model):


_description="Define areas"

_columns={ 'name':fields.char('Area Name',size=64,required=True),

#'area_type': fields.selection(area_type_lov,'Area Type',required=True),

'hindu_state_id':fields.many2one('hindu.state','Sub District Name',size=64,required=True),

'district_id':fields.related('hindu_state_id','hindu_state_id',readonly=True,type='many2one',relation='hindu.desh',string='District Name'),



class hindu_data_super(osv.Model):

_name = "hindu.data.super"

_description = "Area of Registration Super"

_columns = {

'district_id' : fields.many2one('hindu.desh','District', select=True, required=True, ondelete="restrict"),

'hindu_state_id' : fields.many2one('hindu.state', 'Sub District', domain="[('hindu_state_id', '=', district_id)]", select=True, required=True),

'area_id' : fields.many2one('hindu.dist', 'Area', domain="[('hindu_state_id', '=', hindu_state_id)]", select=True, required=True),



how to filter for many2many fields

shridhar b ivani
on 6/20/15, 4:48 AM

I have given answer for many2many.

Emipro Technologies Pvt. Ltd.
on 6/22/15, 6:21 AM
from openerp.osv import fields, osv # its cal.event class inherited

class calendar_event(osv.osv):
    _inherit = "calendar.event"
    _rec_name = 'number'
    _columns = {
            'number' : fields.char('Meeting ID',readonly=1),
            #'place' : fields.many2one('stock.location','Substation Location',),
            'place' : fields.many2one('asset.parentlocation','Substation Location',),
            #'location' : fields.selection(STATUS_SELECTION,'Location',  default='Board A'),
            'asset_catg_id' : fields.many2one('asset.catg', 'Asset Catg Selection',),
             'area_id' : fields.many2one('asset.name','Asset Name Selection', domain="[('asset_catg_id', '=', asset_catg_id)]", select=True, required=True),
            'assetmodelid_add' : fields.many2many('agile.portfolio1','agile_portfolio1_rel','super_id','agile_portfolio1_id','Asset Model Code',),
            'folio_num' : fields.many2many('asset.asset','asset_asset_rel','super_id','asset_asset_id','Folio Num',),
            #'folio_num' : fields.related('folio_num','folio_num',string='Folio Num',relation='asset.asset', type='many2one')   
    _defaults = {
                'number' : lambda self,cr,uid,context={}:self.pool.get('ir.sequence').get(cr,uid,'calendar.event'),

class asset_asset(osv.osv): #asset inherited
    _inherit = "asset.asset"
    #_name = "asset_asset"
    _rec_name= "folio_num"
    _columns = {
        'name': fields.char('Asset Name', size=64),
        'asset_catg_id' : fields.many2one('asset.catg', 'Asset Catg Selection',select=True, required=True),
               'area_id' : fields.many2one('asset.name', 'Asset Name Selection', domain="[('asset_catg_id', '=', asset_catg_id)]", select=True, required=True),
        'assetmodelid_add' : fields.many2one('agile.portfolio1','Asset Model Code',domain="[('area_id', '=', area_id)]",),
        'folio_num' : fields.char('Folio No', readonly=1),
        'asse_line':fields.one2many('asset.line','emp_id','Name Plate'),
               # 'assed_modelid':fields.many2one('agile.portfolio1','Asset Model ID',select=True, required=True),
        'quantity': fields.char('Quantity',size=64),
        'uom': fields.char('Uinit of Measure',size=64),
        'model_no' : fields.char('Model', size=64),
        'place': fields.many2one('asset.parentlocation', 'Location'),
        #'asset_id':fields.many2one('agile.portfolio','Asset ID'),
class asset_parentlocation(osv.osv):
    _columns = {
        'location_name' : fields.char('Asset Location', required=True),
        'parent_location' : fields.many2one('asset.parentlocation','Parent Location'),}

    def name_get(self, cr, uid, ids, context=None):
        if context is None:
            context = {}
        if not ids:
            return []
        reads = self.read(cr, uid, ids, ['location_name','parent_location'], context=context)
        res = []
        for record in reads:
            name = record['location_name']
            if record['parent_location']:
                name = record['parent_location'][1]+' / '+name
            res.append((record['id'], name))
        return res

 i would like to domain filter in cal.event inherited class so i was tried but dint get it how to domain filter of place field in cal.event that will again filter to asset_catg and all
Best Regards,

Shridhar Ivani
Software programmer

Prasanna Technologies Pvt Ltd
Krishna Complex, M.G.Road,
Mangalore - 575003, Karnataka

(Off):  +91-824-2493009
(Fax):  +91-824-2493003

shridhar b ivani
on 6/24/15, 5:06 AM
Please reply me with solution thanks in advance
shridhar b ivani
on 7/16/15, 6:27 AM

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.


Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 


We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :


  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 6/20/15, 3:30 AM


First of all define you column as many2many and then you can make filter at xml level. For that you need to write down domain inside xml defination of that field as like below.

... ...

<field name="hindu_state_id" />

<field name="area_id" domain="[('hindu_state_id','=',hindu_state_id)]" />

... ...

I hope you will get your desire result.

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.


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

1 follower(s)


Asked: 6/20/15, 1:51 AM
Seen: 2915 times
Last updated: 7/16/15, 6:27 AM