Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

name get() not working ?

Subscribe

Get notified when there's activity on this post

This question has been flagged
nameget
10 Replies
19768 Views
Avatar
omprakash
Hai Friends ,
    First I thank everyone for such good support for newbies . I have Question regards name_get() . This is my sample custom code .Please let me know how to pass value for context (for many2one field i like to display to email instead of title) .

Notebook :
1. __init__.py
   import notebook
2.__openerp__.py
{
    "name" : "notebook",
    "version" : "0.1",
    "author" : "Prakash",
    "website" : "http://www.prakash.com/",
    "category" : "Generic Modules/Others",
    "depends" : ["base"],
    "description" : "Simple demo module",
    "init_xml" : ['notebook_view.xml'],
    "demo_xml" : [],
    "update_xml" : [],
    "active": False,
    "installable": False
}
3.notebook.py
 from osv import fields, osv
 class notebook(osv.osv):
    _name = "notebook"
    _description = "Simple Notebook"
    _rec_name = 'title'
    _columns = {
        'title' : fields.char('Title', size=30, required=True),
        'note' : fields.text('Note'),
        'note_date' : fields.date('Date'),
        'email': fields.char('Email', size=240),
    }
    def name_get(self, cr, uid, ids, context=None):
        if context is None:
            context = {}
        res = []
        for record in self.browse(cr, uid, ids, context=context):
            email = record.email
            title = record.title
            if context.get('email'):
                email = "%s <%s>" % (email, record.email)
                return res
            res.append((record.id, title))
        return res

notebook()

 4. notebook_view.xml
    <?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record model="ir.ui.view" id="notebook_tree_view">
            <field name="name">notebook.tree</field>
            <field name="model">notebook</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Notebook">
                    <field name="title"/>
                    <field name="note"/>
                    <field name="note_date"/>
                </tree>
            </field>
        </record>
        <record model="ir.ui.view" id="notebook_form_view">
            <field name="name">notebook.form</field>
            <field name="model">notebook</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Notebook">
                    <field name="title"/>
                    <field name="note"/>
                    <field name="note_date"/>
                    <field name="email"/>
                </form>
            </field>
        </record>
        <record model="ir.actions.act_window" id="action_notebook_form">
            <field name="name">notebook</field>
            <field name="res_model">notebook</field>
        </record>
        <menuitem name="NotebookParent" icon="terp-project" id="NotebookParent_menu"/>
    <menuitem name="NotesChild" parent="NotebookParent_menu" id="NotesChild_menu" />
        <menuitem name="Header" parent="NotesChild_menu" id="Header_menu_mainform" action="action_notebook_form"/>
    </data>
</openerp>



monitor:

1. __init__.py
    import monitor
2. __openerp__.py
{
    "name": "monitor",
    "version": "7.0",
    "depends": ["base"],
    "author": "author",
    "category": "category",
    "description": """
    This module provide : test
    """,
    "init_xml": [],
    'update_xml': [],
    'demo_xml': [],
    'installable': True,
    'active': False,
    "data" : ["monitor_view.xml"]
}
3. monitor.py

  from osv import fields,osv

class monitor(osv.osv):
    _name = 'monitor'
    _columns = {
            'name' : fields.char("name" , size = 10 , required = True),
            'email':fields.many2one('notebook', 'email'),
                    }
monitor()

4.monitor_view.xml
 <?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
               <record model="ir.ui.view" id="monitor_form_view">
                <field name="name">monitor.form</field>
                <field name="model">monitor</field>
                <field name="type">form</field>
                <field name="arch" type="xml">
                    <form string="form_monitor">
                        <field name="name" select="1"/>
                         <field name="email" context="{'email':email}"/>
                    </form>
                </field>
            </record>    

        <act_window name="monitor"
            res_model="monitor"
            src_model="monitor"
            id="monitor_id"/>
    <menuitem id="one_id" name="one" />
    <menuitem id="two_id" name="two" parent="one_id" />
    <menuitem id="three_id" name="three" parent="two_id" action="monitor_id"/>
    </data>
</openerp>

Actually I like to display email instead of title (many2one) , but still it getting title as display for many2one . I don't know how to pass value for context .Please help me to move further . And once again i thank everyone .
1
Avatar
Discard
Avatar
ClueLogics Technologies Pvt. Ltd.
Best Answer

your method should be

   def name_get(self, cr, uid, ids, context=None):
    if context is None:
        context = {}
    res = []
    for record in self.browse(cr, uid, ids, context=context):
        email = record.email
        title = record.title
        tit = "%s <%s>" % (title, record.email)
        res.append((record.id, tit))
    return res
8
Avatar
Discard
omprakash
Author

Hi Sandeep , Thanks for your reply . I have doubt in < monitor_view.xml> line -> <field name="email" context="{'email':email}"/> how to pass value for def name_get(self, cr, uid, ids, context=None) . Actually I need how to pass context value ( need correct syntax) ...And once again thanks

ClueLogics Technologies Pvt. Ltd.

i think you no need to pass value for context for name get, just include above method and don't use context , as i think you want name get with email so email is already there

omprakash
Author

Sandeep Thanks for reply . Basically if i use relation (many2one ) title will be displayed because i declared _rec_name = 'title' (notebook). But i need to display email for some module (monitor). So i want to pass context which decide what to display . But i don't know the syntax . If you understand my problem please help me .

ClueLogics Technologies Pvt. Ltd.

for some records email and some for only title ??

omprakash
Author

Sandeep , For module < monitor > i like to display - email & if i have another module example <school> i want to display as title .

Solanki Shamji

@Sandeep. If I have large amount of data than it is possible to name_get method working? Its give memory error if I have more than 50000 records.

Avatar
Muhammad
Best Answer

Hi,

Can I use this name_get() function as well?

I am using the Automated Actions module to create a project automatically when an opportunity is created.

The only problem I have is that I don't know how to name the project based on the name of the lead/opportunity automatically.

Can you tell me what function/python code I should use?

0
Avatar
Discard
Avatar
Alexander
Best Answer

Hi! It is too difficult to read unformated source code :)

Perhaps, using related email field instead of many2one field in view will be helpfull for you. Also it will be work faster, because no request will be send for every row.

-1
Avatar
Discard
omprakash
Author

Hi Alexander , Thanks for immediate reply . Now I formatted my code . Can you please help me

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

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

Sign up
Related Posts Replies Views Activity
Disable GET parameters
get
Avatar
0
मार्च 15
4468
How to change displayed values in « deliver to » scroll list in a purchase order?
purchase search quotation name get
Avatar
Avatar
1
जून 15
5347
List view Solved
name Listview
Avatar
Avatar
1
फ़र॰ 25
1714
GET/POST Requests in Odoo to External API
get post
Avatar
Avatar
1
फ़र॰ 25
20570
Change the database name Solved
database name
Avatar
Avatar
Avatar
2
जून 23
16936
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

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