diff --git a/yuthon_contract/models/inherit_hr_contract.py b/yuthon_contract/models/inherit_hr_contract.py index e1d051455..e3b0f2e4f 100644 --- a/yuthon_contract/models/inherit_hr_contract.py +++ b/yuthon_contract/models/inherit_hr_contract.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from odoo import api, fields, models, tools -from odoo.exceptions import ValidationError +from odoo.exceptions import ValidationError, UserError from dateutil.relativedelta import relativedelta @@ -36,6 +36,27 @@ class HrContract(models.Model): contact = fields.Char(related='party_id.contact', string='联系人') phone = fields.Char(related='party_id.phone', string='电话') documents_ids = fields.Many2many('ir.attachment', string="合同附件") + is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company', search='_search_part_of_company') + + @api.depends_context('uid', 'company') + @api.depends('company_id') + def _compute_is_company(self): + active_company_ids = self.env.companies + for employee in self: + employee.is_company = employee.company_id in active_company_ids + + def _search_part_of_company(self, operator, value): + if operator not in ('=', '!=') or not isinstance(value, bool): + raise UserError(('Operation not supported')) + company_ids = self.env.companies.ids # 获取公司ID列表 + # 处理反向操作符 + if not value: + operator = '!=' if operator == '=' else '=' + # 使用company_id in company_ids的结构 + if operator == '=': + return [('company_id', 'in', company_ids)] + else: # operator == '!=' + return [('company_id', 'not in', company_ids)] # @api.onchange('resource_calendar_id') # def _onchange_resource_calendar_id(self): diff --git a/yuthon_contract/views/inherit_hr_contract_views.xml b/yuthon_contract/views/inherit_hr_contract_views.xml index 288d8658f..93f9cdff9 100644 --- a/yuthon_contract/views/inherit_hr_contract_views.xml +++ b/yuthon_contract/views/inherit_hr_contract_views.xml @@ -10,6 +10,7 @@ + 1 diff --git a/yuthon_hr_employee/models/inherit_res_user.py b/yuthon_hr_employee/models/inherit_res_user.py index bb2c57a26..443dfb2df 100644 --- a/yuthon_hr_employee/models/inherit_res_user.py +++ b/yuthon_hr_employee/models/inherit_res_user.py @@ -6,6 +6,8 @@ from odoo.exceptions import UserError class ResUsers(models.Model): _inherit = "res.users" + access_token2 = fields.Char(string='OAuth 访问令牌2', help='验证消息通知。') + def all_create_users(self): employee_ids = self.browse(self._context.get('active_ids', self._context.get('active_id'))) for employee in employee_ids: @@ -20,4 +22,8 @@ class ResUsers(models.Model): else: raise UserError('该用户:%s已经创建员工,请不要重复操作' % employee_id.name) - + def all_create_users2(self): + pass + # employee_ids = self.browse(self._context.get('active_ids', self._context.get('active_id'))) + # for employee in employee_ids: + # self.oauth_access_token2 = employee.login \ No newline at end of file diff --git a/yuthon_hr_employee/views/inherit_res_user_views.xml b/yuthon_hr_employee/views/inherit_res_user_views.xml index 7e5f894f5..2484dcc51 100644 --- a/yuthon_hr_employee/views/inherit_res_user_views.xml +++ b/yuthon_hr_employee/views/inherit_res_user_views.xml @@ -7,4 +7,11 @@ code records.all_create_users() + + 更新访问令牌2 + + + code + records.all_create_users2() + \ No newline at end of file