Commit 132a4ed1 authored by Actarus's avatar Actarus
Browse files

contact model: Added name_get method

parent 4141e40c
# -*- coding: utf-8 -*-
from odoo import models, fields
from odoo import models, fields, api
class Contact(models.Model):
_name = "customer.contact"
......@@ -22,3 +22,18 @@ class Contact(models.Model):
country_id = fields.Many2one("res.country", string="Pays")
state_id = fields.Many2one("res.country.state", string="Région")
department_id = fields.Many2one("res.country.department", string="Département")
# ========================
# Computations and actions
# ========================
@api.depends("name", "partner_id.name")
def name_get(self):
res = []
for contact in self:
if contact.partner_id:
name = "{} ({})".format(contact.name, contact.partner_id.name)
else:
name = contact.name
res.append((contact.id, name))
return res
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment