diff --git a/soong_workflow/models/soong_user_role.py b/soong_workflow/models/soong_user_role.py index 041a9f190..7ed6374a7 100644 --- a/soong_workflow/models/soong_user_role.py +++ b/soong_workflow/models/soong_user_role.py @@ -14,26 +14,26 @@ class YuthonUserRole(models.Model): end_time = fields.Datetime(string="结束时间") yuthon_company = fields.Selection([('thtz', '天河投资集团'), ('thwg', '天河物管'), ('thlc', '天河粮储'), ('tctj', '天投城建'), - ('thtjbb', '天河投资本部')], string="所属公司") + ('thtjbb', '天河投资本部')], string="所属公司",compute='compute_company') # - # @api.depends('department_id') - # def compute_company(self): - # company_mapping = {'天河投资集团': 'thtz', - # '天河物管': 'thwg', - # '天河粮储': 'thlc', - # '天投城建': 'tctj', - # '天河投资本部':'thtjbb'} - # for record in self: - # visited_departments = set() - # department = record.department_id - # while department and department.id not in visited_departments: - # visited_departments.add(department.id) - # if department.name == '天河投资集团': - # record.yuthon_company = 'thtz' - # break - # elif department.name in company_mapping: - # record.yuthon_company = company_mapping[department.name] - # break - # department = department.parent_id - # else: - # record.yuthon_company = 'thtz' + @api.depends('department_id') + def compute_company(self): + company_mapping = {'天河投资集团': 'thtz', + '天河物管': 'thwg', + '天河粮储': 'thlc', + '天投城建': 'tctj', + '天河投资本部':'thtjbb'} + for record in self: + visited_departments = set() + department = record.department_id + while department and department.id not in visited_departments: + visited_departments.add(department.id) + if department.name == '天河投资集团': + record.yuthon_company = 'thtz' + break + elif department.name in company_mapping: + record.yuthon_company = company_mapping[department.name] + break + department = department.parent_id + else: + record.yuthon_company = 'thtz' diff --git a/soong_workflow/views/soong_user_role_views.xml b/soong_workflow/views/soong_user_role_views.xml index bb08a258f..d8b014798 100644 --- a/soong_workflow/views/soong_user_role_views.xml +++ b/soong_workflow/views/soong_user_role_views.xml @@ -9,7 +9,7 @@ - + diff --git a/yuthon_contract/models/inherit_hr_contract.py b/yuthon_contract/models/inherit_hr_contract.py index 6027f1866..5060dd808 100644 --- a/yuthon_contract/models/inherit_hr_contract.py +++ b/yuthon_contract/models/inherit_hr_contract.py @@ -17,3 +17,7 @@ class HrContract(models.Model): salary.wage = salary.job_lv_id.base_wage salary.name = '劳动合同' + work_entry_source = fields.Selection([ + ('calendar', '考勤安排'), + ('attendance', 'Attendances'), + ('planning', '特殊排版')]) \ No newline at end of file diff --git a/yuthon_contract/views/inherit_hr_contract_views.xml b/yuthon_contract/views/inherit_hr_contract_views.xml index 145b57b8e..452ad4f20 100644 --- a/yuthon_contract/views/inherit_hr_contract_views.xml +++ b/yuthon_contract/views/inherit_hr_contract_views.xml @@ -6,7 +6,7 @@ - + diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index ff2e75baf..58db48c63 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -6,12 +6,12 @@ from odoo.exceptions import ValidationError class HrLeave(models.Model): _inherit = 'hr.leave' - batch_id = fields.Many2one(string='Batch', comodel_name='hr.leave.batch', required=True, ondelete='cascade') + batch_id = fields.Many2one(string='批量', comodel_name='hr.leave.batch', required=True, ondelete='cascade') class HolidaysRequestBatch(models.Model): _name = 'hr.leave.batch' - _description = 'Time Off Batches' + _description = '请假审批' _inherit = ['mail.thread.main.attachment', 'mail.activity.mixin'] def _get_default_emp(self): @@ -20,21 +20,25 @@ class HolidaysRequestBatch(models.Model): raise return emp - name = fields.Char(string='Description') - employee_id = fields.Many2one(string='Employee', comodel_name='hr.employee', required=True, default=_get_default_emp, index=True) - leave_ids = fields.One2many(string='Details', comodel_name='hr.leave', inverse_name='batch_id') - state = fields.Selection(string='State', selection=[ - ('draft', 'To Submit'), - ('confirm', 'To Approve'), - ('refuse', 'Refused'), - ('validate', 'Approved') + name = fields.Char(string='标题') + employee_id = fields.Many2one(string='员工', comodel_name='hr.employee', required=True, default=_get_default_emp, index=True) + leave_ids = fields.One2many(string='详情', comodel_name='hr.leave', inverse_name='batch_id') + state = fields.Selection(string='状态', selection=[ + ('draft', '撤回'), + ('confirm', '转交'), + ('refuse', '拒绝'), + ('validate', '审批') ], default='draft', tracking=True, copy=False) + company_page = fields.Selection([('tz', '天河投资'), ('wg', '天河物管'), ('lc', '天河粮储')], string="公司") + users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id) + leave_id = fields.Many2one('res.users', string="请假人") + department_id = fields.Many2one('hr.department', string="部门") + days = fields.Float(string='天数') + hours = fields.Float(string='小时') + text = fields.Html(string='申请事由') + leave_line_ids = fields.One2many('hr.leave.line', 'leave_batch_id', string="关联请假详情明细行") + is_issues = fields.Boolean(string='是否上会') - @api.constrains('leave_ids') - def _check_leave_ids(self): - for rec in self: - if len(rec.leave_ids) < 1: - raise ValidationError(_('You must have at least one leave request in the batch.')) # 提交 def action_submit(self): @@ -59,3 +63,17 @@ class HolidaysRequestBatch(models.Model): class HrLeaveLine(models.Model): _name = 'hr.leave.line' + leave_batch_id = fields.Many2one('hr.leave.batch', string="关联请假审批") + leave_type_id = fields.Many2one('hr.leave.type',string="请假类型") + available_days = fields.Integer(related='leave_type_id.available_days',string="可用天数") + applicants = fields.Selection(related='leave_type_id.request_unit',string="申请单位") + leave_documents_ids = fields.Many2many(related='leave_type_id.leave_documents_id',string="假期详情说明") + start_time = fields.Date(string="开始时间") + end_time = fields.Date(string="结束时间") + days = fields.Float(string="天数") + residual = fields.Float(string="剩余天数") + # + # @api.onchange('leave_type_id') + # def _onchange_leave_type_id(self): + # if self.leave_type_id: + # self.leave_documents_ids = self.leave_type_id.leave_documents_id diff --git a/yuthon_holiday/models/inherit_hr_leave_type.py b/yuthon_holiday/models/inherit_hr_leave_type.py index 971cecb68..6bc514307 100644 --- a/yuthon_holiday/models/inherit_hr_leave_type.py +++ b/yuthon_holiday/models/inherit_hr_leave_type.py @@ -6,4 +6,5 @@ class HrLeaveType(models.Model): _inherit = 'hr.leave.type' leave_documents_id = fields.Many2many('ir.attachment', string="假期详细说明") + available_days = fields.Integer(string="可用天数") allocation_validation_type = fields.Selection(defalt='no') \ No newline at end of file diff --git a/yuthon_holiday/security/ir.model.access.csv b/yuthon_holiday/security/ir.model.access.csv index f4129e1d0..d3e6ee678 100644 --- a/yuthon_holiday/security/ir.model.access.csv +++ b/yuthon_holiday/security/ir.model.access.csv @@ -1,2 +1,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_hr_leave_batch,hr.leave.batch,model_hr_leave_batch,,1,1,1,1 +access_hr_leave_line,hr.leave.line,model_hr_leave_line,,1,1,1,1 \ No newline at end of file diff --git a/yuthon_holiday/views/hr_leave_batch.xml b/yuthon_holiday/views/hr_leave_batch.xml index 2a299707d..dadabf6b7 100644 --- a/yuthon_holiday/views/hr_leave_batch.xml +++ b/yuthon_holiday/views/hr_leave_batch.xml @@ -6,14 +6,19 @@ hr.leave.batch.tree hr.leave.batch - - + + - + + + + + + -