Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Discuss
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

name get() not working ?

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
nameget
10 Replies
19774 Tampilan
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
Buang
Avatar
ClueLogics Technologies Pvt. Ltd.
Jawaban Terbai

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
Buang
omprakash
Penulis

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
Penulis

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
Penulis

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
Jawaban Terbai

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
Buang
Avatar
Alexander
Jawaban Terbai

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
Buang
omprakash
Penulis

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

Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Disable GET parameters
get
Avatar
0
Mar 15
4487
How to change displayed values in « deliver to » scroll list in a purchase order?
purchase search quotation name get
Avatar
Avatar
1
Jun 15
5349
List view Diselesaikan
name Listview
Avatar
Avatar
1
Feb 25
1714
GET/POST Requests in Odoo to External API
get post
Avatar
Avatar
1
Feb 25
20587
Change the database name Diselesaikan
database name
Avatar
Avatar
Avatar
2
Jun 23
16948
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik 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