diff --git a/soong_workflow/models/soong_user_role.py b/soong_workflow/models/soong_user_role.py
index fbcefa268..aa4ea0027 100644
--- a/soong_workflow/models/soong_user_role.py
+++ b/soong_workflow/models/soong_user_role.py
@@ -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:
diff --git a/yuthon_holiday/models/yuthon_vacation_reports.py b/yuthon_holiday/models/yuthon_vacation_reports.py
index 4d9a7c9ed..7589c8dbd 100644
--- a/yuthon_holiday/models/yuthon_vacation_reports.py
+++ b/yuthon_holiday/models/yuthon_vacation_reports.py
@@ -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
diff --git a/yuthon_holiday/views/yuthon_vacation_reports_views.xml b/yuthon_holiday/views/yuthon_vacation_reports_views.xml
index 0fdacc26b..609c9be6c 100644
--- a/yuthon_holiday/views/yuthon_vacation_reports_views.xml
+++ b/yuthon_holiday/views/yuthon_vacation_reports_views.xml
@@ -8,8 +8,6 @@
-
-
diff --git a/yuthon_hr_attendance/views/resource_calendar_leaves_views.xml b/yuthon_hr_attendance/views/resource_calendar_leaves_views.xml
index 8f6f258e7..1eec66227 100644
--- a/yuthon_hr_attendance/views/resource_calendar_leaves_views.xml
+++ b/yuthon_hr_attendance/views/resource_calendar_leaves_views.xml
@@ -5,9 +5,6 @@
resource.calendar
-
- 1
-
1
diff --git a/yuthon_hr_employee/models/yuthon_hr_department.py b/yuthon_hr_employee/models/yuthon_hr_department.py
index e2420d86b..898434a6d 100644
--- a/yuthon_hr_employee/models/yuthon_hr_department.py
+++ b/yuthon_hr_employee/models/yuthon_hr_department.py
@@ -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:
diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py
index 2f8498753..9a6ab1323 100644
--- a/yuthon_hr_employee/models/yuthon_hr_employee.py
+++ b/yuthon_hr_employee/models/yuthon_hr_employee.py
@@ -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: