Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Problem with variable in domain

Subscriure's

Get notified when there's activity on this post

This question has been flagged
domainpartner_idcrm.lead
3 Respostes
6936 Vistes
Avatar
Théo Da silva

Hi!

I would like to add a button in contact that will link to crm.lead that the contact sold.

Because of the crm.lead salesman is link by a user_id I created a computed many2one field (stored) crm_user_id to the linked user:

record.crm_user_id = self.env['res.users'].search([('partner_id', '=', record.id)]).id

The id is right but when I want to use it for the domain I get this error:

 

Uncaught Error: NameError: name 'crm_user_id' is not defined
http://localhost:8069/web/content/654-6128a20/web.assets_backend.js:145 Traceback: Error: NameError: name 'crm_user_id' is not defined


When I set a fixe value like 2 (the id of one on my user) instead of the var crm_user_id It works perfectly

The domain in question is set like that:


    <record model="ir.actions.act_window" id="crm_open">
        <field name="domain">[('user_id', '=', crm_user_id)]</field>
        <field name="name">CRM</field>
        <field name="res_model">crm.lead</field>
    </record>


0
Avatar
Descartar
Avatar
Anisha Bahukhandi
Best Answer

Hello Théo Da Silva, 

You are getting this issue because "crm_user_id" is not defined inside the windows action and by default in Odoo you can't pass value in domain inside a XML file for windows action.

And your requirement is to show leads from Partner on button click

So instead of creating a computed field inside the partner you can achieve the same using button method. 

def action_open_crm_lead(self):
        self.ensure_one()
        userObjs = self.env['res.users'].search([('partner_id', '=', self.id)], limit=1)
        user_id = userObjs.id if userObjs else False
        domain = [('user_id', '=', user_id)] if user_id else []
        return {
            'name': 'CRM LEAD',
            'domain': domain,
            'res_model': 'crm.lead',
            'type': 'ir.actions.act_window',
            'view_mode': 'tree,form',
            'view_id': False,
        }

Feel free to ask your queries

Thanks

Anisha Bahukhandi

3
Avatar
Descartar
Avatar
Mustufa Rangwala
Best Answer

Hello,

Can you please make sure you have store=True on "crm_user_id" field which you have created on contact  (res.partner) form. ?

Regards,

Mustufa Rangwala (Probuse)

0
Avatar
Descartar
Avatar
Théo Da silva
Autor Best Answer

Hello Mustufa,

Thanks for your answer, yes store=True

    crm_user_id = fields.Many2one(
        comodel_name='res.users',
        compute=_compute_crm_user_id,
        store=True)

I also have a value in the postgres at the field crm_user_id in the table res_patner.

But I still get the same error

Edit:

Thank you very much Anisha Bahukhandi it works perfectly

0
Avatar
Descartar
Anisha Bahukhandi

Hello Théo Da Silva,

It's great that your query is resolved and you are satisfied with my assistance.

I would really appreciate if you can take out a few minutes out of your busy schedule and put a google review for me here -

https://www.google.com/search?q=webkul&oq=webkul+&aqs=chrome..69i57j69i60l3j0l2.4182j0j7&sourceid=chrome&ie=UTF-8#lrd=0x390ce561c5555555:0xcfb40ae166ce6c21,1,

A nice review from your side will motivate me and my team to provide exceptional assistance.

I hope you can manage to provide few minutes for this :)

Regards

Anisha Bahukhandi

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

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

Registrar-se
Related Posts Respostes Vistes Activitat
Get the partner_id of a user for window action domains Solved
domain partner_id window_action
Avatar
Avatar
1
d’abr. 18
8680
Is it possible to filter by partner_id of the current user?
filter domain partner_id uid
Avatar
0
d’oct. 23
2445
Filter products based on partner order history
domain sale.order partner_id product.product
Avatar
Avatar
1
de set. 21
2134
How to modify the list display fields of crm.lead in Odoo 17 Community Edition?
crm.lead
Avatar
Avatar
Avatar
2
d’ag. 25
3259
naked domain set up Solved
domain
Avatar
Avatar
Avatar
Avatar
3
de jul. 25
6047
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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