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

filtering contacts in field widget based on slightly complex criteria

S'inscrire

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

Cette question a été signalée
contactsdomain_filterPython
1 Répondre
2326 Vues
Avatar
HASEEB AHMED

Hi everyone.

i am trying to tweak an addon i purchased last year for my company. (mrp tags)
i have done 90% tweaks and its coming along very nicely. one point which i am unable to grasp / solve is filter..
to me it seems, i am pretty close, but unable to grasp domain filter completely.
BTW, using odoo13.



on pointer 3 ( trying to solve subcontract) part, where each rec name has equivalent inventory product (type=service) with 2 or 3 vendors (contacts in it) as supplier of service. >> 

my model looks like 
------------------------------------------

-------mrp_custom_checklist.py---------

------------------------------------------
class MrpCustomChecklist(models.Model):

​_inherit = 'mrp.production'

​ partner_id = fields.Many2one('res.partner', string='Partner')


​@api.model

​def get_service_vendors(self):

​ ​service_products = self.env['product.product'].search([('type', '=', 'service')])

​ ​vendor_ids = service_products.mapped('seller_ids.name.id')

​ ​vendor_records = self.env['res.partner'].browse(vendor_ids)

​ ​vendor_names = vendor_records.mapped('name')

​ ​return vendor_names

​ @api.model

​ def get_named_service_vendors(self,product_name):

​ ​ service_product = self.env['product.product'].search([('type', '=', 'service'), ('name', 'ilike', product_name)], limit=1)

​ ​ vendor_ids = service_product.mapped('seller_ids.name.id')

​ ​ vendor_records = self.env['res.partner'].browse(vendor_ids)

​ ​ vendor_names = vendor_records.mapped('name')

​ ​ return vendor_names


and XML looks like 
------------------------------------------

-------mrp_custom_checklist.xml---------

------------------------------------------

" rel="ugc">ir.ui.view">

​ mrp.custom.checklist.form

​ ​

​ ​

​ ​ ​

​ ​ ​

​ ​ ​  

===========

PROBLEM

==========

Field 'get_service_vendors' used in attributes must be present in view but is missing:

  • 'get_service_vendors' in domain="[('id', 'in', get_service_vendors())]"

Error context: View mrp.custom.checklist.form

 
any ideas.??

0
Avatar
Ignorer
Avatar
Baiju KS
Meilleure réponse

You cannot use a function in the domain inside the view file, because it must be present in the view.

Please try to use a compute field with the needed type and use it in the domain.

Hope this helps

1
Avatar
Ignorer
HASEEB AHMED
Auteur

for reference, if someone stuck in same place ( in future )

@api.depends('mode')
def _compute_partner_id(self):
for record in self:

service_products = self.env['product.product'].search([('type', '=', 'service')])
print ("TOTAL SERVICES:",len(service_products))
vendor_ids = service_products.mapped('seller_ids.name.id')[:1]
print ("TOTAL VENDORS (INTENTIONAL LIMIT):",len(vendor_ids))
print ("VENDOR IDS:",vendor_ids)
vendor = self.env['res.partner'].browse(vendor_ids)
print ("VENDOR ID:",vendor)

if vendor:
print ("VENDOR NAME:",vendor.name)
record.partner_id = vendor.id
else:
record.partner_id = False

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é
is it possible to update (re-assign) selection field (field.selection) values dynamically .?
contacts Python fields.selection
Avatar
Avatar
1
sept. 23
3552
How to avoid duplicate contact (Customer/Vendor) by making automated action based on name on V14?
contacts duplication Python AutomatedActions
Avatar
Avatar
1
nov. 22
4550
importing contacts. Getting blocking error: Contacts require a name at multiple rows
contacts
Avatar
Avatar
Avatar
2
oct. 25
774
Blocking Errors
contacts
Avatar
Avatar
1
oct. 25
665
O18 EE: Completely unknown email addresses in the contacts?
contacts
Avatar
Avatar
Avatar
2
oct. 25
834
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