From e255e1d7af8ab538e04b0d77f1aff2be8f5be0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Sat, 13 Sep 2025 17:23:09 +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 --- .../views/soong_workflow_node_views.xml | 2 +- .../wizard/soong_workflow_comment_wizard.py | 2 +- .../models/yuthon_vacation_reports.py | 52 +++++++++++++++++++ .../views/yuthon_vacation_reports_views.xml | 6 ++- .../models/inherit_yuthon_property.py | 6 +++ .../models/property_lease_contract.py | 35 ++++++++++++- .../models/property_management.py | 3 +- .../views/inherit_yuthon_property_views.xml | 3 +- .../wizard/property_reconciliation_wizard.py | 6 +++ .../property_reconciliation_wizard_views.xml | 1 + 10 files changed, 109 insertions(+), 7 deletions(-) diff --git a/soong_workflow/views/soong_workflow_node_views.xml b/soong_workflow/views/soong_workflow_node_views.xml index cfac60c58..9e331ea92 100644 --- a/soong_workflow/views/soong_workflow_node_views.xml +++ b/soong_workflow/views/soong_workflow_node_views.xml @@ -36,9 +36,9 @@ - + diff --git a/soong_workflow/wizard/soong_workflow_comment_wizard.py b/soong_workflow/wizard/soong_workflow_comment_wizard.py index ffb81357c..b91d71a79 100644 --- a/soong_workflow/wizard/soong_workflow_comment_wizard.py +++ b/soong_workflow/wizard/soong_workflow_comment_wizard.py @@ -24,7 +24,7 @@ class SoongWorkflowCommentWizard(models.TransientModel): node_link_len = fields.Char(string="转交2") is_supervising = fields.Boolean(string="是否督办") comment_note_id = fields.Many2one('soong.note', string="常用意见", default='妥否,呈领导审批') - comment_note = fields.Char(string="意见", default='同意') + comment_note = fields.Char(string="意见", default='妥否,呈领导审批') comment = fields.Char(compute='_compute_comment', store=True) state_list = fields.Char(string="状态列表") record_id = fields.Integer() diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index 587b5ff88..7087c766a 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -62,6 +62,7 @@ class YuthonVacationReports(models.Model): is_no_card = fields.Integer(string="缺卡", compute='compute_attendance_fields', store=True, group_operator=None) is_work = fields.Integer(string='旷工', compute='compute_attendance_fields', store=True, group_operator=None) is_abnormal = fields.Integer(string="异常", compute='compute_attendance_fields', store=True, group_operator=None) + att_mount = fields.Integer(string="出勤天数", compute='compute_att_mount', store=True, group_operator=None) vacation_state = fields.Selection( @@ -90,6 +91,57 @@ class YuthonVacationReports(models.Model): f"已存在假期额度记录,不能重复创建!" ) + @api.depends('vacation_date', 'employee_id') + def compute_att_mount(self): + for record in self: + target_date = record.vacation_date or fields.Date.today().replace(day=1) + first_day = target_date.replace(day=1) + if target_date.month == 12: + next_month = 1 + next_year = target_date.year + 1 + else: + next_month = target_date.month + 1 + next_year = target_date.year + last_day = fields.Date.from_string(f"{next_year}-{next_month}-01") - timedelta(days=1) + + first_day_str = fields.Date.to_string(first_day) + last_day_str = fields.Date.to_string(last_day) + attendance_records = self.env['hr.attendance'].search([ + ('employee_id', '=', record.employee_id.id), + ('current_data', '>=', first_day_str), + ('current_data', '<=', last_day_str) + ]) + unique_dates = set(attendance_records.mapped('current_data')) + record.att_mount = len(unique_dates) + + def action_open(self): + self.ensure_one() + target_date = self.vacation_date or fields.Date.today().replace(day=1) + first_day = target_date.replace(day=1) + if target_date.month == 12: + next_month = 1 + next_year = target_date.year + 1 + else: + next_month = target_date.month + 1 + next_year = target_date.year + last_day = fields.Date.from_string( + f"{next_year}-{next_month}-01" + ) - timedelta(days=1) + + first_day_str = fields.Date.to_string(first_day) + last_day_str = fields.Date.to_string(last_day) + action = self.env["ir.actions.actions"]._for_xml_id("yuthon_hr_attendance.action_attendance_company_form") + action.update({ + 'domain': [ + ('employee_id', '=', self.employee_id.id), + ('current_data', '>=', first_day_str), + ('current_data', '<=', last_day_str) + ] + }) + return action + + + def confirm_state(self): for rec in self: rec.vacation_state = 'confirmed' diff --git a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml index 0deb02c57..7b78edea7 100644 --- a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml +++ b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml @@ -101,8 +101,10 @@
-
- +
+
diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index 1d000a9a0..326cde850 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -393,6 +393,7 @@ class PropertyAccountsReceivable(models.Model): _rec_name = 'contract_id' property_ids = fields.Many2many('yuthon.property', string='物业', compute='_compute_property_ids', store=True) + property_name = fields.Text(string='物业', compute="_compute_property_name") management_area = fields.Float(related='contract_id.total_area', string='面积') title_deed = fields.Char(string="产权证号", compute='_compute_title_deed') lessee_id = fields.Many2one(related='contract_id.lessee_id', string='承租方') @@ -407,6 +408,11 @@ class PropertyAccountsReceivable(models.Model): rent_owed = fields.Float(string="欠租金额") per_day = fields.Float(string="每天违约金(元/天)") + @api.depends('contract_id') + def _compute_property_name(self): + for record in self: + record.property_name = record.contract_id.property_name + @api.depends('property_ids') def _compute_title_deed(self): for record in self: diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index 232e66a61..19f7c72f0 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -401,7 +401,10 @@ class PropertyLeaseContract(models.Model): }) def end_approval(self): - self.write({'condition': 'be_executed'}) + self.write({'condition': 'be_executed', + 'actual_start_time': self.term_start_time, + 'actual_end_time': self.term_end_time, + }) def open_record(self): return { @@ -1506,6 +1509,36 @@ class PropertyLeaseContract(models.Model): elif effective_month and today >= effective_month < term_end: contract.contact_state = 'terminate' + @api.onchange('actual_start', 'actual_end') + def _onchange_contact_state(self): + for contract in self: + today = fields.Date.today() + term_end = contract.term_start_time + actual_start = contract.actual_start + actual_end = contract.actual_end + effective_month = None + + if actual_end: + last_day_of_month = calendar.monthrange(actual_end.year, actual_end.month)[1] + if actual_end.day == last_day_of_month: + effective_month = fields.Date.to_date(f"{actual_end.year}-{actual_end.month}-{last_day_of_month}") + if effective_month.month == 12: + effective_month = fields.Date.to_date(f"{effective_month.year + 1}-01-01") + else: + effective_month = fields.Date.to_date(f"{effective_month.year}-{effective_month.month + 1}-01") + else: + effective_month = fields.Date.to_date(f"{actual_end.year}-{actual_end.month}-01") + + if not actual_start or today < actual_start: + # 待执行:实际开始时间未到或未设置 + contract.contact_state = 'to' + elif actual_start and (not actual_end or today < actual_end): + # 执行中:已开始且未结束(或结束时间未设置) + contract.contact_state = 'ing' + elif today >= actual_end == term_end: + contract.contact_state = 'complete' + elif effective_month and today >= effective_month and effective_month < term_end: + contract.contact_state = 'terminate' # 续租 def button_lease_extension(self): diff --git a/yuthon_property_approval/models/property_management.py b/yuthon_property_approval/models/property_management.py index 27b8b05e8..5bd5889de 100644 --- a/yuthon_property_approval/models/property_management.py +++ b/yuthon_property_approval/models/property_management.py @@ -16,7 +16,8 @@ class PropertyManagement(models.Model): default=lambda self: self.env['ir.sequence'].next_by_code('property_management_code')) reason_change = fields.Char(string="变更事由") user_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user) - department_id = fields.Many2one('hr.department', related='user_id.employee_id.department_id',string="申请人部门") + department_id = fields.Many2one('hr.department', related='user_id.employee_id.department_id',string="申请人部门", store=True) + company_id = fields.Many2one('res.company', related='user_id..employee_id.company_id', string="公司", store=True) handling_opinions = fields.Text(string="经办意见") management_line2_ids = fields.One2many('property.management.line2', 'property_management_id', string="原物业信息") management_line_ids = fields.One2many('property.management.line', 'property_management_id', string="物业信息") diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml index e653d2563..0f3e0f81e 100644 --- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml +++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml @@ -276,7 +276,8 @@ - + + diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard.py b/yuthon_property_approval/wizard/property_reconciliation_wizard.py index 951b9e997..310da4de3 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py @@ -453,6 +453,7 @@ class PropertyReconciliationLine(models.Model): reconciliation_id = fields.Many2one('property.reconciliation.wizard', string='关联对账单弹窗') sequence = fields.Integer(string='顺序') + property_name = fields.Text(string='物业', compute="_compute_property_name") property_ids = fields.Many2many('yuthon.property', string='物业', compute="_compute_property_ids", store=True) contract_id = fields.Many2one('property.lease.contract', string='合同编号') rent_month = fields.Float(string='当期金额') @@ -464,6 +465,11 @@ class PropertyReconciliationLine(models.Model): ('other', '其他')], string='收款类型', store=True) remake = fields.Char(string='备注') + @api.depends('contract_id') + def _compute_property_name(self): + for record in self: + record.property_name = record.contract_id.property_name + @api.depends('contract_id', 'contract_id.lease_ids', 'contract_id.lease_ids.address_id') def _compute_property_ids(self): for record in self: diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml b/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml index d7b8361cc..acd38375f 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml @@ -30,6 +30,7 @@ +