# -*- coding: utf-8 -*- from odoo import models, fields, api from odoo.exceptions import ValidationError from addons_main.archives.models.base import base_bill class Config(base_bill.Bill): _name = 'form_edit.config' _description = u'表头修改工具:设置' _order = 'id desc' _module = 'form_edit' detail = fields.One2many('form_edit.config_detail', 'form_edit_config_id', string=u'设置明细', copy=True) user_id = fields.Many2one('res.users', string=u'用户', readonly=True, index=True, default=lambda self: self.env.user) def get_config(self, model): flag = False name = model.get('model') if type(model) == dict else model _model = self.env['ir.model'].sudo().search([('model', '=', name)]) if _model: res = self.env['form_edit.config_detail'].sudo().search([('cus_models', '=', _model.id)]) is_write = self._uid in self.env.ref('archives.group_user_author').users.ids if res and is_write: flag = True return flag def get_res_groups(self): is_group = self._uid in self.env.ref( 'archives.group_user_function_setting').users.ids or self._uid in self.env.ref('archives.group_admin_user_function_setting').users.ids return is_group