diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index f40d62cea..43f426cae 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -469,10 +469,10 @@ class PropertyBankStatements(models.Model): all_vals.extend(fee_vals) all_vals.extend(rename_vals) - return all_vals, total_rent_month, used_type_names + return all_vals, total_rent_month, return [], 0 - def _get_context_and_action(self, record, all_vals, total_rent_month, used_type_names): + def _get_context_and_action(self, record, all_vals, total_rent_month): """ :param record: 银行收款记录 :param all_vals: 应收费用列表 @@ -480,10 +480,6 @@ 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, @@ -496,7 +492,6 @@ 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) @@ -541,8 +536,8 @@ class PropertyBankStatements(models.Model): def button_reconciliation(self): for record in self: - all_vals, total_rent_month, used_type_names = self._get_reconciliation_vals(record, record.contract_ids) - return self._get_context_and_action(record, all_vals, total_rent_month, used_type_names) + all_vals, total_rent_month = self._get_reconciliation_vals(record, record.contract_ids) + return self._get_context_and_action(record, all_vals, total_rent_month) 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 16c6cfda7..ee02a6dbe 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py @@ -86,7 +86,7 @@ class PropertyReconciliationWizard(models.Model): rec.reconciliation_line_ids = to_delete new_contracts = self.env['property.lease.contract'].browse(current_contract_ids) - new_vals, _, _ = rec.bank_id._get_reconciliation_vals(rec.bank_id, new_contracts, is_equity=True) + new_vals, _,= rec.bank_id._get_reconciliation_vals(rec.bank_id, new_contracts, is_equity=True) rec.reconciliation_line_ids = [(5, 0, 0)] rec.reconciliation_line_ids = new_vals rec.compute_reconciliation_line_ids() @@ -106,7 +106,7 @@ class PropertyReconciliationWizard(models.Model): 'lightbox': '灯箱', 'guanzijian': '管子间', 'electricity_fee': '电费', - 'penalty': '违约金', # 存在但会被排除 + 'penalty': '违约金', 'management_fee': '管理费', 'repair_fee': '维修费', 'fee': '人工费/日光灯款/代垫用料费', @@ -115,10 +115,9 @@ class PropertyReconciliationWizard(models.Model): 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: + if line.collection_type not in allowed_by_selection: to_delete.append((2, line.id, 0)) if to_delete: @@ -126,6 +125,18 @@ class PropertyReconciliationWizard(models.Model): @api.onchange('actual_total') def compute_reconciliation_line_ids(self): + type_name_map = { + 'deposit': '押金', + 'rent': '租金', + 'water_fee': '水费', + 'lightbox': '灯箱', + 'guanzijian': '管子间', + 'electricity_fee': '电费', + 'penalty': '违约金', + 'management_fee': '管理费', + 'repair_fee': '维修费', + 'fee': '人工费/日光灯款/代垫用料费', + } new_lines = [] # 违约金生成 for contract_id in self.contract_ids: @@ -349,6 +360,15 @@ class PropertyReconciliationWizard(models.Model): self.write({'reconciliation_line_ids': missing_penalty_lines}) self.create_reconciliation_vals() + line_types = [] + for line in self.reconciliation_line_ids: + if line.collection_type not in line_types: + line_types.append(line.collection_type) + type_names = [type_name_map.get(t) for t in line_types if type_name_map.get(t)] + receivable_types = self.env['yuthon.management.type'].search([ + ('name', 'in', type_names) + ]) + self.receivables_type_ids = receivable_types def create_reconciliation_vals(self): """