@@ -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):
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='employee_id']" position="after">
|
||||
<field name="contract_type_id" string="用工形式"/>
|
||||
<field name="is_company" string="是否本公司" optional="hide"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='name']" position="attributes">
|
||||
<attribute name="column_invisible">1</attribute>
|
||||
|
||||
@@ -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
|
||||
@@ -7,4 +7,11 @@
|
||||
<field name="state">code</field>
|
||||
<field name="code">records.all_create_users()</field>
|
||||
</record>
|
||||
<record id="all_data_create_user2" model="ir.actions.server">
|
||||
<field name="name">更新访问令牌2</field>
|
||||
<field name="model_id" ref="base.model_res_users"/>
|
||||
<field name="binding_model_id" ref="base.model_res_users"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">records.all_create_users2()</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user