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 2 field yang akan di munculkan apa aja itu mas?
field pic relation ke res.partner berarti yang di inherit name_get
nya res.partner
mas, bukan management.activity
nya
@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
Kalau kasusnya seperti ini mas.
Saya ingin nanti field pic pada saat dropdown muncul dua field.
Penulisan API gimana ya mas