Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Filter O2M field against antoher O2M field

Odoberať

Get notified when there's activity on this post

This question has been flagged
domainone2manyodoo9
1 Odpoveď
4825 Zobrazenia
Avatar
Azzedine

Hello Odoo community,

I'm making a custom module to manage access to building.

When granting access the user can select many partners. Once done, he can log departure for one or all of them.

For this purpose i created a model :

Access Model :

parter_ids = One2many(comodel_name="res.partner",inverse_name="Access_id") 
departed_partner_ids One2many(comodel_name="res.partner",inverse_name="Access_id")
@model
def get_log_departure_view(self) :
.....

So, the departure view is triggered by a button in the xml view, i tried something like : 

<field name="partner_ids" widget="many2many_tags" readonly="1"/>
<field name="departed_partner_ids" 
         widget="many2many_tags"
domain="[('id', 'in',partner_ids)]"
         options="{'no_create': True}"
 />

but this does not work, i have the following error :  not all arguments converted during string formatting

I think that's because partner_ids/partner_ids.id is substituted to something like "[ID,?,[ID1,ID2..]]"


Any idea, suggestion or solution for what I'm trying to achieve would be a great help :)

Thank you.

0
Avatar
Zrušiť
Avatar
Paulius Pazarauskas
Best Answer

The full code of your "Access Model" would be nice, because it is hard to understand what you are trying to achieve. It seems that both of your One2many fields point to the same inverse_name, thus meaning they will always show the same data? I have a feeling that a partner might have access to more than one building? If so you're probably better off using a Many2many relation. 

As for your domain, try changing it to this:

domain="[('id', 'in', partner_ids.ids)]"

Again, not sure why you need 2 One2many fields with the same inverse field, instead of focusing on the problem, try to explain your end goal, maybe then we can form a better solution for you.

0
Avatar
Zrušiť
Azzedine
Autor

Thank you for your time :)

Sorry, my mistake, actually it's not the same inverse_name, i just simplified the code for sake of clarity.

I extended res.partner to add the right inverse_names.

And no, a partner (or partners) must have only one access at once to a building. (so a m2o is more suitable for my case).

I already tried 'ids' attribute, but it does not work either : Error: AttributeError: object has no attribute 'ids'

i'll edit the question. thanks !

Paulius Pazarauskas

It is still weird that you want to put a domain on one of the One2many fields, they usually are not used with domains as the inverse field already specifies the relation and records will be filtered out based on that field.

Please post all of your code so I can help you

Azzedine
Autor

Thanks again for your time.

Yes, i admit that the logic is somehow weird. I actually changed the 'departed_partner_ids' field to M2M relation. but i still have the same issue.

My py file contain more that 200 lines of code and related to 4 custom models (in addition of res.partner). it would be unnecessary and a pain to write it here !

the problem is as simple as i described it above.

reminder : what i'm trying to achieve is to filter a M2M domain field based on a O2M records.

ps: I can't update my question, i don't know why :/

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

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Odoo 9C: "Add an item" of One2Many behaviour is crazy. [BUG] Solved
one2many odoo9
Avatar
6
jún 16
4928
limited choose list depented on another
domain one2many
Avatar
Avatar
1
jún 15
4697
On_change domain on one2many field
domain one2many
Avatar
Avatar
2
jún 15
4362
domain on a field in computed one2many
domain one2many computed-fields
Avatar
0
sep 24
1949
dynamic domain in one2many Solved
domain one2many dynamic
Avatar
Avatar
Avatar
2
máj 24
10125
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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