跳至內容
選單
此問題已被標幟
1 回覆
2703 瀏覽次數

Hi,

I added a new field (partner_contact_id) on sale order form;

#############################################

from odoo import api, fields, models

class SaleOrder(models.Model):

_inherit = "sale.order"

partner_contact_id = fields.Many2one(

comodel_name='res.partner',

string='Contact Person',

domain="[('parent_id', '=', partner_id), ('type', '=', 'contact')]")

#############################################

But in sale order form contacts displayed with company name.

Like: Azure Interior, Brandon Freeman

How can i display only contact name. (Like: Brandon Freeman)

Thanks


頭像
捨棄
作者

Thank you very much.

最佳答案

Hi,

You can override the name_get() method in the sale order and for this, you need not add a new partner_contact_id field as partner_id already exists.

class SaleOrder(models.Model):
    _inherit = "sale.order"

    def name_get(self):
        result = []
        for record in self:
            name = record.partner_id.name if record.partner_id else ''
            result.append((record.id, name))
        return result

Thanks

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
9月 23
2609
1
3月 15
4102
1
10月 23
1497
1
7月 23
2537
0
3月 15
4018