odoo 根据不同的登录用户进行字段的管控
大致思路:
1,可以将用户的群组compute出来,存储到一个字段中,compute 的群组可以使用','连接;
user_all_groups = fields.Char(string='用户所有群组', compute='_compute_user_all_groups', default='',) def _compute_user_all_groups(self): groups = ','.join(self.env.user.groups_id.mapped('name')) logging.info('groups:{}'.format(groups)) self.user_all_groups = groups or ''
2,在form视图中使用attrs属性来管控字段的隐藏和只读属性,使用的操作符为ilike, 如:
<field name="type" attrs="{'readonly': [('user_all_groups', 'ilike', '内部用户')]}"/>
本文来自博客园,作者:那时一个人,转载请注明原文链接:https://www.cnblogs.com/qianxunman/p/12134578.html