config.py 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. # -*- coding: utf-8 -*-
  2. from odoo import models, fields, api
  3. from odoo.exceptions import ValidationError
  4. from addons_main.archives.models.base import base_bill
  5. class Config(base_bill.Bill):
  6. _name = 'form_edit.config'
  7. _description = u'表头修改工具:设置'
  8. _order = 'id desc'
  9. _module = 'form_edit'
  10. detail = fields.One2many('form_edit.config_detail', 'form_edit_config_id', string=u'设置明细', copy=True)
  11. user_id = fields.Many2one('res.users', string=u'用户', readonly=True, index=True,
  12. default=lambda self: self.env.user)
  13. def get_config(self, model):
  14. flag = False
  15. name = model.get('model') if type(model) == dict else model
  16. _model = self.env['ir.model'].sudo().search([('model', '=', name)])
  17. if _model:
  18. res = self.env['form_edit.config_detail'].sudo().search([('cus_models', '=', _model.id)])
  19. is_write = self._uid in self.env.ref('archives.group_user_author').users.ids
  20. if res and is_write:
  21. flag = True
  22. return flag
  23. def get_res_groups(self):
  24. is_group = self._uid in self.env.ref(
  25. 'archives.group_user_function_setting').users.ids or self._uid in self.env.ref('archives.group_admin_user_function_setting').users.ids
  26. return is_group