Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Filter O2M field against antoher O2M field

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
domainone2manyodoo9
1 Répondre
4820 Vues
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
Ignorer
Avatar
Paulius Pazarauskas
Meilleure réponse

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
Ignorer
Azzedine
Auteur

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
Auteur

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

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Odoo 9C: "Add an item" of One2Many behaviour is crazy. [BUG] Résolu
one2many odoo9
Avatar
6
juin 16
4925
limited choose list depented on another
domain one2many
Avatar
Avatar
1
juin 15
4683
On_change domain on one2many field
domain one2many
Avatar
Avatar
2
juin 15
4345
domain on a field in computed one2many
domain one2many computed-fields
Avatar
0
sept. 24
1940
dynamic domain in one2many Résolu
domain one2many dynamic
Avatar
Avatar
Avatar
2
mai 24
10115
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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