簡體   English   中英

如何在 odoo 的特定操作中替換記錄名稱?

[英]how to replace record name in specific action in odoo?

我有一個名為 patient 的 model 包含所有患者數據,我需要為打開 model 但沒有任何 sensative 數據(如名稱)的用戶組添加另一個菜單,但默認情況下它是 model 的 _rec_name,如何隱藏名稱患者的特定操作是另一個字段或 static 字符串,如“患者”

任何幫助將不勝感激...

基本上,您需要將數據拆分為兩個模型或更多模型。 然后使用 Delegation inheritance。這樣你就可以更輕松地分離敏感信息和非敏感信息。

在這里閱讀更多相關信息: https://www.odoo.com/documentation/14.0/reference/orm.html#inheritance-and-extension

您可以在此處查看示例hr.employee有 3 個模型:基本模型、公共模型和私有模型。

https://github.com/odoo/odoo/tree/14.0/addons/hr/models

我通過覆蓋 name_get 方法並添加新條件來實現,如果我在我的新菜單中使用 model 時將返回另一個名稱,該菜單僅針對新組顯示

def name_get(self):
    result = []
    if not self.env.user.has_group('pl_analytic.group_pl_analytic'):
        for patient in self:
            name = patient.full_name
            result.append((patient.id, name))
    else:
        for patient in self:
            result.append((patient.id, patient.identification_code))
    return result

謝謝大家

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM