From 471df1f17bf52a3deef65de7d4fe3ee13f3c8fe1 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: Wed, 3 Dec 2025 19:24:24 +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
---
.../property_accounts_receivable_views.xml | 4 +-
yuthon_property_approval/__manifest__.py | 2 +
yuthon_property_approval/models/__init__.py | 3 +-
.../models/property_bills_list.py | 31 ++++++++++++++
.../models/property_bills_payable.py | 33 ++++++++-------
.../models/property_lease_contract.py | 7 +---
.../models/property_lease_renewal.py | 40 ++++++-------------
.../security/ir.model.access.csv | 4 +-
.../views/inherit_yuthon_property_views.xml | 4 +-
.../views/property_bills_list_views.xml | 30 ++++++++++++++
.../views/property_bills_payable_views.xml | 23 ++++-------
.../views/property_lease_renewal.xml | 3 --
yuthon_property_approval/wizard/__init__.py | 3 +-
.../wizard/property_bills_wizard.py | 23 +++++++++++
.../wizard/property_bills_wizard_views.xml | 20 ++++++++++
yuthon_work_brand/views/hr_menus.xml | 2 +-
16 files changed, 159 insertions(+), 73 deletions(-)
create mode 100644 yuthon_property_approval/models/property_bills_list.py
create mode 100644 yuthon_property_approval/views/property_bills_list_views.xml
create mode 100644 yuthon_property_approval/wizard/property_bills_wizard.py
create mode 100644 yuthon_property_approval/wizard/property_bills_wizard_views.xml
diff --git a/yuthon_property/views/property_accounts_receivable_views.xml b/yuthon_property/views/property_accounts_receivable_views.xml
index ef0ec2761..91ce9cf4e 100644
--- a/yuthon_property/views/property_accounts_receivable_views.xml
+++ b/yuthon_property/views/property_accounts_receivable_views.xml
@@ -5,6 +5,7 @@
+
@@ -13,12 +14,11 @@
-
+
-
diff --git a/yuthon_property_approval/__manifest__.py b/yuthon_property_approval/__manifest__.py
index 37e51fb0a..332fdab41 100644
--- a/yuthon_property_approval/__manifest__.py
+++ b/yuthon_property_approval/__manifest__.py
@@ -26,6 +26,7 @@
'views/property_eligibility.xml',
'views/yuthon_property_ledger_views.xml',
'views/property_lessee_analysis_viwes.xml',
+ 'views/property_bills_list_views.xml',
'views/property_fitment.xml',
'views/property_information.xml',
'views/property_inventory_table.xml',
@@ -93,6 +94,7 @@
'wizard/contract_signature_wizard_viwes.xml',
'wizard/penalty_line_wizard_viwes.xml',
'wizard/build_pop_wizard_viwes.xml',
+ 'wizard/property_bills_wizard_views.xml',
'wizard/property_meeting_wizard_views.xml',
'views/property_menu_all.xml',
],
diff --git a/yuthon_property_approval/models/__init__.py b/yuthon_property_approval/models/__init__.py
index 449809c66..992949364 100644
--- a/yuthon_property_approval/models/__init__.py
+++ b/yuthon_property_approval/models/__init__.py
@@ -59,4 +59,5 @@ from . import yuthon_property_ledger
from . import payment_process
from . import contract_accounts_receivable
from . import property_bills_payable
-from . import property_payment_notice
\ No newline at end of file
+from . import property_payment_notice
+from . import property_bills_list
\ No newline at end of file
diff --git a/yuthon_property_approval/models/property_bills_list.py b/yuthon_property_approval/models/property_bills_list.py
new file mode 100644
index 000000000..598347026
--- /dev/null
+++ b/yuthon_property_approval/models/property_bills_list.py
@@ -0,0 +1,31 @@
+from odoo import models, fields, api
+
+
+class PropertyBillsList(models.Model):
+ _name = 'property.bills.list'
+ _description = '应收账单'
+
+ management_type_id = fields.Many2one('yuthon.management.type', string='类型')
+ due_date = fields.Date(string='应付日期')
+ actual_date = fields.Date(string='实付日期')
+ amount = fields.Float(string='应付')
+ amount_actual = fields.Float(string='实付')
+ contract_id = fields.Many2one('property.lease.contract', string="合同编号")
+ lessee_id = fields.Many2one(related="contract_id.lessee_id", string="承租方", store=True)
+ property_name = fields.Char(related='contract_id.property_name', string="物业信息")
+
+ def action_pay(self):
+ return {
+ 'name': '支付账单弹窗',
+ 'type': 'ir.actions.act_window',
+ 'view_mode': 'form',
+ 'res_model': 'property.bills.wizard',
+ 'target': 'new',
+ 'context': {
+ 'default_bills_list_id': self.id,
+ }
+ }
+
+
+
+
diff --git a/yuthon_property_approval/models/property_bills_payable.py b/yuthon_property_approval/models/property_bills_payable.py
index aac495efb..9d94579aa 100644
--- a/yuthon_property_approval/models/property_bills_payable.py
+++ b/yuthon_property_approval/models/property_bills_payable.py
@@ -19,9 +19,13 @@ class PropertyBillsPayable(models.Model):
lease_contract_id = fields.Many2one('property.lease.contract', string="合同")
property_name = fields.Char(related='lease_contract_id.property_name', string="物业信息", index=True)
lessee_id = fields.Many2one(related="lease_contract_id.lessee_id", string='承租方', index=True)
+ due_date = fields.Date('应付日期')
+ amount_payable = fields.Float('应付金额')
+ deduction_amount = fields.Float('扣除金额')
+ actual_amount = fields.Float('实付金额')
+ remake = fields.Text(string='备注')
remarks = fields.Text(string='正文')
document_ids = fields.Many2many('ir.attachment', string="附件")
- bills_line_ids = fields.One2many('property.bills.line', 'payable_id', string="费用明细")
active = fields.Boolean('Active', default=True, tracking=True)
work_end = fields.Boolean(string="结束")
@@ -31,23 +35,22 @@ class PropertyBillsPayable(models.Model):
self_users_ids = fields.Many2many('res.users', string="当前经办人",
default=lambda self: [(6, 0, [self.env.user.id])])
+ @api.onchange('amount_payable', 'deduction_amount')
+ def _onchange_amount_payable(self):
+ if self.amount_payable and self.deduction_amount:
+ self.actual_amount = self.amount_payable - self.deduction_amount
+
def end_approval(self):
self.write({'work_end': True})
- receivable = self.env['property.accounts.receivable'].search([('contract_id', '=', self.lease_contract_id.id),
- ('management_type_id.name', '=', '押金')
- ])
- if receivable:
- receivable.write({'has_date': fields.Date.today()})
- self.lease_contract_id.contact_state = 'settle'
- self.lease_contract_id.compute_is_has()
-
+ management_type_id = self.env['yuthon.management.type'].search([('name', '=', '押金')], limit=1)
+ self.env['property.bills.list'].create({
+ 'due_date': fields.Date.today(),
+ 'management_type_id': management_type_id.id,
+ 'amount': self.amount_payable,
+ 'amount_actual': self.actual_amount,
+ 'contract_id': self.lease_contract_id.id,
+ })
class PropertyBillsLine(models.Model):
_name = 'property.bills.line'
_description = '账单明细'
-
- payable_id = fields.Many2one('property.bills.payable', string='关联应付账单')
- due_date = fields.Date('应付日期')
- date_actual = fields.Date('实付日期')
- management_type_id = fields.Many2one('yuthon.management.type', string='类型')
- original_amount = fields.Float('金额')
diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py
index 2d9612a8f..b3008644b 100644
--- a/yuthon_property_approval/models/property_lease_contract.py
+++ b/yuthon_property_approval/models/property_lease_contract.py
@@ -417,11 +417,8 @@ class PropertyLeaseContract(models.Model):
'context': {
'default_lease_contract_id': record.id,
'default_name': f'{record.contract_code}退押金申请',
- 'default_bills_line_ids': [(0, 0, {
- 'due_date': fields.Date.today(),
- 'management_type_id': management_type_id.id,
- 'original_amount': record.deposit
- })]
+ 'default_amount_payable': record.deposit,
+ 'default_actual_amount': record.deposit,
},
}
diff --git a/yuthon_property_approval/models/property_lease_renewal.py b/yuthon_property_approval/models/property_lease_renewal.py
index cce9ac074..2501a5e04 100644
--- a/yuthon_property_approval/models/property_lease_renewal.py
+++ b/yuthon_property_approval/models/property_lease_renewal.py
@@ -63,7 +63,6 @@ class PropertyLeaseRenewal(models.Model):
remake = fields.Text(string="备注")
receivables_ids = fields.One2many('early.receivables.line', 'renewal_id', string='应收明细')
- bills_record_id = fields.Many2one('property.bills.payable', string='应付账单流程')
@api.onchange('refund_amount')
def _onchange_refund_amount(self):
@@ -148,6 +147,7 @@ class PropertyLeaseRenewal(models.Model):
management_type_id = rec.env["yuthon.management.type"].search([('name', '=', '更名费')])
if not management_type_id:
management_type_id = rec.env["yuthon.management.type"].create({'name': '更名费'})
+
self.env['property.accounts.receivable'].create({
'contract_id': new_contract.id,
'original_amount': rec.fee,
@@ -183,14 +183,15 @@ class PropertyLeaseRenewal(models.Model):
if rec.receivables_ids:
refund_lines = rec.receivables_ids.filtered(lambda l: l.refund_amount > 0)
bills_line_list = []
- soong_workflow_line_list = []
+ # 除押金的明细
if refund_lines:
for refund_line in refund_lines:
- bills_line_list.append((0, 0, {
+ bills_line_list.append({
'due_date': fields.Date.today(),
'management_type_id': refund_line.management_type_id.id,
- 'original_amount': refund_line.refund_amount,
- }))
+ 'amount': refund_line.refund_amount,
+ 'contract_id': rec.contract_id.id,
+ })
if rec.is_full_refund:
deposit_management_type = self.env['yuthon.management.type'].search(
@@ -199,19 +200,12 @@ class PropertyLeaseRenewal(models.Model):
)
deposit_amount = rec.deposit if rec.is_full_refund else rec.refund_amount
if deposit_amount > 0:
- bills_line_list.append((0, 0, {
+ bills_line_list.append({
'due_date': fields.Date.today(),
'management_type_id': deposit_management_type.id,
- 'original_amount': deposit_amount,
- }))
-
- bills_payable = self.env['property.bills.payable'].create({
- 'code': self.env['ir.sequence'].next_by_code('property_bills_payable_code'),
- 'lease_contract_id': rec.contract_id.id,
- 'name': f'{rec.contract_id.contract_code}应付单',
- 'create_uid': self.env.uid,
- 'bills_line_ids': bills_line_list
- })
+ 'amount': deposit_amount,
+ 'contract_id': rec.contract_id.id,
+ })
if not rec.is_full_refund:
start_time = datetime.combine(rec.early_quitting_date, datetime.min.time().replace(hour=8, minute=00))
@@ -222,17 +216,9 @@ class PropertyLeaseRenewal(models.Model):
'remake': f'合同为{rec.contract_id.contract_code}{rec.remake}',
})
- workflow_record_id = self.env['soong.workflow.record'].search([
- ('code', '=', rec.code),
- ('res_id', '=', rec.id),
- ])
- soong_workflow_line_list.append((0, 0, {
- 'model': 'property.bills.payable',
- 'res_id': bills_payable.id,
- 'workflow_record_id': workflow_record_id.id
- }))
- self.bills_record_id = bills_payable.id
- bills_payable.soong_record_ids = soong_workflow_line_list
+ # 创建应付账单
+ if bills_line_list:
+ self.env['property.bills.list'].create(bills_line_list)
# 原有作废/减免逻辑保留
for receivable_id in rec.receivables_ids:
diff --git a/yuthon_property_approval/security/ir.model.access.csv b/yuthon_property_approval/security/ir.model.access.csv
index 3dee78668..42ded9296 100644
--- a/yuthon_property_approval/security/ir.model.access.csv
+++ b/yuthon_property_approval/security/ir.model.access.csv
@@ -120,4 +120,6 @@ access_early_receivables_line, early_receivables_line,model_early_receivables_li
access_property_bills_payable,property_bills_payable,model_property_bills_payable,base.group_user,1,1,1,1
access_property_bills_line,property_bills_line,model_property_bills_line,base.group_user,1,1,1,1
access_property_payment_notice,property_payment_notice,model_property_payment_notice,base.group_user,1,1,1,1
-access_print_payment_wizard,print_payment_wizard,model_print_payment_wizard,base.group_user,1,1,1,1
\ No newline at end of file
+access_print_payment_wizard,print_payment_wizard,model_print_payment_wizard,base.group_user,1,1,1,1
+access_property_bills_list,property_bills_list,model_property_bills_list,base.group_user,1,1,1,1
+access_property_bills_wizard,property_bills_wizard,model_property_bills_wizard,base.group_user,1,1,1,1
\ No newline at end of file
diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
index 2cf30e740..44a91a808 100644
--- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml
+++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
@@ -410,7 +410,7 @@
-
+
@@ -432,6 +432,8 @@
+
+
diff --git a/yuthon_property_approval/views/property_bills_list_views.xml b/yuthon_property_approval/views/property_bills_list_views.xml
new file mode 100644
index 000000000..af9f2a0a0
--- /dev/null
+++ b/yuthon_property_approval/views/property_bills_list_views.xml
@@ -0,0 +1,30 @@
+
+
+
+ property.bills.list.tree
+ property.bills.list
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 应收账单
+ property.bills.list
+ tree
+
+
+
+
+
+
+
diff --git a/yuthon_property_approval/views/property_bills_payable_views.xml b/yuthon_property_approval/views/property_bills_payable_views.xml
index 2cfda0ba9..8a03b3f76 100644
--- a/yuthon_property_approval/views/property_bills_payable_views.xml
+++ b/yuthon_property_approval/views/property_bills_payable_views.xml
@@ -4,7 +4,7 @@
property.bills.payable.tree
property.bills.payable
-
+
@@ -15,7 +15,7 @@
property.bills.payable.form
property.bills.payable
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 应付账单
+ 应付账单审批
property.bills.payable
tree,form
diff --git a/yuthon_property_approval/views/property_lease_renewal.xml b/yuthon_property_approval/views/property_lease_renewal.xml
index fcb88cfb3..54042313c 100644
--- a/yuthon_property_approval/views/property_lease_renewal.xml
+++ b/yuthon_property_approval/views/property_lease_renewal.xml
@@ -94,9 +94,6 @@
-
-
-
diff --git a/yuthon_property_approval/wizard/__init__.py b/yuthon_property_approval/wizard/__init__.py
index 218307a02..c7b3bb482 100644
--- a/yuthon_property_approval/wizard/__init__.py
+++ b/yuthon_property_approval/wizard/__init__.py
@@ -12,4 +12,5 @@ from . import binding_information_wizard
from . import contract_signature_wizard
from . import build_pop_wizard
from . import penalty_line_wizard
-from . import print_payment_wizard
\ No newline at end of file
+from . import print_payment_wizard
+from . import property_bills_wizard
\ No newline at end of file
diff --git a/yuthon_property_approval/wizard/property_bills_wizard.py b/yuthon_property_approval/wizard/property_bills_wizard.py
new file mode 100644
index 000000000..0b6ca64f6
--- /dev/null
+++ b/yuthon_property_approval/wizard/property_bills_wizard.py
@@ -0,0 +1,23 @@
+from odoo import models, fields, api
+
+
+class PropertyBillsWizard(models.TransientModel):
+ _name = 'property.bills.wizard'
+ _description = '应收账单弹窗'
+
+ bills_list_id = fields.Many2one('property.bills.list', string="账单")
+ actual_date = fields.Date(string='实付日期')
+
+ def confirm(self):
+ self.bills_list_id.actual_date = self.actual_date
+ self.bills_list_id.state = 'paid'
+ receivable = self.env['property.accounts.receivable'].search([('contract_id', '=', self.bills_list_id.contract_id.id),
+ ('management_type_id.name', '=', '押金')
+ ])
+ if receivable:
+ receivable.write({'has_date': fields.Date.today()})
+ self.bills_list_id.contract_id.contact_state = 'settle'
+ self.lease_contract_id.compute_is_has()
+
+
+
diff --git a/yuthon_property_approval/wizard/property_bills_wizard_views.xml b/yuthon_property_approval/wizard/property_bills_wizard_views.xml
new file mode 100644
index 000000000..8f7c1b509
--- /dev/null
+++ b/yuthon_property_approval/wizard/property_bills_wizard_views.xml
@@ -0,0 +1,20 @@
+
+
+
+ 应收账单弹窗
+ property.bills.wizard
+
+
+
+
+
+
+
+
diff --git a/yuthon_work_brand/views/hr_menus.xml b/yuthon_work_brand/views/hr_menus.xml
index dfa62abd3..7f6ca430b 100644
--- a/yuthon_work_brand/views/hr_menus.xml
+++ b/yuthon_work_brand/views/hr_menus.xml
@@ -845,7 +845,7 @@
id="property_bills_payable_menu"
parent="yuthon_financial_management_menu"
name="应付账单"
- action="yuthon_property_approval.view_property_bills_payable_action"
+ action="yuthon_property_approval.view_property_bills_list_action"
sequence="4"/>