diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index cccbf4d5b..c362fe125 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -1062,6 +1062,7 @@ class AttendanceMessageLog(models.Model): employee_id = fields.Many2one('hr.employee', string='员工') department_id = fields.Many2one(related='employee_id.department_id', string="部门", index=True) company_id = fields.Many2one(related='employee_id.company_id', string="公司") + service_address = fields.Char(string='服务地址') update_date = fields.Datetime(string='提醒时间') shift_id = fields.Many2one('planning.slot', string="班次", compute="_compute_shift_id", store=True) content = fields.Text(string='内容') diff --git a/yuthon_hr_attendance/views/attendance_message_log.xml b/yuthon_hr_attendance/views/attendance_message_log.xml index 8b63d2110..68ebe5675 100644 --- a/yuthon_hr_attendance/views/attendance_message_log.xml +++ b/yuthon_hr_attendance/views/attendance_message_log.xml @@ -10,6 +10,7 @@ + diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index 841ae535e..1f10de41b 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -337,6 +337,17 @@ class PropertyBankStatements(models.Model): def _get_reconciliation_vals(self, record): if record.name: + collection_type_map = { + 'rent': '租金', + 'deposit': '押金', + 'management_fee': '管理费', + 'lightbox': '灯箱', + 'guanzijian': '管子间', + 'water_fee': '水费', + 'electricity_fee': '电费', + 'fee': '人工费/日光灯款/代垫用料费', + } + used_type_names = set() total_rent_month = 0 # 应收租金 rent_ids = self.env['property.accounts.receivable'].search([ @@ -415,6 +426,7 @@ class PropertyBankStatements(models.Model): nonlocal total_rent_month vals_list = [] current_sequence = sequence_val + type_name = collection_type_map.get(collection_type_val, '') # 特殊处理:押金类型需要去重相同合同的记录 if collection_type_val == 'deposit': # 使用字典来跟踪已处理的合同ID @@ -466,6 +478,9 @@ class PropertyBankStatements(models.Model): current_sequence += 10 + if vals_list and type_name: + used_type_names.add(type_name) + return vals_list, current_sequence all_vals = [] @@ -487,10 +502,10 @@ class PropertyBankStatements(models.Model): all_vals.extend(electricity_vals) all_vals.extend(fee_vals) - return all_vals, total_rent_month + return all_vals, total_rent_month, used_type_names return [], 0 - def _get_context_and_action(self, record, all_vals, total_rent_month): + def _get_context_and_action(self, record, all_vals, total_rent_month, used_type_names): """ :param record: 银行收款记录 :param all_vals: 应收费用列表 @@ -498,6 +513,10 @@ class PropertyBankStatements(models.Model): :return: """ start_time = self.start_time + relativedelta(hours=8) + management_types = self.env['yuthon.management.type'].search([ + ('name', 'in', list(used_type_names)) + ]) + context = { "default_actual_date": fields.Date.to_date(start_time), "default_bank_id": self.id, @@ -510,6 +529,7 @@ class PropertyBankStatements(models.Model): "default_receivable_total": total_rent_month, "dialog_size": "extra-large", "default_order": "due_date desc", + "default_receivables_type_ids": [(6, 0, management_types.ids)] if management_types else [], } self._check_unreconciled_statements(start_time) @@ -554,8 +574,8 @@ class PropertyBankStatements(models.Model): def button_reconciliation(self): for record in self: - all_vals, total_rent_month = self._get_reconciliation_vals(record) - return self._get_context_and_action(record, all_vals, total_rent_month) + all_vals, total_rent_month, used_type_names = self._get_reconciliation_vals(record) + return self._get_context_and_action(record, all_vals, total_rent_month, used_type_names) def put_button(self): form_id = self.env.ref('yuthon_property_approval.view_property_accounts_approval_form').id diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard.py b/yuthon_property_approval/wizard/property_reconciliation_wizard.py index 20e6e4ad9..d450c5588 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py @@ -16,6 +16,7 @@ class PropertyReconciliationWizard(models.Model): bank_id = fields.Many2one('property.bank.statements', string='银行流水') lessee_ids = fields.Many2many('property.tenant.information', string='承租方') + receivables_type_ids = fields.Many2many('yuthon.management.type', string="应收类型") name_account = fields.Char( string='对方户名') account = fields.Char(string='账号') contract_ids = fields.Many2many('property.lease.contract', string='合同') @@ -40,14 +41,12 @@ class PropertyReconciliationWizard(models.Model): rec.amount_water_been = rec.bank_id.yes_amount rec.amount_water = rec.bank_id.no_amount - @api.depends('reconciliation_line_ids') def _compute_receivable_total(self): for rec in self: rec.receivable_total = sum(line.rent for line in rec.reconciliation_line_ids) rec.amount_reconciled = rec.bank_id.no_amount - sum(line.amount for line in self.reconciliation_line_ids) - @api.depends('reconciliation_line_ids.collection_type', 'reconciliation_line_ids.rent') def _compute_rent_total(self): """计算所有类型为租金的明细行的未收总额""" @@ -85,6 +84,39 @@ class PropertyReconciliationWizard(models.Model): to_delete.append((2, line.id, 0)) rec.reconciliation_line_ids = to_delete + @api.onchange('receivables_type_ids') + def onchange_receivables_type_ids(self): + for rec in self: + selected_type_names = rec.receivables_type_ids.mapped('name') + if not selected_type_names: + rec.reconciliation_line_ids = [(5, 0, 0)] + continue + # 收款类型与名称的映射(包含违约金,但后续会排除) + type_name_map = { + 'deposit': '押金', + 'rent': '租金', + 'water_fee': '水费', + 'lightbox': '灯箱', + 'guanzijian': '管子间', + 'electricity_fee': '电费', + 'penalty': '违约金', # 存在但会被排除 + 'management_fee': '管理费', + 'repair_fee': '维修费', + 'fee': '人工费/日光灯款/代垫用料费', + } + allowed_by_selection = [ + coll_type for coll_type, name in type_name_map.items() + if name in selected_type_names + ] + allowed_collection_types = allowed_by_selection + ['penalty'] + to_delete = [] + for line in rec.reconciliation_line_ids: + if line.collection_type not in allowed_collection_types: + to_delete.append((2, line.id, 0)) + + if to_delete: + rec.reconciliation_line_ids = to_delete + @api.onchange('actual_total') def compute_reconciliation_line_ids(self): new_lines = [] diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml b/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml index aef4eec33..e531a36c4 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml @@ -49,6 +49,7 @@ + diff --git a/yuthon_wechat/models/wecom_apps.py b/yuthon_wechat/models/wecom_apps.py index 0e4c83cd7..e8abfbf67 100644 --- a/yuthon_wechat/models/wecom_apps.py +++ b/yuthon_wechat/models/wecom_apps.py @@ -173,10 +173,12 @@ class WeComApps(models.Model): result_data = self.sync_function_api("message_send", "MESSAGE_SEND", data, category) employee_id = self.env["res.users"].search([("login", "=", user_id)], limit=1).employee_id notice_type = 'attendance' if '记得打卡' in description else 'process' + service_address = self.env['ir.config_parameter'].sudo().get_param('web.base.url') self.env["attendance.message.log"].create({ "employee_id": employee_id.id, "content": description, "notice_type": notice_type, + "service_address":service_address, 'update_date': fields.Datetime.now(), "message_url": url, })