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č

Problem with variable in domain

Naroči se

Get notified when there's activity on this post

This question has been flagged
domainpartner_idcrm.lead
3 Odgovori
6977 Prikazi
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
Opusti
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
Opusti
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
Opusti
Avatar
Théo Da silva
Avtor 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
Opusti
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!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Get the partner_id of a user for window action domains Solved
domain partner_id window_action
Avatar
Avatar
1
apr. 18
8714
Is it possible to filter by partner_id of the current user?
filter domain partner_id uid
Avatar
0
okt. 23
2481
Filter products based on partner order history
domain sale.order partner_id product.product
Avatar
Avatar
1
sep. 21
2138
How to modify the list display fields of crm.lead in Odoo 17 Community Edition?
crm.lead
Avatar
Avatar
Avatar
2
avg. 25
3332
naked domain set up Solved
domain
Avatar
Avatar
Avatar
Avatar
3
jul. 25
6083
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