如何在 odoo 的特定操作中替换记录名称?
how to replace record name in specific action in odoo?
我有一个名为 patient 的模型,其中包含所有患者数据,
我需要为一些打开模型但没有任何敏感数据(例如名称)的用户添加另一个菜单,但默认情况下是模型的 _rec_name,
如何在特定操作中将患者的姓名隐藏为另一个字段或静态字符串,如“Patient”
任何帮助将不胜感激...
基本上您需要将数据拆分为两个模型或更多模型。
然后使用委托继承。然后你可以更容易地分离敏感信息和非敏感信息。
在此处阅读更多相关信息:
https://www.odoo.com/documentation/14.0/reference/orm.html#inheritance-and-extension
您可以在此处查看示例 hr.employee
有 3 个模型:基本模型、public 和私有模型。
我通过覆盖 name_get 方法并添加新条件来做到这一点,如果我在我的新菜单中使用仅对新组显示的模型return 另一个名称
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
感谢大家
我有一个名为 patient 的模型,其中包含所有患者数据, 我需要为一些打开模型但没有任何敏感数据(例如名称)的用户添加另一个菜单,但默认情况下是模型的 _rec_name, 如何在特定操作中将患者的姓名隐藏为另一个字段或静态字符串,如“Patient”
任何帮助将不胜感激...
基本上您需要将数据拆分为两个模型或更多模型。 然后使用委托继承。然后你可以更容易地分离敏感信息和非敏感信息。
在此处阅读更多相关信息: https://www.odoo.com/documentation/14.0/reference/orm.html#inheritance-and-extension
您可以在此处查看示例 hr.employee
有 3 个模型:基本模型、public 和私有模型。
我通过覆盖 name_get 方法并添加新条件来做到这一点,如果我在我的新菜单中使用仅对新组显示的模型return 另一个名称
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
感谢大家