From 75216584929004cb8af7a4bd486beaac196a0b70 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Thu, 29 May 2025 19:25:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_contract/models/inherit_hr_contract.py | 23 ++++++++++++++++++- .../views/inherit_hr_contract_views.xml | 1 + yuthon_hr_employee/models/inherit_res_user.py | 8 ++++++- .../views/inherit_res_user_views.xml | 7 ++++++ 4 files changed, 37 insertions(+), 2 deletions(-) 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