diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index bece194a0..8a6bff747 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -510,6 +510,12 @@ class PropertyBankStatements(models.Model): all_vals.extend(fee_vals) all_vals.extend(rename_vals) + # 按 due_date 正序排列,最早日期在最上面 + all_vals.sort(key=lambda x: (x[2].get('due_date') or date.max, x[2].get('contract_id') or 0)) + # 重新设置 sequence,确保按正序从 10 开始递增 + for idx, val in enumerate(all_vals, start=1): + val[2]['sequence'] = idx * 10 + return all_vals, total_rent_month, return [], 0 diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard.py b/yuthon_property_approval/wizard/property_reconciliation_wizard.py index 23d38e40f..98d185a57 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py @@ -543,7 +543,7 @@ class PropertyReconciliationWizard(models.Model): class PropertyReconciliationLine(models.Model): _name = 'property.reconciliation.line' _description = '对账明细' - _order = 'due_date desc' + _order = 'sequence, due_date' reconciliation_id = fields.Many2one('property.reconciliation.wizard', string='关联对账单弹窗') sequence = fields.Integer(string='顺序') diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml b/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml index 74495bf5e..7ebb560a9 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard_views.xml @@ -62,7 +62,7 @@ - +