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

Domain in xml odoo 10

Subscribe

Get notified when there's activity on this post

This question has been flagged
python2.7odoo
2 Replies
7336 Views
Avatar
Kévin Hennion

I want use a domain filter in my xml field like this :

domain="[('id','>=',field)]"

However, i don't understand how does it work !

Here my fields :

    responsible_partner = fields.Many2one(string="Responsible",
                                          comodel_name="res.partner",
                                          ondelete='restrict',
                                          domain="[('company_type','=','person')]",
                                          delegate=False)
    responsible_foyer = fields.Many2one(string="Foyer responsible", comodel_name="horanet.relation.foyer", copy=False)

Here my form view XML :

   <field name="responsible_partner" required="True" domain="[('id','=',responsible_foyer.partner_id)]" />
   <field name="responsible_foyer" />

Here my function :

@api.onchange('partner_id')
def _get_active_foyer(self):
    if self.partner_id:
        actually_partner_id = self.partner_id.name
        if actually_partner_id:
            records_foyer_id = self.env['horanet.relation.foyer'].search([('partner_id', '=', actually_partner_id)])

            for rec_foyer in records_foyer_id:
                if rec_foyer.foyer_id:
                    records_partner_id = self.env['horanet.relation.foyer'].search(
                        [('foyer_id', '=', rec_foyer.foyer_id.id)])
                    for rec_partner in records_partner_id:
                        if rec_partner.partner_id:
                            self.responsible_partner = rec_partner.partner_id.id
                            self.responsible_foyer = rec_partner.id

Error :

Error: AttributeError: object has no attribute 'partner_id'

However, I have the field partner_id in my model : "horanet.relation.foyer".

Can you explain to me ?

Thanks

0
Avatar
Discard
Avatar
Kévin Hennion
Author Best Answer

Hello,

Sorry for my english, I am french.

My function and my fields it's in 'ecole.partner.school' model. I have a 'partner_id' field in this model.

In my function, I don't have errors. What I get from the field 'responsible_foyer' is OK. However, I retrieve every partner if I click on my field Many2one in view XML. That is why, I want put a filter in XML. 

I an beginner on ODOO and there are maybe others ways to do :)

Thanks You

0
Avatar
Discard
Avatar
Tristán Mozos
Best Answer

Hiii!!!

I don't understand exactly what you want to do and I miss the description of the two models and the fields of these to can analyze better the error. However,  I have viewed something on your _get_active_foyer method. I assume that the method is of the model of your fields description. If it is true, I miss the partner_id field declaration on your model and can be a reason of error on self.partner_id statement on the first line.

Best regards

0
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
8542
How to add a list of product in a view?
python2.7 odoo
Avatar
Avatar
1
Oct 19
6673
how to customize one2many field in odoo
python2.7 odoo
Avatar
0
Feb 19
6594
How to modify “return ” to add a tax line in invoice
python2.7 odoo
Avatar
0
May 18
3411
How to customize partner t-field-options in qweb reports Solved
python2.7 odoo
Avatar
Avatar
1
Apr 24
26571
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