From ba78bb040b2905fcb4c051cc39f7ce2ec30292a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Mon, 7 Sep 2026 15:09:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E4=B9=A0=E7=94=9F=E5=A2=9E=E5=91=98?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_catering/controllers/restaurant.py | 56 ++++++- .../views/inherit_hr_job_views.xml | 2 +- yuthon_hr_employee_approval/__manifest__.py | 3 + .../data/process_code_data.xml | 7 + .../models/__init__.py | 3 +- .../models/yuthon_intern_increment.py | 45 ++++++ .../report/yuthon_intern_increment_report.xml | 20 +++ ...thon_intern_increment_report_templates.xml | 140 ++++++++++++++++++ .../security/ir.model.access.csv | 1 + .../views/menuitem.xml | 8 +- .../views/yuthon_intern_increment_views.xml | 99 +++++++++++++ yuthon_work_brand/views/hr_menus.xml | 5 + 12 files changed, 381 insertions(+), 8 deletions(-) create mode 100644 yuthon_hr_employee_approval/models/yuthon_intern_increment.py create mode 100644 yuthon_hr_employee_approval/report/yuthon_intern_increment_report.xml create mode 100644 yuthon_hr_employee_approval/report/yuthon_intern_increment_report_templates.xml create mode 100644 yuthon_hr_employee_approval/views/yuthon_intern_increment_views.xml diff --git a/yuthon_catering/controllers/restaurant.py b/yuthon_catering/controllers/restaurant.py index ba49ca1b1..7189883b2 100644 --- a/yuthon_catering/controllers/restaurant.py +++ b/yuthon_catering/controllers/restaurant.py @@ -106,7 +106,7 @@ class RestaurantController(Controller): def get_catering(self, **kwargs): user_id = int(kwargs.get('user_id')) menu_date = kwargs.get('menu_date', date.today()) - menu_id = int(kwargs.get('menu_id')) + menu_id = kwargs.get('menu_id') if not user_id or not menu_date or not menu_id: return json.dumps({'data': '', 'code': 500, 'message': '请求失败'}) @@ -124,11 +124,63 @@ class RestaurantController(Controller): 'menu_id': catering.menu_day_id.id, 'breakfast': catering.breakfast, 'lunch': catering.lunch, - 'state': catering.state + 'state': catering.state, + 'is_expatriate': False, } return json.dumps({'data': catering_data, 'code': 200, 'message': ''}) + + # 没有用餐记录时,判断当前员工是否处于外派期间; + # 若处于外派期间,默认早餐和午餐均为不就餐(False)。 + is_expatriate = self._check_expatriation(employee, menu_date) + if is_expatriate: + catering_data = { + 'id': 0, + 'user_id': employee.user_id.id, + 'menu_id': int(menu_id), + 'breakfast': False, + 'lunch': False, + 'state': 'unconfirmed', + 'is_expatriate': True, + } + return json.dumps({'data': catering_data, 'code': 200, 'message': ''}) + return json.dumps({'data': '', 'code': 200, 'message': '没有查询到数据'}) + def _check_expatriation(self, employee, menu_date): + """判断员工在指定日期是否处于外派期间。 + + 规则: + 1. 存在审批结束且未作废、未失效、未结束的外派审批记录,员工在 expatriates_ids 中; + 2. 外派开始日期 <= 当前日期; + 3. 已填写返回日期时,当前日期 <= 返回日期; + 4. 未填写返回日期时,从外派开始日期起即视为外派中。 + """ + if not employee: + return False + WorkflowRecord = request.env['soong.workflow.record'].sudo() + # 先找出审批结束且未作废的外派审批单 ID + workflow_records = WorkflowRecord.search([ + ('res_model', '=', 'expatriation.approval'), + ('approve_state', '=', 'end'), + ('reclaim_state', '=', False), + ]) + expatriation_ids = workflow_records.mapped('res_id') + if not expatriation_ids: + return False + Expatriation = request.env['expatriation.approval'].sudo() + domain = [ + ('id', 'in', expatriation_ids), + ('expatriates_ids', 'in', [employee.id]), + ('start_date', '!=', False), + ('start_date', '<=', menu_date), + ('is_effect', '=', False), + ('work_end', '=', False), + '|', + ('return_date', '=', False), + ('return_date', '>=', menu_date), + ] + return bool(Expatriation.search(domain, limit=1)) + @route('/phone/restaurant/get_catering_statistics', methods=['POST'], type='http', auth="none", csrf=False, cors='*') @exception_handle def get_catering_statistics(self, **kwargs): diff --git a/yuthon_hr_employee/views/inherit_hr_job_views.xml b/yuthon_hr_employee/views/inherit_hr_job_views.xml index 845d9b0d1..312856978 100644 --- a/yuthon_hr_employee/views/inherit_hr_job_views.xml +++ b/yuthon_hr_employee/views/inherit_hr_job_views.xml @@ -82,7 +82,7 @@ 1 - + diff --git a/yuthon_hr_employee_approval/__manifest__.py b/yuthon_hr_employee_approval/__manifest__.py index 6c34c0f0e..e3ff30809 100644 --- a/yuthon_hr_employee_approval/__manifest__.py +++ b/yuthon_hr_employee_approval/__manifest__.py @@ -50,6 +50,7 @@ 'views/yuthon_appointment_approval_views.xml', 'views/yuthon_transfer_approval_views.xml', 'views/yuthon_social_files_approval_view.xml', + 'views/yuthon_intern_increment_views.xml', 'views/website_employee_views.xml', 'views/menuitem.xml', @@ -63,6 +64,8 @@ 'report/renewal_approval_template.xml', 'report/service_approval_report.xml', 'report/service_approval_report_templates.xml', + 'report/yuthon_intern_increment_report.xml', + 'report/yuthon_intern_increment_report_templates.xml', 'wizard/yuthon_website_employee_wizard.xml', 'wizard/interview_approval_wizard.xml', diff --git a/yuthon_hr_employee_approval/data/process_code_data.xml b/yuthon_hr_employee_approval/data/process_code_data.xml index 343127c40..aaf3d24d4 100644 --- a/yuthon_hr_employee_approval/data/process_code_data.xml +++ b/yuthon_hr_employee_approval/data/process_code_data.xml @@ -168,4 +168,11 @@ 3 + + 实习生增员申请表-编号 + yuthon_intern_increment_code + SX%(y)s%(month)s%(day)s + 3 + + diff --git a/yuthon_hr_employee_approval/models/__init__.py b/yuthon_hr_employee_approval/models/__init__.py index 900eecc9f..93e5a69f7 100644 --- a/yuthon_hr_employee_approval/models/__init__.py +++ b/yuthon_hr_employee_approval/models/__init__.py @@ -28,4 +28,5 @@ from . import yuthon_renewal_approval from . import contract_review_approval from . import yuthon_employee_add from . import yuthon_pre_examination -from . import yuthon_employee_setting \ No newline at end of file +from . import yuthon_employee_setting +from . import yuthon_intern_increment \ No newline at end of file diff --git a/yuthon_hr_employee_approval/models/yuthon_intern_increment.py b/yuthon_hr_employee_approval/models/yuthon_intern_increment.py new file mode 100644 index 000000000..3446afb89 --- /dev/null +++ b/yuthon_hr_employee_approval/models/yuthon_intern_increment.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# 实习生增员申请表模型 +from odoo import models, fields, api + + +class YuthonInternIncrement(models.Model): + _name = 'yuthon.intern.increment' + _description = '实习生增员申请表' + _inherit = ['soong.workflow.mixin', 'mail.thread.main.attachment', 'mail.activity.mixin'] + + code = fields.Char(string='编号', + default=lambda self: self.env['ir.sequence'].next_by_code('yuthon_intern_increment_code')) + name = fields.Char(string='标题') + users_id = fields.Many2one('res.users', string='申请人', default=lambda self: self.env.user.id) + department_id = fields.Many2one(related='users_id.employee_id.department_id', string='申请部门') + company_id = fields.Many2one(related='users_id.employee_id.company_id', string='公司') + application_date = fields.Date(string='申请日期', default=fields.Date.today) + intern_position = fields.Char(string='实习岗位') + current_staff_count = fields.Integer(string='部门现有人数') + increment_count = fields.Integer(string='拟增员人数') + planned_report_date = fields.Date(string='计划报到日期') + increment_reason = fields.Text(string='增员理由') + job_content = fields.Text(string='工作内容(主要职责)') + qualifications = fields.Text(string='任职资格(学历、专业、资质及相关要求)') + dept_manager_opinion = fields.Text(string='申请部门经理意见') + hr_opinion = fields.Text(string='综合办公室意见') + management_opinion = fields.Text(string='经营班子审批意见') + documents_ids = fields.Many2many('ir.attachment', string='附件') + work_end = fields.Boolean(string='结束') + active = fields.Boolean('Active', default=True, tracking=True) + urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], + string='紧急度', default='normal') + + def _get_default_name_title(self): + return self._description if self._description else self._name + + name_title = fields.Char(default=_get_default_name_title) + self_users_ids = fields.Many2many('res.users', string='当前经办人', + default=lambda self: [(6, 0, [self.env.user.id])]) + + def action_print_intern_increment(self): + """打印实习生增员申请表""" + self.ensure_one() + report_ref = self.env.ref('yuthon_hr_employee_approval.action_intern_increment_report') + return report_ref.report_action(self.id) diff --git a/yuthon_hr_employee_approval/report/yuthon_intern_increment_report.xml b/yuthon_hr_employee_approval/report/yuthon_intern_increment_report.xml new file mode 100644 index 000000000..1f0ce21b0 --- /dev/null +++ b/yuthon_hr_employee_approval/report/yuthon_intern_increment_report.xml @@ -0,0 +1,20 @@ + + + + + + + 实习生增员申请表 + + yuthon.intern.increment + qweb-pdf + yuthon_hr_employee_approval.intern_increment_report_document + yuthon_hr_employee_approval.intern_increment_report_document + + + report + + '实习生增员申请表_%s_%s_%s' % (object.name or '', object.users_id.name or '', ((object.log_ids.filtered(lambda l: l.name == '归档')[-1].lase_click_date or object.log_ids.filtered(lambda l: l.name == '归档')[-1].date_create).strftime('%Y-%m-%d') if object.log_ids.filtered(lambda l: l.name == '归档') else '')) + + + diff --git a/yuthon_hr_employee_approval/report/yuthon_intern_increment_report_templates.xml b/yuthon_hr_employee_approval/report/yuthon_intern_increment_report_templates.xml new file mode 100644 index 000000000..428b40d7b --- /dev/null +++ b/yuthon_hr_employee_approval/report/yuthon_intern_increment_report_templates.xml @@ -0,0 +1,140 @@ + + + + + + + diff --git a/yuthon_hr_employee_approval/security/ir.model.access.csv b/yuthon_hr_employee_approval/security/ir.model.access.csv index b1490c749..7d4fbf91f 100644 --- a/yuthon_hr_employee_approval/security/ir.model.access.csv +++ b/yuthon_hr_employee_approval/security/ir.model.access.csv @@ -56,6 +56,7 @@ access_contract_review_approval,contract_review_approval,model_contract_review_a access_awards_line, awards_line,model_awards_line,base.group_user,1,1,1,1 access_yuthon_employee_add,yuthon_employee_add,model_yuthon_employee_add,base.group_user,1,1,1,1 access_yuthon_pre_examination,yuthon_pre_examination,model_yuthon_pre_examination,base.group_user,1,1,1,1 +access_yuthon_intern_increment,yuthon_intern_increment,model_yuthon_intern_increment,base.group_user,1,1,1,1 access_yuthon_service_type,yuthon_service_type,model_yuthon_service_type,base.group_user,1,1,1,1 access_yuthon_contract_type,yuthon_contract_type,model_yuthon_contract_type,base.group_user,1,1,1,1 access_leaving_salary_line,leaving_salary_line,model_leaving_salary_line,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/yuthon_hr_employee_approval/views/menuitem.xml b/yuthon_hr_employee_approval/views/menuitem.xml index b12a5cda6..765c915a9 100644 --- a/yuthon_hr_employee_approval/views/menuitem.xml +++ b/yuthon_hr_employee_approval/views/menuitem.xml @@ -8,10 +8,10 @@ parent="hr_recruitment.menu_hr_recruitment_root" sequence="7"/> + name="招聘需求申请表" + parent="hr_process_work_job" + action="yuthon_recruitment_approval_action" + sequence="1"/> + + + yuthon.intern.increment.tree + yuthon.intern.increment + + + + + + + + + + + + + + + + yuthon.intern.increment.form + yuthon.intern.increment + +
+
+ +
+ + + + + + + + + + + +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + 实习生增员申请表 + yuthon.intern.increment + tree,form + +
diff --git a/yuthon_work_brand/views/hr_menus.xml b/yuthon_work_brand/views/hr_menus.xml index cf1e00962..f48f1c1c1 100644 --- a/yuthon_work_brand/views/hr_menus.xml +++ b/yuthon_work_brand/views/hr_menus.xml @@ -65,6 +65,11 @@ parent="hr_menu_recruitment_process" action="yuthon_hr_employee_approval.yuthon_recruitment_approval_action" sequence="1"/> +