From 41665a7b74e7256ca1cb4ed6bcbeac439aae3c63 Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Fri, 20 Jun 2025 15:49:35 +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
---
room/models/room_booking.py | 2 +-
.../static/src/js/statements_create_button.js | 4 ++--
yuthon_property_approval/__manifest__.py | 1 +
.../models/inherit_yuthon_property.py | 15 +--------------
.../security/ir.model.access.csv | 1 +
.../views/inherit_yuthon_property_views.xml | 7 -------
yuthon_property_approval/wizard/__init__.py | 3 ++-
.../wizard/click_reconciliation_wizard.py | 17 +++++++++++++++++
.../click_reconciliation_wizard_views.xml | 18 ++++++++++++++++++
.../wizard/property_reconciliation_wizard.py | 5 +++--
10 files changed, 46 insertions(+), 27 deletions(-)
create mode 100644 yuthon_property_approval/wizard/click_reconciliation_wizard.py
create mode 100644 yuthon_property_approval/wizard/click_reconciliation_wizard_views.xml
diff --git a/room/models/room_booking.py b/room/models/room_booking.py
index 7db1cd7ce..1e6c11b1b 100644
--- a/room/models/room_booking.py
+++ b/room/models/room_booking.py
@@ -223,7 +223,7 @@ class RoomBooking(models.Model):
'views': [(False, 'form')],
'target': 'new',
'context': {
- 'default_qrcode_image': qrcode_image,
+ 'efault_default_qrcode_image': qrcode_image,
}
}
return action
diff --git a/yuthon_property/static/src/js/statements_create_button.js b/yuthon_property/static/src/js/statements_create_button.js
index 726ffaac4..5c7065632 100644
--- a/yuthon_property/static/src/js/statements_create_button.js
+++ b/yuthon_property/static/src/js/statements_create_button.js
@@ -11,8 +11,8 @@ export class CustomStatementsListController extends ListController {
openAllStatementsWizard() {
this.actionService.doAction({
type: 'ir.actions.act_window',
- res_model: 'property.statements.wizard',
- name: '批量对账',
+ res_model: 'click.reconciliation.wizard',
+ name: '一键对账',
view_mode: 'form',
view_type: 'form',
views: [[false, 'form']],
diff --git a/yuthon_property_approval/__manifest__.py b/yuthon_property_approval/__manifest__.py
index 8557cab46..ec934cd4e 100644
--- a/yuthon_property_approval/__manifest__.py
+++ b/yuthon_property_approval/__manifest__.py
@@ -74,6 +74,7 @@
'wizard/choose_contract_wizard_views.xml',
'wizard/property_reconciliation_wizard_views.xml',
'wizard/property_management_wizard.xml',
+ 'wizard/click_reconciliation_wizard_views.xml',
'wizard/property_rental_wizard_views.xml',
'wizard/property_meeting_wizard_views.xml',
'views/property_menu_all.xml',
diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py
index 98d4ebe74..71b7dc652 100644
--- a/yuthon_property_approval/models/inherit_yuthon_property.py
+++ b/yuthon_property_approval/models/inherit_yuthon_property.py
@@ -66,7 +66,7 @@ class PropertyBankStatements(models.Model):
def _get_reconciliation_vals(self, record):
if record.name:
dt = datetime.strptime(str(self.start_time), '%Y-%m-%d %H:%M:%S').date()
- bank_id = self.env['property.bank.line'].search([('bank', '=', record.name)])
+ bank_id = self.env['property.bank.line'].search([('bank', '=', record.name)], limit=1)
first_day = dt.replace(day=1)
last_day = first_day + relativedelta(months=1) - relativedelta(days=1)
total_rent_month = 0
@@ -220,19 +220,6 @@ class PropertyBankStatements(models.Model):
all_vals, total_rent_month = self._get_reconciliation_vals(record)
return self._get_context_and_action(record, all_vals, total_rent_month)
- def button_all_reconciliation(self):
- statements_ids = self.env["property.bank.statements"].browse(self._context.get('active_ids', self._context.get('active_id')))
- total_all_vals = []
- grand_total_rent_month = 0
- for record in statements_ids:
- all_vals, total_rent_month = self._get_reconciliation_vals(record)
- total_all_vals.extend(all_vals)
- grand_total_rent_month += total_rent_month
- if statements_ids:
- first_record = statements_ids[0]
- return self._get_context_and_action(first_record, total_all_vals, grand_total_rent_month)
- return None
-
def put_button(self):
form_id = self.env.ref('yuthon_property_approval.view_property_accounts_approval_form').id
bank_list = []
diff --git a/yuthon_property_approval/security/ir.model.access.csv b/yuthon_property_approval/security/ir.model.access.csv
index 9b1378375..9491d48b1 100644
--- a/yuthon_property_approval/security/ir.model.access.csv
+++ b/yuthon_property_approval/security/ir.model.access.csv
@@ -97,4 +97,5 @@ access_property_meeting_line,property_meeting_line,model_property_meeting_line,b
access_property_management_line, property_management_line,model_property_management_line,base.group_user,1,1,1,1
access_property_management_line2, property_management_line2,model_property_management_line2,base.group_user,1,1,1,1
access_property_management_wizard, property_management_wizard,model_property_management_wizard,base.group_user,1,1,1,1
+access_click_reconciliation_wizard, click_reconciliation_wizard,model_click_reconciliation_wizard,base.group_user,1,1,1,1
diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
index dfaff0263..c71ba5f9e 100644
--- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml
+++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
@@ -543,13 +543,6 @@
-
-
- 批量对账
-
-
- code
- action = model.button_all_reconciliation()
diff --git a/yuthon_property_approval/wizard/__init__.py b/yuthon_property_approval/wizard/__init__.py
index d325b1b5b..41ae25d99 100644
--- a/yuthon_property_approval/wizard/__init__.py
+++ b/yuthon_property_approval/wizard/__init__.py
@@ -5,4 +5,5 @@ from . import property_add_wizard
from . import property_physical_wizard
from . import property_reconciliation_wizard
from . import property_meeting_wizard
-from . import property_management_wizard
\ No newline at end of file
+from . import property_management_wizard
+from . import click_reconciliation_wizard
\ No newline at end of file
diff --git a/yuthon_property_approval/wizard/click_reconciliation_wizard.py b/yuthon_property_approval/wizard/click_reconciliation_wizard.py
new file mode 100644
index 000000000..a96c71b2e
--- /dev/null
+++ b/yuthon_property_approval/wizard/click_reconciliation_wizard.py
@@ -0,0 +1,17 @@
+from odoo import models, fields, api, _, SUPERUSER_ID
+from datetime import datetime, timedelta
+from dateutil.relativedelta import relativedelta
+
+
+class ClickReconciliationWizard(models.Model):
+ _name = 'click.reconciliation.wizard'
+
+ message = fields.Text(string='确认信息', readonly=True)
+
+ def action_confirm(self):
+ statements_ids = self.env["property.bank.statements"].search([('bank_state', '=', 'not_reconciled')])
+ for record in statements_ids:
+ all_vals, total_rent_month = record._get_reconciliation_vals(record)
+ # 更新对账状态
+ if total_rent_month == record.original_amount:
+ record.bank_state = 'reconciled'
diff --git a/yuthon_property_approval/wizard/click_reconciliation_wizard_views.xml b/yuthon_property_approval/wizard/click_reconciliation_wizard_views.xml
new file mode 100644
index 000000000..6aa646ef7
--- /dev/null
+++ b/yuthon_property_approval/wizard/click_reconciliation_wizard_views.xml
@@ -0,0 +1,18 @@
+
+
+
+ click.reconciliation.wizard.form
+ click.reconciliation.wizard
+
+
+
+
+
diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard.py b/yuthon_property_approval/wizard/property_reconciliation_wizard.py
index 6c571bff8..561876be8 100644
--- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py
+++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py
@@ -36,8 +36,9 @@ class PropertyReconciliationWizard(models.Model):
remaining_amount -= line.amount # 更新剩余金额
# 检查是否违约
- if line.due_date and self.actual_date:
- # 计算应收日期的下月1号
+ if(line.due_date and self.actual_date and
+ line.collection_type != 'deposit'):
+ # 计算应收日期的下月1号
next_month_first = (fields.Date.from_string(line.due_date) + relativedelta(months=1)).replace(day=1)
# 如果实收日期晚于下月1号,产生违约