Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

Filter many2one values

Naroči se

Get notified when there's activity on this post

This question has been flagged
python2.7odooodoo-v9odoo9odoo9.0
3703 Prikazi
Avatar
Ugne Sinkeviciene

I have many2one field name_id in my_model.xml view.

I want to filter and have possibility select from name_id field only these values which have a relation with active form view model.

Example:

I have 'my.model' class records:

id = 1
title = 'Aloha'

id = 2
title = 'Bye'

'my.model.line' class records:

id = 1
name = 'first'
my_model_id = 1

id = 2
name = 'second'
my_model_id = 1

id = 3
name = 'item'
my_model_id = 2

So when I open form view, and click on add an item from name_id many2one field I want to have selection only from values: 'first', 'second' if active 'my.model' id = 1. If 'my.model' id = 2name_id many2one field selection just from 'item' value.

my_model.xml

 <record model="ir.ui.view" id="view_my_model_form">
     <field name="name">my.model.form</field>
     <field name="model">my.model</field>
     <field name="arch" type="xml">
        <form string="My Model">
          <header>
               <field name="my_model_line">
                     <tree>
                         field name="name"/>
                      </tree>
               </field>
      <notebook>
           <page>
              <field name="supply_conditions_status">
                  <tree string="My model Lines">
                        <field name="name_id"/>
                  </tree>

Models:

class SupplyConditions(models.Model):
    _name = 'supply.conditions'
    name_id = fields.Many2one('my.model.line', string='Product')
    model_id = fields.Many2one('my.model')

class MyModelLine(models.Model):
    _name = 'my.model.line'
    name = fields.Char('Name')
    my_model_id = fields.Many2one('my.model')

class MyModel(models.Model):
    _name = 'my.model'
    title = fields.Char('Title')
    my_model_line = fields.One2many('my.model.line', 'my_model_id')
    supply_conditions_status = fields.One2many('supply.conditions', 'model_id')

I have no idea how to do this. Can't use domain on xml view because can't reach active 'my.model' id. Tried on name_id use _default_value but nothing.. Maybe with relations but also have no idea how. Need any hints..


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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
From old api to new api search and name_search functions
orm python2.7 odoo odoo9
Avatar
Avatar
1
dec. 16
7729
Is it possible hide "Edit" button on form view by extending base.xml? Solved
views edit python2.7 odoo odoo-v9
Avatar
Avatar
Avatar
Avatar
Avatar
5
okt. 22
16602
How to enable payment button in Sale Order and Accounting Invoice odoo9?
payment odoo odooV9 odoo9 odoo9.0
Avatar
0
apr. 16
3888
Indiegogo: Upgrade Odoo Community Edition!
odoo odoo8.0 odoo8 odoo9 odoo9.0
Avatar
Avatar
1
okt. 15
5246
How to bring products from opportunity to quotation
odoo odoo9
Avatar
0
okt. 23
3597
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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