Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

how to do for many2many domain filter?

Subscribe

Get notified when there's activity on this post

This question has been flagged
python2.7odoo
1 Reply
12233 Views
Avatar
shridhar b ivani

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):

_name="hindu.desh"

_description="Define districts"

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

hindu_desh()

class hindu_state(osv.Model):

_name="hindu.state"

_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") }

hindu_state()

class hindu_dist(osv.Model):

_name="hindu.dist"

_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'),

}

hindu_dist()

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),

}

hindu_data_super()

0
Avatar
Discard
shridhar b ivani
Author

how to filter for many2many fields

Emipro Technologies Pvt. Ltd.

I have given answer for many2many.

OdooBot
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'),
        'asse_line2':fields.one2many('asset.part','emp_id1','Parts'),
               # '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):
    _name="asset.parentlocation"
    _rec_name="location_name"
    _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
www.prasannatechnologies.com

OdooBot
Please reply me with solution thanks in advance
Avatar
Emipro Technologies Pvt. Ltd.
Best Answer

Hi,

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.

1
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
how to do for many2one domain filter?
python2.7 odoo
Avatar
5
Sep 20
8580
How to add a list of product in a view?
python2.7 odoo
Avatar
Avatar
1
Oct 19
6780
how to customize one2many field in odoo
python2.7 odoo
Avatar
0
Feb 19
6655
Domain in xml odoo 10
python2.7 odoo
Avatar
Avatar
2
Nov 18
7389
How to modify “return ” to add a tax line in invoice
python2.7 odoo
Avatar
0
May 18
3454
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now