Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Kov
    • Nábytek
    • Jídlo
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • IT hardware a podpora
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

Problem with variable in domain

Odebírat

Get notified when there's activity on this post

This question has been flagged
domainpartner_idcrm.lead
3 Odpovědi
6923 Zobrazení
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
Zrušit
Avatar
Anisha Bahukhandi
Nejlepší odpověď

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
Zrušit
Avatar
Mustufa Rangwala
Nejlepší odpověď

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
Zrušit
Avatar
Théo Da silva
Autor Nejlepší odpověď

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
Zrušit
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!

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
Get the partner_id of a user for window action domains Vyřešeno
domain partner_id window_action
Avatar
Avatar
1
dub 18
8664
Is it possible to filter by partner_id of the current user?
filter domain partner_id uid
Avatar
0
říj 23
2423
Filter products based on partner order history
domain sale.order partner_id product.product
Avatar
Avatar
1
zář 21
2124
How to modify the list display fields of crm.lead in Odoo 17 Community Edition?
crm.lead
Avatar
Avatar
Avatar
2
srp 25
3203
naked domain set up Vyřešeno
domain
Avatar
Avatar
Avatar
Avatar
3
čvc 25
5964
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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