添加功能
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
from odoo import api, fields, models, _
|
||||
from pypinyin import pinyin, lazy_pinyin
|
||||
from odoo.osv import expression
|
||||
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
class YuthonUserRole(models.Model):
|
||||
_name = 'soong.user.role'
|
||||
@@ -22,7 +22,7 @@ class YuthonUserRole(models.Model):
|
||||
employee_ids = fields.One2many('hr.employee', 'user_role_id')
|
||||
company_id = fields.Many2one('res.company', string="公司", default=lambda self: self.env.company)
|
||||
pinyin_name = fields.Char(string="拼音名称", compute='_compute_pinyin', index=True)
|
||||
is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company')
|
||||
is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company', search='_search_part_of_company_id')
|
||||
|
||||
@api.depends_context('uid', 'company')
|
||||
@api.depends('company_id')
|
||||
@@ -45,6 +45,17 @@ class YuthonUserRole(models.Model):
|
||||
employee = user_employees.filtered(lambda r: r.company_id == user.company_id) or user_employees[:1]
|
||||
return employee
|
||||
|
||||
def _search_part_of_company_id(self, operator, value):
|
||||
if operator not in ('=', '!=') or not isinstance(value, bool):
|
||||
raise UserError(('Operation not supported'))
|
||||
user_employee = self._get_valid_employee_for_user()
|
||||
# Double negation
|
||||
if not value:
|
||||
operator = '!=' if operator == '=' else '='
|
||||
if not user_employee.company_id:
|
||||
return [('id', operator, user_employee.id)]
|
||||
return (['!'] if operator == '!=' else []) + [('company_id', '=', user_employee.company_id.id)]
|
||||
|
||||
@api.onchange('is_main')
|
||||
def _onchange_is_main(self):
|
||||
for employee in self.personnel_ids:
|
||||
|
||||
@@ -11,7 +11,6 @@ class YuthonVacationReports(models.Model):
|
||||
employee_id = fields.Many2one('hr.employee', string='员工')
|
||||
leave = fields.Float(string='年假')
|
||||
working_overtime = fields.Float(string='加班时')
|
||||
vacation_balance = fields.Float(string='假期余额')
|
||||
|
||||
def button_fixes_approval(self):
|
||||
form_id = self.env.ref('yuthon_holiday.view_yuthon_fixes_approval_form').id
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
<field name="employee_id"/>
|
||||
<field name="leave"/>
|
||||
<field name="working_overtime"/>
|
||||
<field name="vacation_balance"/>
|
||||
<button name="vacation_details"/>
|
||||
<button name="vacation_details" string="详情" type="object" class="oe_highlight"/>
|
||||
<button name="button_fixes_approval" string="修正" type="object" class="oe_highlight"/>
|
||||
</tree>
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
<field name="model">resource.calendar</field>
|
||||
<field name="inherit_id" ref="resource.view_resource_calendar_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='company_id']" position="attributes">
|
||||
<attribute name="column_invisible">1</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='work_time_rate']" position="attributes">
|
||||
<attribute name="column_invisible">1</attribute>
|
||||
</xpath>
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
from odoo import api, fields, models
|
||||
from pypinyin import pinyin,lazy_pinyin
|
||||
from odoo.osv import expression
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
|
||||
|
||||
class YuthonHrDepartment(models.Model):
|
||||
_inherit = "hr.department"
|
||||
@@ -23,7 +24,7 @@ class YuthonHrDepartment(models.Model):
|
||||
department_code = fields.Char(string="部门序号")
|
||||
company_id = fields.Many2one('res.company', string="公司", index=True, default=lambda self: self.env.company)
|
||||
pinyin_name = fields.Char(string="拼音名称", compute='_compute_pinyin', index=True, store=True)
|
||||
is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company')
|
||||
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')
|
||||
@@ -46,6 +47,17 @@ class YuthonHrDepartment(models.Model):
|
||||
employee = user_employees.filtered(lambda r: r.company_id == user.company_id) or user_employees[:1]
|
||||
return employee
|
||||
|
||||
def _search_part_of_company(self, operator, value):
|
||||
if operator not in ('=', '!=') or not isinstance(value, bool):
|
||||
raise UserError(('Operation not supported'))
|
||||
user_employee = self._get_valid_employee_for_user()
|
||||
# Double negation
|
||||
if not value:
|
||||
operator = '!=' if operator == '=' else '='
|
||||
if not user_employee.company_id:
|
||||
return [('id', operator, user_employee.id)]
|
||||
return (['!'] if operator == '!=' else []) + [('company_id', '=', user_employee.company_id.id)]
|
||||
|
||||
@api.constrains('create_date', 'end_date')
|
||||
def _check_start_end_time(self):
|
||||
for record in self:
|
||||
|
||||
@@ -167,7 +167,7 @@ class YuthonHrEmployee(models.Model):
|
||||
pension_insurance_base = fields.Float(string='基本养老费基数', compute='_compute_insurance_bases')
|
||||
work_injury_insurance_base = fields.Float(string='失业保险金基数', compute='_compute_insurance_bases')
|
||||
housing_fund_base = fields.Float(string='住房公积金基数', compute='_compute_insurance_bases')
|
||||
is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company')
|
||||
is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company', search='_search_part_of_company')
|
||||
last_attendance = fields.Boolean(string="上月全勤", store=True)
|
||||
|
||||
@api.depends_context('uid', 'company')
|
||||
@@ -191,6 +191,17 @@ class YuthonHrEmployee(models.Model):
|
||||
employee = user_employees.filtered(lambda r: r.company_id == user.company_id) or user_employees[:1]
|
||||
return employee
|
||||
|
||||
def _search_part_of_company(self, operator, value):
|
||||
if operator not in ('=', '!=') or not isinstance(value, bool):
|
||||
raise UserError(('Operation not supported'))
|
||||
user_employee = self._get_valid_employee_for_user()
|
||||
# Double negation
|
||||
if not value:
|
||||
operator = '!=' if operator == '=' else '='
|
||||
if not user_employee.company_id:
|
||||
return [('id', operator, user_employee.id)]
|
||||
return (['!'] if operator == '!=' else []) + [('company_id', '=', user_employee.company_id.id)]
|
||||
|
||||
@api.depends('normal_overtime_hours', 'weekend_overtime_hours', 'holiday_overtime_hours')
|
||||
def _compute_overtime_this_month(self):
|
||||
for employee in self:
|
||||
|
||||
Reference in New Issue
Block a user