Created
September 6, 2017 05:48
-
-
Save repodevs/e77ec4391c3059a0f0639bc53de76cf0 to your computer and use it in GitHub Desktop.
odoo name_get inherit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# © 2017 Niaga Solution - Edi Santoso <[email protected]> | |
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). | |
from odoo import api, models | |
class Contact(models.Model): | |
_inherit = 'res.partner' | |
@api.multi | |
def name_get(self): | |
res = super(Contact, self).name_get() | |
res_dict = dict(res) | |
for record in self: | |
if record.unit_id: | |
res_dict[record.id] = "(%s) %s" % (record.unit_id.code, record.name) | |
return res_dict.items() |
@mhdsyarif coba ini mas
from odoo import api, models
class Contact(models.Model):
_inherit = 'res.partner'
@api.multi
def name_get(self):
res = super(Contact, self).name_get()
res_dict = dict(res)
for record in self:
if record.email:
res_dict[record.id] = "%s / %s" % (record.name, record.email)
return res_dict.items()
ini akan menampilkan
nama
-> Jikas User tidak mempunyai e-mail
nama / [email protected]
-> Jika user punya e-mail
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
saya ingin menampilkan name sama email
classnya sebenarnya saya potong mas, jadi saya buat tabel baru bernama
management.activity
di dalamnya ada field pic, jadi pada saat di form dropdown pic muncul nama dan emailsaya baru bisa seperti ini.