diff --git a/yuthon_holiday/__manifest__.py b/yuthon_holiday/__manifest__.py index f1968c02a..5f3092d54 100644 --- a/yuthon_holiday/__manifest__.py +++ b/yuthon_holiday/__manifest__.py @@ -14,6 +14,7 @@ 'report/hr_leave_batch_report_action.xml', 'views/inherit_hr_type_views.xml', 'views/inherit_hr_leave_allocation_views.xml', + 'views/extended_vacation_approval_views.xml', 'views/inherit_hr_leave_accrual_plan_views.xml', 'views/hr_leave_accrual_views.xml', 'views/yuthon_fixes_approval_views.xml', diff --git a/yuthon_holiday/data/yuthon_holiday_data.xml b/yuthon_holiday/data/yuthon_holiday_data.xml index e40998543..7b607a966 100644 --- a/yuthon_holiday/data/yuthon_holiday_data.xml +++ b/yuthon_holiday/data/yuthon_holiday_data.xml @@ -14,6 +14,13 @@ 4 + + 修正编号 + yuthon_extended_code + JQYC + 4 + + 哺乳编号 yuthon_breastfeed_leave_code diff --git a/yuthon_holiday/models/__init__.py b/yuthon_holiday/models/__init__.py index 1bd3fb868..5bd4cf43d 100644 --- a/yuthon_holiday/models/__init__.py +++ b/yuthon_holiday/models/__init__.py @@ -4,4 +4,5 @@ from . import inherit_hr_leave from . import inherit_hr_leave_accrual_plan from . import yuthon_fixes_approval from . import yuthon_holiday_setting -from . import yuthon_breastfeed_leave \ No newline at end of file +from . import yuthon_breastfeed_leave +from . import extended_vacation_approval \ No newline at end of file diff --git a/yuthon_holiday/models/extended_vacation_approval.py b/yuthon_holiday/models/extended_vacation_approval.py new file mode 100644 index 000000000..09952f3de --- /dev/null +++ b/yuthon_holiday/models/extended_vacation_approval.py @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- +from email.policy import default + +from odoo import models, fields, api + + +class ExtendedVacationApproval(models.Model): + _name = 'extended.vacation.approval' + _description = '假期延长申请' + _inherit = ['soong.workflow.mixin', 'mail.thread.main.attachment', 'mail.activity.mixin'] + + name = fields.Char(string="标题") + code = fields.Char(string="编号", default=lambda self: self.env['ir.sequence'].next_by_code('yuthon_extended_code')) + 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="部门") + employee_ids = fields.Many2many('hr.employee', string="假期顺延人员") + type_vacations_ids = fields.Many2many('hr.leave.type', string="假期类型") + is_issues = fields.Boolean(string='是否上会') + issues_result = fields.Html(string="会议结果") + related_issues_id = fields.Many2one('issue.library', string="关联议题") + reason_application = fields.Text(string="申请事由") + documents_ids = fields.Many2many('ir.attachment', string="附件") + date_postponed = fields.Date(string="延期至") + active = fields.Boolean('Active', default=True, tracking=True) + remarks = fields.Text(string="备注") + work_end = fields.Boolean(string="结束") + urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度', + default='normal') + line_ids = fields.One2many('extended.vacation.line', 'vacation_id', string="延期假期") + + 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])]) + + @api.onchange('employee_ids') + def _onchange_employee_ids(self): + if not self.employee_ids: + self.line_ids = [(5, 0, 0)] + return + current_date = fields.Date.today() + target_date = fields.Date.to_date(f"{current_date.year}-{current_date.month}-01") + self.line_ids = [(5, 0, 0)] + line_values = [] + for employee in self.employee_ids: + report_record = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', employee.id.origin), + ('vacation_date', '=', target_date) + ], limit=1) + line_data = { + 'employee_id': employee.id, + 'dynamic_previous_year': report_record.dynamic_previous_year if report_record else 0.0, + 'dynamic_previous_year1': report_record.dynamic_previous_year1 if report_record else 0.0, + } + line_values.append((0, 0, line_data)) + self.line_ids = line_values + + def end_approval(self): + current_date = fields.Date.today() + start_date = fields.Date.to_date(f"{current_date.year}-01-01") + end_date = fields.Date.to_date(f"{current_date.year}-{current_date.month}-01") + if self.employee_ids: + has_annual_leave = self.type_vacations_ids.filtered(lambda r: r.name == '年假') + has_overtime_leave = self.type_vacations_ids.filtered(lambda r: r.name == '补休') + for employee in self.employee_ids: + report_records = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', employee.id), + ('vacation_date', '>=', start_date), + ('vacation_date', '<=', end_date) + ]) + if report_records: + write_vals = {} + if has_annual_leave: + write_vals['valid_date'] = self.date_postponed + if has_overtime_leave: + write_vals['valid_date1'] = self.date_postponed + + if write_vals: + report_records.write(write_vals) + for record in report_records: + record.update_line() + +class ExtendedVacationLine(models.Model): + _name = 'extended.vacation.line' + _description = "假期延长明细" + + vacation_id = fields.Many2one('extended.vacation.approval', string="假期延长") + employee_id = fields.Many2one('hr.employee', string="姓名") + dynamic_previous_year = fields.Float(string="上年年假剩余d", digits=(16, 3)) + dynamic_previous_year1 = fields.Float(string="上年补休剩余d", digits=(16, 3)) \ 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 29aef657e..70ee2a65b 100644 --- a/yuthon_holiday/security/ir.model.access.csv +++ b/yuthon_holiday/security/ir.model.access.csv @@ -6,4 +6,6 @@ access_yuthon_fixes_wizard,yuthon_fixes_wizard,model_yuthon_fixes_wizard,base.gr access_yuthon_holiday_setting,yuthon_holiday_setting,model_yuthon_holiday_setting,base.group_user,1,1,1,1 access_leave_allocation_wizard,leave_allocation_wizard,model_leave_allocation_wizard,base.group_user,1,1,1,1 access_yuthon_leave_wizard,yuthon_leave_wizard,model_yuthon_leave_wizard,base.group_user,1,1,1,1 -access_yuthon_breastfeed_leave,yuthon_breastfeed_leave,model_yuthon_breastfeed_leave,base.group_user,1,1,1,1 \ No newline at end of file +access_yuthon_breastfeed_leave,yuthon_breastfeed_leave,model_yuthon_breastfeed_leave,base.group_user,1,1,1,1 +access_extended_vacation_approval,extended_vacation_approval,model_extended_vacation_approval,base.group_user,1,1,1,1 +access_extended_vacation_line,extended_vacation_line,model_extended_vacation_line,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/yuthon_holiday/views/extended_vacation_approval_views.xml b/yuthon_holiday/views/extended_vacation_approval_views.xml new file mode 100644 index 000000000..7e01fc5e8 --- /dev/null +++ b/yuthon_holiday/views/extended_vacation_approval_views.xml @@ -0,0 +1,77 @@ + + + + extended.vacation.approval.tree + extended.vacation.approval + + + + + + + + + extended.vacation.approval.form + extended.vacation.approval + +
+ + + + + + + + + + + + + + + + + + +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + + + diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index 8ad5bb1b8..2a041e9d9 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -377,17 +377,33 @@ class YuthonVacationReports(models.Model): rec.year_workday += workday_overtime_add rec.year_holiday += holidays_overtime_add - if rec.working_overtime > 0: + current_month_first = rec.vacation_date.replace(day=1) + last_month_last = current_month_first - timedelta(days=1) + last_month_first = last_month_last.replace(day=1) + last_month_record = self.env['yuthon.vacation.reports'].search([ + ('employee_id', '=', rec.employee_id.id), + ('vacation_date', '=', last_month_first), + ], limit=1) + if last_month_record: + total_overtime = last_month_record.dynamic_previous_year1 + last_month_record.this_year1 + else: + total_overtime = 0.0 + + if total_overtime > 0: working_overtime_lines = rec.overtime_ids.filtered( lambda o: not o.workflow_record_id and o.text == '上月额度继承' ) - working_overtime_lines.workday = rec.working_overtime * 8 + working_overtime_lines.workday = total_overtime * 8 + if last_month_record: + total_leave = last_month_record.dynamic_previous_year + last_month_record.dynamic_remainder_year + else: + total_leave = 0.0 - if rec.leave > 0: + if total_leave > 0: leave_lines = rec.leave_ids.filtered( lambda o: not o.workflow_record_id and o.text == '上月额度继承' ) - leave_lines.update_lines = rec.leave * 8 + leave_lines.update_lines = total_leave * 8 rec._compute_leave() rec._compute_working_overtime() @@ -1365,12 +1381,21 @@ class YuthonVacationReports(models.Model): } rec.write(inherit_vals) + current_date = fields.Date.today() if last_month_record: + if last_month_record.valid_date and last_month_record.valid_date < current_date: + dynamic_previous_year_val = 0.0 + else: + dynamic_previous_year_val = last_month_record.dynamic_previous_year + if last_month_record.valid_date1 and last_month_record.valid_date1 < current_date: + dynamic_previous_year1_val = 0.0 + else: + dynamic_previous_year1_val = last_month_record.dynamic_previous_year1 inherit_vals = { 'leave': last_month_record.leave, - 'dynamic_previous_year': last_month_record.dynamic_previous_year, + 'dynamic_previous_year': dynamic_previous_year_val, 'dynamic_remainder_year': last_month_record.dynamic_remainder_year, - 'dynamic_previous_year1': last_month_record.dynamic_previous_year1, + 'dynamic_previous_year1': dynamic_previous_year1_val, 'this_year1': last_month_record.this_year1, 'working_overtime': last_month_record.working_overtime, 'medical_fee': last_month_record.medical_fee, diff --git a/yuthon_property/models/property_bank_statements.py b/yuthon_property/models/property_bank_statements.py index 4412ab636..e4c5c2a1e 100644 --- a/yuthon_property/models/property_bank_statements.py +++ b/yuthon_property/models/property_bank_statements.py @@ -195,11 +195,14 @@ class ReceivableModifyLine(models.Model): bank_id = fields.Many2one('property.bank.statements', string='关联银行对账单') original_amount = fields.Float(related='bank_id.original_amount', string='交易金额', store=False) + no_amount = fields.Float(related='bank_id.no_amount', string='未对', store=False) + bank_state = fields.Selection(related='bank_id.bank_state', string='状态', store=False) receivable_id = fields.Many2one('property.accounts.receivable', string='应收账单') management_type_id = fields.Many2one('yuthon.management.type', related='receivable_id.management_type_id', string='应收类型', store=False) due_date = fields.Date(related='receivable_id.due_date', string='应收开始', store=False) due_date_end = fields.Date(related='receivable_id.due_date_end', string='应收结束', store=False) property_name = fields.Text(string='物业', compute='_compute_property_name', store=False, search='_search_property_name') + delivered1 = fields.Float(related='receivable_id.delivered1', string='已收金额', store=False) is_write = fields.Boolean() @api.depends('receivable_id') @@ -225,6 +228,32 @@ class ReceivableModifyLine(models.Model): not_collected = fields.Float(string='未收') amount = fields.Float(string='已对金额') + def open_receivable(self): + """打开应收账单""" + self.ensure_one() + if self.receivable_id: + return { + 'type': 'ir.actions.act_window', + 'name': '应收账单', + 'res_model': 'property.accounts.receivable', + 'res_id': self.receivable_id.id, + 'view_mode': 'form', + 'target': 'current', + } + + def open_bank_statement(self): + """打开银行流水""" + self.ensure_one() + if self.bank_id: + return { + 'type': 'ir.actions.act_window', + 'name': '银行流水', + 'res_model': 'property.bank.statements', + 'res_id': self.bank_id.id, + 'view_mode': 'form', + 'target': 'current', + } + diff --git a/yuthon_property/views/property_bank_statements_views.xml b/yuthon_property/views/property_bank_statements_views.xml index 0aefe7b6c..70848a5e4 100644 --- a/yuthon_property/views/property_bank_statements_views.xml +++ b/yuthon_property/views/property_bank_statements_views.xml @@ -116,16 +116,21 @@ + + + +