From 76f72733de7e6be51f144c60bfe00a11c23c3d55 Mon Sep 17 00:00:00 2001 From: zhouzhou <123@qq.com> Date: Wed, 11 Dec 2024 19:50:24 +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/__init__.py | 3 +- yuthon_contract/__manifest__.py | 1 + yuthon_contract/models/inherit_hr_contract.py | 12 ++++- yuthon_contract/security/ir.model.access.csv | 1 + .../views/inherit_hr_contract_views.xml | 9 +++- yuthon_contract/wizard/__init__.py | 1 + .../wizard/yuthon_contract_wizard.py | 44 +++++++++++++++++++ .../wizard/yuthon_contract_wizard_views.xml | 25 +++++++++++ yuthon_holiday/__manifest__.py | 5 +++ yuthon_holiday/models/inherit_hr_leave.py | 4 ++ .../static/scss/yuthon_leave_scss.scss | 12 +++++ yuthon_holiday/views/hr_leave_batch.xml | 8 ++-- .../models/yuthon_duty_plan.py | 10 ----- yuthon_hr_employee/models/inherit_hr_job.py | 11 +++-- .../views/yuthon_hr_employee_views.xml | 2 +- 15 files changed, 127 insertions(+), 21 deletions(-) create mode 100644 yuthon_contract/wizard/__init__.py create mode 100644 yuthon_contract/wizard/yuthon_contract_wizard.py create mode 100644 yuthon_contract/wizard/yuthon_contract_wizard_views.xml create mode 100644 yuthon_holiday/static/scss/yuthon_leave_scss.scss diff --git a/yuthon_contract/__init__.py b/yuthon_contract/__init__.py index 9a7e03ede..c536983e2 100644 --- a/yuthon_contract/__init__.py +++ b/yuthon_contract/__init__.py @@ -1 +1,2 @@ -from . import models \ No newline at end of file +from . import models +from . import wizard \ No newline at end of file diff --git a/yuthon_contract/__manifest__.py b/yuthon_contract/__manifest__.py index 16fb89baf..cf2d0b841 100644 --- a/yuthon_contract/__manifest__.py +++ b/yuthon_contract/__manifest__.py @@ -14,6 +14,7 @@ 'data': [ 'security/ir.model.access.csv', 'data/contract_code_data.xml', + 'wizard/yuthon_contract_wizard_views.xml', 'views/inherit_hr_contract_views.xml', ], 'installable': True, diff --git a/yuthon_contract/models/inherit_hr_contract.py b/yuthon_contract/models/inherit_hr_contract.py index b12bdb866..c764d5164 100644 --- a/yuthon_contract/models/inherit_hr_contract.py +++ b/yuthon_contract/models/inherit_hr_contract.py @@ -48,4 +48,14 @@ class HrContract(models.Model): wage_id = self.env['hr.salary.rule'].search([('struct_id.name', '=', record.structure_type_id.name), ('yuthon_company','=', record.yuthon_company), ('name', '=','基本工资')]) if wage_id: - record.wage = wage_id.amount_fix \ No newline at end of file + record.wage = wage_id.amount_fix + + def action_hr_contract(self): + return { + "type": "ir.actions.act_window", + "name": "批量导入合同", + "res_model": "yuthon.contract.wizard", + "view_mode": "form", + "target": "new", + } + diff --git a/yuthon_contract/security/ir.model.access.csv b/yuthon_contract/security/ir.model.access.csv index 0b7f9c7bc..a41277ec0 100644 --- a/yuthon_contract/security/ir.model.access.csv +++ b/yuthon_contract/security/ir.model.access.csv @@ -1,4 +1,5 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_yuthon_contract_wizard,yuthon.contract.wizard,model_yuthon_contract_wizard,,1,1,1,1 diff --git a/yuthon_contract/views/inherit_hr_contract_views.xml b/yuthon_contract/views/inherit_hr_contract_views.xml index 45fd9b3a9..87718dbdc 100644 --- a/yuthon_contract/views/inherit_hr_contract_views.xml +++ b/yuthon_contract/views/inherit_hr_contract_views.xml @@ -66,7 +66,7 @@ - + @@ -74,4 +74,11 @@ + + 批量导入合同 + + + code + action = model.action_hr_contract() + diff --git a/yuthon_contract/wizard/__init__.py b/yuthon_contract/wizard/__init__.py new file mode 100644 index 000000000..78a16fb34 --- /dev/null +++ b/yuthon_contract/wizard/__init__.py @@ -0,0 +1 @@ +from . import yuthon_contract_wizard diff --git a/yuthon_contract/wizard/yuthon_contract_wizard.py b/yuthon_contract/wizard/yuthon_contract_wizard.py new file mode 100644 index 000000000..9f888e425 --- /dev/null +++ b/yuthon_contract/wizard/yuthon_contract_wizard.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +from odoo import models, fields, api, _, SUPERUSER_ID +from odoo.exceptions import ValidationError, UserError +import xlrd +import base64 +import datetime +from datetime import datetime + + +class YuthonContractWizard(models.Model): + _name = 'yuthon.contract.wizard' + + excel_file = fields.Binary(string="上传Excel表") + excel_name = fields.Char(string="文件名") + + def confirm(self): + """ + 导入excel文件,按行读取数据并处理 + :return: 导入员工信息表并更新 + """ + if not self.excel_file: + raise ValidationError('请上传文件。') + book = xlrd.open_workbook(file_contents=base64.decodebytes(self.excel_file)) + sh = book.sheet_by_index(0) + for rx in range(1, sh.nrows): + row = sh.row(rx) + self.employee_contract_data(row) + + def employee_contract_data(self,row): + employee_id = self.env['hr.employee'].search([('name', '=', row[1].value)]) + structure_type_id = self.env['hr.payroll.structure.type'].search([('name', '=', row[4].value), ('yuthon_company', '=', 'thwg')]) + party_id = self.env['yuthon.party.setting'].search([('party', '=', row[5].value)]) + contract_type_id = self.env['hr.contract.type'].search([('name', '=', row[6].value)]) + wage_id = self.env['hr.salary.rule'].search([('struct_id.name', '=', structure_type_id.name), + ('yuthon_company', '=', 'thwg'), + ('name', '=', '基本工资')]) + wage = wage_id.amount_fix + self.env['hr.contract'].create({ + 'employee_id': employee_id.id, + 'structure_type_id':structure_type_id.id, + 'party_id':party_id.id, + 'contract_type_id':contract_type_id.id, + 'wage':wage + }) diff --git a/yuthon_contract/wizard/yuthon_contract_wizard_views.xml b/yuthon_contract/wizard/yuthon_contract_wizard_views.xml new file mode 100644 index 000000000..d3dcbd005 --- /dev/null +++ b/yuthon_contract/wizard/yuthon_contract_wizard_views.xml @@ -0,0 +1,25 @@ + + + + 审批意见弹窗 + yuthon.contract.wizard + +
+ + + + + + + + + + + +
+
+
+
\ No newline at end of file diff --git a/yuthon_holiday/__manifest__.py b/yuthon_holiday/__manifest__.py index dbfb90e32..8853092c1 100644 --- a/yuthon_holiday/__manifest__.py +++ b/yuthon_holiday/__manifest__.py @@ -16,6 +16,11 @@ 'views/hr_leave_batch.xml', 'wizard/yuthon_fixes_wizard_views.xml', ], + 'assets': { + 'web.assets_backend': [ + 'yuthon_holiday/static/scss/yuthon_leave_scss.scss', + ], + }, 'demo': [], 'depends': ['hr_holidays', 'planning', 'hr', 'yuthon_hr_employee', 'base', 'yuthon_issue', 'documents', 'mail', 'soong_workflow'], 'installable': True, diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index 6d188eba6..590e6c04d 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -46,6 +46,8 @@ class HolidaysRequestBatch(models.Model): name = fields.Char(string='标题') employee_id = fields.Many2one(string='员工', comodel_name='hr.employee', required=True, default=_get_default_emp, index=True) + yuthon_company = fields.Selection([('thtz', '天河投资集团'), ('thwg', '天河物管'), + ('thlc', '天河粮储')], string="所属公司", related='employee_id.yuthon_company') state = fields.Selection(string='状态', selection=[ ('draft', '撤回'), ('confirm', '转交'), @@ -112,6 +114,8 @@ class HrLeaveLine(models.Model): leave_batch_id = fields.Many2one('hr.leave.batch', string="关联请假审批") employee_id = fields.Many2one(string='员工', comodel_name='hr.employee', related='leave_batch_id.employee_id') + start_unit = fields.Selection([('day', '上半天'),('hour', '下半天')], string='单位') + end_unit = fields.Selection([('day', '上半天'),('hour', '下半天')], string='单位') leave_type_id = fields.Many2one( string="请假类型", comodel_name='hr.leave.type', diff --git a/yuthon_holiday/static/scss/yuthon_leave_scss.scss b/yuthon_holiday/static/scss/yuthon_leave_scss.scss new file mode 100644 index 000000000..d1ae714fb --- /dev/null +++ b/yuthon_holiday/static/scss/yuthon_leave_scss.scss @@ -0,0 +1,12 @@ +.list_width{ + width: 200px !important; + max-width: 200px !important; +} +.list_width2{ + width: 100px !important; + max-width: 100px !important; +} +.list_ids_width{ + width: 200px !important; + max-width: 200px !important; +} \ 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 2bdcbc1ce..044f23680 100644 --- a/yuthon_holiday/views/hr_leave_batch.xml +++ b/yuthon_holiday/views/hr_leave_batch.xml @@ -56,7 +56,7 @@ - - - + + + + diff --git a/yuthon_hr_attendance/models/yuthon_duty_plan.py b/yuthon_hr_attendance/models/yuthon_duty_plan.py index 702839cd1..122e0e3dd 100644 --- a/yuthon_hr_attendance/models/yuthon_duty_plan.py +++ b/yuthon_hr_attendance/models/yuthon_duty_plan.py @@ -17,7 +17,6 @@ class YuthonDutyPlan(models.Model): def auto_duty_plan(self): role_a = self.env['planning.role'].search([('name', '=', '联安粮库')], limit=1) role_template_a = self.env['planning.slot.template'].search([('planning_name', '=', '白班'), ('role_id', '=', role_a.id)]) - role_template_b = self.env['planning.slot.template'].search([('planning_name', '=', '值班'), ('role_id', '=', role_a.id)]) today = datetime.today().date() first_day_of_month = today.replace(day=1) if today.month < 12: @@ -31,15 +30,6 @@ class YuthonDutyPlan(models.Model): while current_date <= last_day_of_month: self.create_planning_slot(employee, role_a, role_template_a, current_date) current_date += timedelta(days=1) - - current_date = first_day_of_month - for line in self.plan_line_ids.sorted('sequence'): - for employee in line.employee_ids: - - self.create_planning_slot(employee, role_a, role_template_b, current_date) - current_date += timedelta(days=1) - - return { 'type': 'ir.actions.client', 'tag': 'display_notification', diff --git a/yuthon_hr_employee/models/inherit_hr_job.py b/yuthon_hr_employee/models/inherit_hr_job.py index 85630d0ac..b2f4bae7c 100644 --- a/yuthon_hr_employee/models/inherit_hr_job.py +++ b/yuthon_hr_employee/models/inherit_hr_job.py @@ -95,11 +95,14 @@ class HrJob(models.Model): if department_id: job.sudo().write({'department_id': department_id.id if len(department_id) == 1 else department_id[0].id}) - # @api.onchange('job_personnel_ids') - # def _onchange_job_personnel_ids(self): - # for employee in self.job_personnel_ids: - # employee.job_id = self.id + @api.onchange('department_id') + def onchange_department_id(self): + company_mapping = { + '天河投资集团':'thtz' , '天河物管': 'thwg', '天河粮储':'thlc', '集团本部': 'thtjbb' + } + yuthon_company = company_mapping.get(self.department_id.parent_id.name) + self.yuthon_company = yuthon_company class HrJobType(models.Model): _name = "hr.job.type" diff --git a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml index f0be4f43c..bbd1f978d 100644 --- a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml +++ b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml @@ -19,7 +19,7 @@ - +