From 6b37920f733a7c2f57fb846ba70f3a929840d338 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Thu, 17 Jul 2025 18:12:22 +0800 Subject: [PATCH 01/12] =?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 --- .../models/yuthon_vacation_reports.py | 17 ++++++++++++ .../views/yuthon_vacation_reports_views.xml | 27 ++++++++++++------- .../models/property_split_approval.py | 20 +++++++------- .../views/property_split_approval_views.xml | 1 - yuthon_work_brand/views/hr_menus.xml | 10 +++---- 5 files changed, 48 insertions(+), 27 deletions(-) diff --git a/yuthon_holiday/models/yuthon_vacation_reports.py b/yuthon_holiday/models/yuthon_vacation_reports.py index 14f4ca568..cb2c49c6d 100644 --- a/yuthon_holiday/models/yuthon_vacation_reports.py +++ b/yuthon_holiday/models/yuthon_vacation_reports.py @@ -7,6 +7,7 @@ from odoo.exceptions import ValidationError class YuthonVacationReports(models.Model): _name = 'yuthon.vacation.reports' _description = '假期额度记录' + _rec_name = "employee_id" employee_id = fields.Many2one('hr.employee', string='员工') company_id = fields.Many2one(related="employee_id.company_id", string="公司") @@ -18,6 +19,22 @@ class YuthonVacationReports(models.Model): working_overtime = fields.Float(string='加班时', compute='_compute_working_overtime', store=True) meal_fee = fields.Integer(string="误餐次数", compute='_compute_meal_fee', store=True) + def action_open_my_form(self): + employee = self.env.user.employee_id + vacation_report = self.env['yuthon.vacation.reports'].search( + [('employee_id', '=', employee.id)], limit=1) + return { + 'name': '我的假期额度', + 'type': 'ir.actions.act_window', + 'res_model': 'yuthon.vacation.reports', + 'view_mode': 'form', + 'res_id': vacation_report.id, + 'view_id': self.env.ref('yuthon_holiday.view_yuthon_vacation_reports_form1').id, + 'context': { + 'default_employee_id': employee.id, + }, + } + def overtime_allocation(self): form_id = self.env.ref('hr_holidays.hr_leave_allocation_view_form_manager').id holiday_status_id = self.env['hr.leave.type'].search([('name', '=', '补休')]) diff --git a/yuthon_holiday/views/yuthon_vacation_reports_views.xml b/yuthon_holiday/views/yuthon_vacation_reports_views.xml index 33f6c0fcb..14277fe92 100644 --- a/yuthon_holiday/views/yuthon_vacation_reports_views.xml +++ b/yuthon_holiday/views/yuthon_vacation_reports_views.xml @@ -4,7 +4,7 @@ yuthon.vacation.reports.tree yuthon.vacation.reports - + @@ -89,11 +89,20 @@ + + yuthon.vacation.reports.search + yuthon.vacation.reports + + + + + + yuthon.vacation.reports.form yuthon.vacation.reports -
+ @@ -170,13 +179,13 @@ (0, 0, {'view_mode': 'tree', 'view_id': ref('yuthon_holiday.view_yuthon_vacation_reports_tree')}), (0, 0, {'view_mode': 'form', 'view_id': ref('yuthon_holiday.view_yuthon_vacation_reports_form')})]"/> - - 我的假期额度 - yuthon.vacation.reports - form - [('employee_id.user_id', '=', uid)] - + + 我的假期额度表单 + + code + + action = model.action_open_my_form() + 更新报表 diff --git a/yuthon_property_approval/models/property_split_approval.py b/yuthon_property_approval/models/property_split_approval.py index cb1cd7c1f..449083a73 100644 --- a/yuthon_property_approval/models/property_split_approval.py +++ b/yuthon_property_approval/models/property_split_approval.py @@ -36,18 +36,18 @@ class PropertySplitApproval(models.Model): name_title = fields.Char(default=_get_default_name_title) - def property_split_button(self): + @api.onchange('split_quantity', 'property_id') + def _onchange_split_quantity(self): + self.property_split_approval_line_ids = [(5, 0, 0)] if self.split_quantity < 2: raise UserError('拆分数量必须是大于2') - if self.id and self.property_id: - lines_to_create = [] - for i in range(self.split_quantity): - lines_to_create.append({ - 'property_split_approval_id': self.id, - 'split_property': f"{self.property_id.name}-{i + 1}" - }) - self.property_split_approval_line_ids.unlink() - self.env['property.split.approval.line'].create(lines_to_create) + lines_to_create = [] + for i in range(self.split_quantity): + lines_to_create.append({ + 'property_split_approval_id': self.id, + 'split_property': f"{self.property_id.name}-{i + 1}" + }) + self.property_split_approval_line_ids = [(0, 0, line) for line in lines_to_create] def put_split_message(self): property_list = [] diff --git a/yuthon_property_approval/views/property_split_approval_views.xml b/yuthon_property_approval/views/property_split_approval_views.xml index 38ac65ac3..38df6ab2d 100644 --- a/yuthon_property_approval/views/property_split_approval_views.xml +++ b/yuthon_property_approval/views/property_split_approval_views.xml @@ -63,7 +63,6 @@ -