19 lines
759 B
Python
19 lines
759 B
Python
# -*- coding: utf-8 -*-
|
|
from odoo import api, fields, models, _
|
|
|
|
|
|
class SoongNoteSetting(models.Model):
|
|
_name = 'soong.note.setting'
|
|
|
|
name = fields.Char(string="名称")
|
|
user_group_ids = fields.Many2many('soong.user.role.group', string='用户组')
|
|
users_role_ids = fields.Many2many('soong.user.role', string='角色范围', compute='_compute_users_role_ids', store=True)
|
|
|
|
@api.depends('user_group_ids.user_role_ids')
|
|
def _compute_users_role_ids(self):
|
|
for record in self:
|
|
all_role_ids = []
|
|
for group in record.user_group_ids:
|
|
all_role_ids.extend(group.user_role_ids.ids)
|
|
unique_role_ids = list(set(all_role_ids))
|
|
record.users_role_ids = [(6, 0, unique_role_ids)] |