diff --git a/planning_gantt/static/src/js/planning_gantt_renderer.js b/planning_gantt/static/src/js/planning_gantt_renderer.js index 4296afd33..9604dfb8a 100644 --- a/planning_gantt/static/src/js/planning_gantt_renderer.js +++ b/planning_gantt/static/src/js/planning_gantt_renderer.js @@ -145,6 +145,8 @@ patch(PlanningGanttRenderer.prototype, { display_name: {}, start_time: {}, end_time: {}, + end_time2: {}, + day2: {}, }, }, } @@ -181,8 +183,10 @@ patch(PlanningGanttRenderer.prototype, { const groupSlotTemplate = slotTemplateData[group.id]; group.start_time = groupSlotTemplate?.start_time || 0; group.end_time = groupSlotTemplate?.end_time || 0; + group.end_time2 = groupSlotTemplate?.end_time2 || 0; + group.day2 = groupSlotTemplate?.day2 || ''; // 拼接显示信息 - group.ganttLegend = `${groupSlotTemplate.display_name} : ${floatToTime(group.start_time)} - ${floatToTime(group.end_time)}`; + group.ganttLegend = `${groupSlotTemplate.display_name} : ${floatToTime(group.start_time)} - ${floatToTime(group.day2)} ${floatToTime(group.end_time2)}`; }); }, diff --git a/yuthon_hr_attendance/__manifest__.py b/yuthon_hr_attendance/__manifest__.py index 678803ddf..7fc5fb6b2 100644 --- a/yuthon_hr_attendance/__manifest__.py +++ b/yuthon_hr_attendance/__manifest__.py @@ -16,7 +16,6 @@ 'soong_workflow', 'yuthon_issue', 'planning', 'calendar', 'web_gantt', 'yuthon_wechat'], 'data': [ 'security/ir.model.access.csv', - 'security/attendance_security_group.xml', 'data/hr_attendance_time.xml', 'data/attendance_code_data.xml', 'data/attendance_role_groups_data.xml', diff --git a/yuthon_hr_attendance/models/inherit_planning_role.py b/yuthon_hr_attendance/models/inherit_planning_role.py index 01be42617..8c4720fd2 100644 --- a/yuthon_hr_attendance/models/inherit_planning_role.py +++ b/yuthon_hr_attendance/models/inherit_planning_role.py @@ -30,6 +30,8 @@ class PlanningSlotTemplate(models.Model): _inherit = 'planning.slot.template' department_id = fields.Many2one('hr.department', string="部门") + day2 = fields.Char(string="次日") + end_time2 = fields.Float(string="显示时间") class InheritPlanningSlot(models.Model): diff --git a/yuthon_hr_attendance/models/planning_template_inherit.py b/yuthon_hr_attendance/models/planning_template_inherit.py index b79126be9..6d0b2b521 100644 --- a/yuthon_hr_attendance/models/planning_template_inherit.py +++ b/yuthon_hr_attendance/models/planning_template_inherit.py @@ -34,7 +34,6 @@ class PlanningTemplate(models.Model): end_time = time(hour=int(rec.end_time), minute=round(math.modf(rec.end_time)[0] / (1 / 60.0))) # 计算结束日期 end_datetime = start_datetime + timedelta(hours=rec.duration) - # 检查是否跨日 is_next_day = end_datetime.date() > start_datetime.date() if is_next_day: @@ -51,11 +50,18 @@ class PlanningTemplate(models.Model): duration_days = math.ceil((end_datetime - start_datetime).total_seconds() / (3600 * 24)) return duration_days, timedelta(hours=end_datetime.hour, minutes=end_datetime.minute).total_seconds() / 3600 - @api.depends("planning_name") - def _compute_display_name(self): - super()._compute_display_name() - for record in self: - record.display_name = f"{record.role_id.name}-{record.planning_name}" + # @api.depends("planning_name") + # def _compute_display_name(self): + # super()._compute_display_name() + # for record in self: + # if record.planning_name and record.role_id: + # record.display_name = f"{record.role_id.name}-{record.planning_name}" + # elif record.planning_name: + # record.display_name = record.planning_name + # elif record.role_id: + # record.display_name = record.role_id.name + # else: + # record.display_name = "Unknown" class Planning(models.Model): diff --git a/yuthon_hr_attendance/models/yuthon_duty_plan.py b/yuthon_hr_attendance/models/yuthon_duty_plan.py index fb4f31b04..0e4cc99fe 100644 --- a/yuthon_hr_attendance/models/yuthon_duty_plan.py +++ b/yuthon_hr_attendance/models/yuthon_duty_plan.py @@ -29,6 +29,13 @@ class YuthonDutyPlan(models.Model): next_month = (selected_month % 12) + 1 next_year = year + (1 if next_month == 1 else 0) # 如果是12月,年份加1 last_day_of_month = datetime(next_year, next_month, 1)- timedelta(days=1) + existing_slots = self.env['planning.slot'].search([ + ('department_id.name', '=', '综合班'), + ('start_datetime', '>=', first_day_of_month), + ('start_datetime', '<=', last_day_of_month), + ]) + if len(existing_slots) > 0: + raise UserError(f"该月已经有排程,请选择其他时间。") else: next_month = (selected_month % 12) + 1 next_year = year + (1 if next_month == 1 else 0) @@ -36,6 +43,13 @@ class YuthonDutyPlan(models.Model): next_next_month = (next_month % 12) + 1 next_next_year = next_year + (1 if next_next_month == 1 else 0) last_day_of_month = datetime(next_next_year, next_next_month, 1)- timedelta(days=1) + existing_slots = self.env['planning.slot'].search([ + ('role_id.name', '=', '联安粮库'), + ('start_datetime', '>=', first_day_of_month), + ('start_datetime', '<=', last_day_of_month), + ]) + if len(existing_slots) > 0: + raise UserError(f"该月已经有排程,请选择其他时间。") 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)]) diff --git a/yuthon_hr_attendance/models/yuthon_run_planning.py b/yuthon_hr_attendance/models/yuthon_run_planning.py index 8d03c9d79..f42196826 100644 --- a/yuthon_hr_attendance/models/yuthon_run_planning.py +++ b/yuthon_hr_attendance/models/yuthon_run_planning.py @@ -29,6 +29,13 @@ class YuthonRunPlanning(models.Model): next_month = (selected_month % 12) + 1 next_year = year + (1 if next_month == 1 else 0) last_day_of_month = datetime(next_year, next_month, 1) - timedelta(days=1) + existing_slots = self.env['planning.slot'].search([ + ('department_id.name', '=', '运行班'), + ('start_datetime', '>=', first_day_of_month), + ('start_datetime', '<=', last_day_of_month), + ]) + if len(existing_slots) > 0: + raise UserError(f"该月已经有排程,请选择其他时间。") else: next_month = (selected_month % 12) + 1 next_year = year + (1 if next_month == 1 else 0) @@ -36,6 +43,13 @@ class YuthonRunPlanning(models.Model): next_next_month = (next_month % 12) + 1 next_next_year = next_year + (1 if next_next_month == 1 else 0) last_day_of_month = datetime(next_next_year, next_next_month, 1) - timedelta(days=1) + existing_slots = self.env['planning.slot'].search([ + ('department_id.name', '=', '运行班'), + ('start_datetime', '>=', first_day_of_month), + ('start_datetime', '<=', last_day_of_month), + ]) + if len(existing_slots) > 0: + raise UserError(f"该月已经有排程,请选择其他时间。") role_a = self.env['planning.role'].search([('name', '=', '工程部')], limit=1) start_time = int(self.env['planning.slot.template'].search([('role_id', '=', role_a.id), ('planning_name', '=', '白班')]).start_time) @@ -68,7 +82,7 @@ class YuthonRunPlanning(models.Model): slot_id[i].write({ 'template_id': self.env['planning.slot.template'].search([('role_id', '=', role_a.id), ('planning_name', '=', '中夜')]).id, 'start_datetime': datetime(current_date.year, current_date.month, current_date.day,start_time2) + timedelta(hours=16) - timedelta(days=1), - 'end_datetime': datetime(current_date.year, current_date.month, current_date.day,end_time2) + timedelta(days=1, hours=16) - timedelta(days=1), + 'end_datetime': datetime(current_date.year, current_date.month, current_date.day,end_time2) + timedelta(hours=16) - timedelta(days=1), 'role_id': role_a.id, 'allocated_hours': 8, }) @@ -130,6 +144,13 @@ class YuthonRunPlanning(models.Model): next_month = (selected_month % 12) + 1 next_year = year + (1 if next_month == 1 else 0) # 如果是12月,年份加1 last_day_of_month = datetime(next_year, next_month, 1) - timedelta(days=1) + existing_slots = self.env['planning.slot'].search([ + ('department_id.name', '=', '高压班'), + ('start_datetime', '>=', first_day_of_month), + ('start_datetime', '<=', last_day_of_month), + ]) + if len(existing_slots) > 0: + raise UserError(f"该月已经有排程,请选择其他时间。") else: next_month = (selected_month % 12) + 1 next_year = year + (1 if next_month == 1 else 0) @@ -137,7 +158,13 @@ class YuthonRunPlanning(models.Model): next_next_month = (next_month % 12) + 1 next_next_year = next_year + (1 if next_next_month == 1 else 0) last_day_of_month = datetime(next_next_year, next_next_month, 1) - timedelta(days=1) - + existing_slots = self.env['planning.slot'].search([ + ('department_id.name', '=', '高压班'), + ('start_datetime', '>=', first_day_of_month), + ('start_datetime', '<=', last_day_of_month), + ]) + if len(existing_slots) > 0: + raise UserError(f"该月已经有排程,请选择其他时间。") role_a = self.env['planning.role'].search([('name', '=', '工程部')], limit=1) start_time = int(self.env['planning.slot.template'].search([('role_id', '=', role_a.id), ('planning_name', '=', '白班')]).start_time) end_time = int(self.env['planning.slot.template'].search([('role_id', '=', role_a.id), ('planning_name', '=', '白班')]).end_time) @@ -164,13 +191,13 @@ class YuthonRunPlanning(models.Model): while current_date <= last_day_of_month: for employee in range(0, len(self.high_run_ids)): i = i + 1 - slot_id = all_slot.search([('resource_id', '=', self.engineering_run_ids[employee].employee_id.resource_id.id), ('start_datetime', '>=', first_day_of_month), ('start_datetime', '<=', last_day_of_month)]).sorted('start_datetime') + slot_id = all_slot.search([('resource_id', '=', self.high_run_ids[employee].employee_id.resource_id.id), ('start_datetime', '>=', first_day_of_month), ('start_datetime', '<=', last_day_of_month)]).sorted('start_datetime') if i < 31: slot_id[i].write({ 'template_id': self.env['planning.slot.template'].search( [('role_id', '=', role_a.id), ('planning_name', '=', '中夜')]).id, 'start_datetime': datetime(current_date.year, current_date.month, current_date.day,start_time2) + timedelta(hours=16) - timedelta(days=1), - 'end_datetime': datetime(current_date.year, current_date.month, current_date.day,end_time2) + timedelta(days=1, hours=16) - timedelta(days=1), + 'end_datetime': datetime(current_date.year, current_date.month, current_date.day,end_time2) + timedelta(hours=16) - timedelta(days=1), 'role_id': role_a.id, 'allocated_hours': 8, }) @@ -205,6 +232,13 @@ class YuthonRunPlanning(models.Model): next_month = (selected_month % 12) + 1 next_year = year + (1 if next_month == 1 else 0) # 如果是12月,年份加1 last_day_of_month = datetime(next_year, next_month, 1)- timedelta(days=1) + existing_slots = self.env['planning.slot'].search([ + ('department_id.name', '=', '综合班'), + ('start_datetime', '>=', first_day_of_month), + ('start_datetime', '<=', last_day_of_month), + ]) + if len(existing_slots) > 0: + raise UserError(f"该月已经有排程,请选择其他时间。") else: next_month = (selected_month % 12) + 1 next_year = year + (1 if next_month == 1 else 0) @@ -212,6 +246,13 @@ class YuthonRunPlanning(models.Model): next_next_month = (next_month % 12) + 1 next_next_year = next_year + (1 if next_next_month == 1 else 0) last_day_of_month = datetime(next_next_year, next_next_month, 1)- timedelta(days=1) + existing_slots = self.env['planning.slot'].search([ + ('department_id.name', '=', '综合班'), + ('start_datetime', '>=', first_day_of_month), + ('start_datetime', '<=', last_day_of_month), + ]) + if len(existing_slots) > 0: + raise UserError(f"该月已经有排程,请选择其他时间。") role_a = self.env['planning.role'].search([('name', '=', '工程部')], limit=1) start_time = int(self.env['planning.slot.template'].search( @@ -247,13 +288,13 @@ class YuthonRunPlanning(models.Model): while current_date <= last_day_of_month: for employee in range(0, len(self.all_run_ids)): i = i + 1 - slot_id = all_slot.search([('resource_id', '=', self.engineering_run_ids[employee].employee_id.resource_id.id), ('start_datetime', '>=', first_day_of_month), ('start_datetime', '<=', last_day_of_month)]).sorted('start_datetime') + slot_id = all_slot.search([('resource_id', '=', self.all_run_ids[employee].employee_id.resource_id.id), ('start_datetime', '>=', first_day_of_month), ('start_datetime', '<=', last_day_of_month)]).sorted('start_datetime') if i < 31: slot_id[i].write({ 'template_id': self.env['planning.slot.template'].search( [('role_id', '=', role_a.id), ('planning_name', '=', '中夜')]).id, 'start_datetime': datetime(current_date.year, current_date.month, current_date.day,start_time2) + timedelta(hours=16) - timedelta(days=1), - 'end_datetime': datetime(current_date.year, current_date.month, current_date.day,end_time2) + timedelta(days=1, hours=16) - timedelta(days=1), + 'end_datetime': datetime(current_date.year, current_date.month, current_date.day,end_time2) + timedelta(hours=16) - timedelta(days=1), 'role_id': role_a.id, 'allocated_hours': 8, }) diff --git a/yuthon_hr_attendance/models/yuthon_shift_planning.py b/yuthon_hr_attendance/models/yuthon_shift_planning.py index ef3fcc603..803520a44 100644 --- a/yuthon_hr_attendance/models/yuthon_shift_planning.py +++ b/yuthon_hr_attendance/models/yuthon_shift_planning.py @@ -1,6 +1,6 @@ from odoo import api, fields, models, tools, _ from datetime import datetime, time, timedelta - +from odoo.exceptions import UserError, ValidationError class YuthonShiftPlanning(models.Model): _name = 'yuthon.shift.planning' @@ -28,6 +28,13 @@ class YuthonShiftPlanning(models.Model): next_month = (selected_month % 12) + 1 next_year = year + (1 if next_month == 1 else 0) # 如果是12月,年份加1 end_date = datetime(next_year, next_month, 1) + existing_slots = self.env['planning.slot'].search([ + ('role_id.name', '=', '保安部'), + ('start_datetime', '>=', start_date), + ('start_datetime', '<=', end_date), + ]) + if len(existing_slots) > 0: + raise UserError(f"该月已经有排程,请选择其他时间。") else: next_month = (selected_month % 12) + 1 next_year = year + (1 if next_month == 1 else 0) @@ -35,9 +42,15 @@ class YuthonShiftPlanning(models.Model): next_next_month = (next_month % 12) + 1 next_next_year = next_year + (1 if next_next_month == 1 else 0) end_date = datetime(next_next_year, next_next_month, 1) - + existing_slots = self.env['planning.slot'].search([ + ('role_id.name', '=', '保安部'), + ('start_datetime', '>=', start_date), + ('start_datetime', '<=', end_date), + ]) + if len(existing_slots) > 0: + raise UserError(f"该月已经有排程,请选择其他时间。") 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_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)]) role_template_c = self.env['planning.slot.template'].search([('planning_name', '=', '夜班'), ('role_id', '=', role_a.id)]) role = [role_template_a, role_template_b, role_template_c] @@ -116,8 +129,12 @@ class YuthonShiftPlanning(models.Model): if resource_id in ever_holidays and current_weekday in ever_holidays[resource_id]: pass else: - self.create_planning_slot(record, role_a, role_item, current_date) # 确保这个方法存在 + self.create_planning_slot(record, role_a, role_item, current_date) current_date += timedelta(days=1) + if current_date >= end_date: + break + if current_date >= end_date: + break # 为白班员工创建排班 create_shifts_for_group(self.planning_ever_white_ids, role[0]) # 为中班员工创建排班 diff --git a/yuthon_hr_attendance/security/attendance_security_group.xml b/yuthon_hr_attendance/security/attendance_security_group.xml deleted file mode 100644 index 14a14bc5b..000000000 --- a/yuthon_hr_attendance/security/attendance_security_group.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - 行政考勤组 - - - 行政考勤用户 - - - - 行政考勤天河投资领导 - - - - - 行政考勤天河物管领导 - - - - - 行政考勤天河粮储领导 - - - - - 行政考勤管理员 - - - - - - diff --git a/yuthon_hr_attendance/static/src/planning_gantt/gantt_popover.xml b/yuthon_hr_attendance/static/src/planning_gantt/gantt_popover.xml index d5f0638a9..0d2424bab 100644 --- a/yuthon_hr_attendance/static/src/planning_gantt/gantt_popover.xml +++ b/yuthon_hr_attendance/static/src/planning_gantt/gantt_popover.xml @@ -8,11 +8,10 @@ - diff --git a/yuthon_hr_attendance/views/inherit_planning_slot_template_views.xml b/yuthon_hr_attendance/views/inherit_planning_slot_template_views.xml index ec720c2b3..5cf2b1b99 100644 --- a/yuthon_hr_attendance/views/inherit_planning_slot_template_views.xml +++ b/yuthon_hr_attendance/views/inherit_planning_slot_template_views.xml @@ -8,7 +8,9 @@ - + + + @@ -19,7 +21,9 @@ - + + + diff --git a/yuthon_hr_attendance/views/inherit_planning_slot_views.xml b/yuthon_hr_attendance/views/inherit_planning_slot_views.xml index 2bd8d68b6..6c8aee360 100644 --- a/yuthon_hr_attendance/views/inherit_planning_slot_views.xml +++ b/yuthon_hr_attendance/views/inherit_planning_slot_views.xml @@ -109,6 +109,6 @@ planning.slot gantt,calendar,tree,form,kanban,pivot,graph {'planning_expand_resource': 1, 'planning_expand_role': 1} - [('department_id.name','=', '客服中心')] + [('department_id.name','=', '客户部')] \ No newline at end of file diff --git a/yuthon_property/models/yuthon_property.py b/yuthon_property/models/yuthon_property.py index c112133f6..3083d4735 100644 --- a/yuthon_property/models/yuthon_property.py +++ b/yuthon_property/models/yuthon_property.py @@ -47,17 +47,14 @@ class YuthonProperty(models.Model): live_room = fields.Many2one('yuthon.live.room', string="居住用房") is_electricity_meter = fields.Boolean(string="电表") electricity_id = fields.Many2one('yuthon.electricity.setting', string="电费标准配置") - admin_id = fields.Many2one('hr.employee', string="管理员") - yuthon_company = fields.Selection([('thtz', '天河投资'), ('thwg', '天河物管'), - ('thlc', '天河粮储'), ('ttcj', '天投城建'), ('fz', '房总')], string="所属公司") - tenure_type = fields.Selection([('dai', '代管'), ('zi', '自营')], string="权属类型") + admin_id = fields.Many2one('res.users', string="管理员") purpose_id = fields.Many2one('yuthon.resource.purpose', string="管理类型") is_confirm_authorization = fields.Boolean(string="确权") owner_id = fields.Many2one('yuthon.owner.message', string="权属人") property_card = fields.Html(string="产权证") life_timer = fields.Datetime(string="使用时间") property_use_time = fields.Selection([('a', '70年'), ('b', '40年')], string="使用年限") - property_precinct = fields.Many2one('yuthon.precinct.message', string="所属片区") + precinct_id = fields.Many2one('yuthon.precinct.message',string="所属片区") asset_type_id = fields.Many2one('yuthon.resource.type', string="出租类型") is_hvac = fields.Boolean(string="使用中央空调") is_handle_land = fields.Boolean(string="办理土地有偿使用手续") @@ -90,6 +87,29 @@ class YuthonProperty(models.Model): property_merge_approval_id = fields.Many2one('yuthon.property', string='关联物业信息') manage_fee_line_ids = fields.One2many('manage.information.fee.line', 'yuthon_property_id', string='关联管理费明细行') + @api.onchange('title_information_ids') + def _onchange_title_information_ids(self): + for rec in self: + title_info_records = rec.title_information_ids + if title_info_records: + latest_record_id = sorted(title_info_records, key=lambda x: x.start_time, reverse=True)[0] + rec.write({ + 'equity_area':latest_record_id.equity_area, + 'management_area': latest_record_id.management_area, + 'building_area':latest_record_id.building_area + }) + + @api.onchange('manage_information_ids') + def _onchange_manage_information_ids(self): + for rec in self: + manage_information_ids = rec.manage_information_ids + if manage_information_ids: + latest_record_id = sorted(manage_information_ids, key=lambda x: x.start_time, reverse=True)[0] + rec.write({ + 'precinct_id': latest_record_id.precinct_id.id, + 'admin_id': latest_record_id.admin_id.id + }) + @api.onchange('building_area') def _onchange_building_area(self): for rec in self: @@ -301,7 +321,7 @@ class TitleInformationLine(models.Model): rent_area = fields.Float(string="可租面积") owner = fields.Many2one('yuthon.owner.message',string="权属人") title_certificate = fields.Char(string="产权证号") - start_time = fields.Date(string="生效日期") + start_time = fields.Date(string="生效日期", default=fields.Date.today) end_date = fields.Date(string="失效日期") @@ -311,10 +331,10 @@ class ManageInformationLine(models.Model): yuthon_property_id = fields.Many2one('yuthon.property', string="关联物业信息") purpose_id = fields.Many2one('yuthon.resource.purpose', string="管理类型") - precinct = fields.Char(string="片区") - admin_id = fields.Many2one('hr.employee', string="管理员") + precinct_id = fields.Many2one('yuthon.precinct.message',string="所属片区") + admin_id = fields.Many2one('res.users', string="管理员") yuthon_company = fields.Selection([('thtz', '天河投资集团'), ('thwg', '天河物管'), ('thlc', '天河粮储'), ('thtj', '天城投建')], string="所属公司") - start_time = fields.Date(string="生效日期") + start_time = fields.Date(string="生效日期", default=fields.Date.today) end_date = fields.Date(string="失效日期") diff --git a/yuthon_property/views/yuthon_property_views.xml b/yuthon_property/views/yuthon_property_views.xml index 8fdd9d325..302bf48fa 100644 --- a/yuthon_property/views/yuthon_property_views.xml +++ b/yuthon_property/views/yuthon_property_views.xml @@ -86,8 +86,6 @@ - - @@ -113,8 +111,10 @@ - + + + @@ -209,15 +209,14 @@ - + - - - + + diff --git a/yuthon_tianhe/i18n/zh_CN.po b/yuthon_tianhe/i18n/zh_CN.po index c63c2179b..235ab0029 100644 --- a/yuthon_tianhe/i18n/zh_CN.po +++ b/yuthon_tianhe/i18n/zh_CN.po @@ -64,7 +64,7 @@ msgstr "会议管理" #: model:ir.ui.menu,name:purchase.menu_purchase_root #, python-format msgid "Purchase" -msgstr "办公用品管理" +msgstr "采购" #. module: fleet #. odoo-javascript diff --git a/yuthon_work_brand/views/attendance_menu.xml b/yuthon_work_brand/views/attendance_menu.xml index 09c0b63fb..141283fa8 100644 --- a/yuthon_work_brand/views/attendance_menu.xml +++ b/yuthon_work_brand/views/attendance_menu.xml @@ -4,37 +4,31 @@ @@ -90,7 +84,6 @@