From 60f3449c7c9836d2a97f3d69f3de511646ed438f 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: Tue, 11 Nov 2025 10:58:58 +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
---
.../models/property_bank_statements.py | 2 +-
.../models/inherit_yuthon_property.py | 20 ++++++
.../models/property_lease_contract.py | 11 ++--
.../models/property_merge_approval.py | 15 +++--
.../views/inherit_yuthon_property_views.xml | 2 +-
.../views/property_merge_approval_views.xml | 6 +-
.../wizard/binding_information_wizard.py | 64 +++++++++++++------
.../binding_information_wizard_views.xml | 3 +-
.../wizard/property_reconciliation_wizard.py | 50 ++++-----------
9 files changed, 101 insertions(+), 72 deletions(-)
diff --git a/yuthon_property/models/property_bank_statements.py b/yuthon_property/models/property_bank_statements.py
index c2492de85..4db309f7d 100644
--- a/yuthon_property/models/property_bank_statements.py
+++ b/yuthon_property/models/property_bank_statements.py
@@ -33,7 +33,7 @@ class PropertyBankStatements(models.Model):
contract_penalty = fields.Char(string="合同累计违约金")
original_amount = fields.Float(string='交易金额')
lending_direction = fields.Selection([('borrow', '借'), ('loan', '贷')], string='借贷方向')
- yes_amount = fields.Float(stringo='已对')
+ yes_amount = fields.Float(string='已对')
no_amount = fields.Float(string='未对', compute='_compute_no_amount')
reconciliation_time = fields.Datetime('对账时间')
voucher_type = fields.Selection([('electronic_transfer', '电子转账凭证'), ('telegraphic_transfer', '电汇凭证')], string='凭证种类')
diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py
index 9e1019902..40be9dc34 100644
--- a/yuthon_property_approval/models/inherit_yuthon_property.py
+++ b/yuthon_property_approval/models/inherit_yuthon_property.py
@@ -558,6 +558,7 @@ class PropertyBankStatements(models.Model):
statements = self.env['property.bank.statements'].search([
('name', '=', account),
('start_time', '<', current_transaction_time - timedelta(hours=8)),
+ ('your_own_unit', '=', self.your_own_unit),
('bank_state', '=', 'not_reconciled'),
('id', '!=', self.id),
])
@@ -1018,6 +1019,25 @@ class PropertyRentList(models.Model):
property_address = fields.Text(string="物业信息", compute='get_property_address')
contract_sort = fields.Selection(related='contract_id.contract_sort', string="资产类型", store=True)
company_id = fields.Many2one(related='contract_id.lessor_id', string="出租方公司", store=True)
+ is_company = fields.Boolean(string='是否是本公司', compute='_compute_is_company', store=False)
+
+ @api.depends('company_id')
+ @api.depends_context('uid', 'company')
+ def _compute_is_company(self):
+ user_companies = self.env['res.company'].browse(self.env.companies.ids)
+ user_company_names = set(user_companies.mapped('name'))
+ account_mapping = {
+ '集团本部': ['天河投资', '天投城建'],
+ '天河物管': ['天河物管'],
+ '天河粮储': ['天河粮储']
+ }
+ for record in self:
+ record.is_company = False
+ for company_name, allowed_accounts in account_mapping.items():
+ if company_name in user_company_names:
+ if record.company_id.referred in allowed_accounts:
+ record.is_company = True
+ break
@api.depends('contract_id')
def get_property_address(self):
diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py
index c6b2ff9bf..72c59d967 100644
--- a/yuthon_property_approval/models/property_lease_contract.py
+++ b/yuthon_property_approval/models/property_lease_contract.py
@@ -1945,30 +1945,30 @@ class PropertyLeaseContract(models.Model):
line.copy({'contract_id': new_contract.id})
# 复制电费明细行
electric_lines = self.env['property.electric.fee.line'].search([
- ('contract_id', '=', lease_contract_ids.contract_id.id)
+ ('contract_id', '=', lease_contract_ids.id)
])
for line in electric_lines:
line.copy({'contract_id': new_contract.id})
# 复制物业管理费明细行
manage_lines = self.env['property.manage.fee.line'].search([
- ('contract_id', '=', lease_contract_ids.contract_id.id)
+ ('contract_id', '=', lease_contract_ids.id)
])
for line in manage_lines:
line.copy({'contract_id': new_contract.id})
# 复制其他费用明细行
other_lines = self.env['property.other.fee.line'].search([
- ('other_id', '=', lease_contract_ids.contract_id.id)
+ ('other_id', '=', lease_contract_ids.id)
])
for line in other_lines:
line.copy({'other_id': new_contract.id})
# 复制子合同明细
subset_lines = self.env['property.subset.contract'].search([
- ('subset_id', '=', lease_contract_ids.contract_id.id)
+ ('subset_id', '=', lease_contract_ids.id)
])
for line in subset_lines:
line.copy({'subset_id': new_contract.id})
lease_lines = self.env['property.lease.contract.line'].search([
- ('lease_id', '=', lease_contract_ids.contract_id.id)
+ ('lease_id', '=', lease_contract_ids.id)
])
for line in lease_lines:
line.copy({'lease_id': new_contract.id})
@@ -1976,6 +1976,7 @@ class PropertyLeaseContract(models.Model):
new_contract.write({
'version': new_version,
'condition': 'new',
+ 'contact_state': 'to',
})
return {
'type': 'ir.actions.act_window',
diff --git a/yuthon_property_approval/models/property_merge_approval.py b/yuthon_property_approval/models/property_merge_approval.py
index 2f7d28d89..31494df59 100644
--- a/yuthon_property_approval/models/property_merge_approval.py
+++ b/yuthon_property_approval/models/property_merge_approval.py
@@ -20,8 +20,8 @@ class PropertyMergeApproval(models.Model):
merge_units = fields.Char(string='单元')
merge_property_floor_id = fields.Many2one('property.floor.setting', string='楼层')
merge_asset_type_id = fields.Many2one('yuthon.resource.type', string='资产类型')
- merge_building_area = fields.Float(string='建筑面积', digits=(16, 4))
- merge_rent_area = fields.Float(string='可租面积')
+ management_area = fields.Float(string='管理面积', digits=(16, 4))
+ merge_rent_area = fields.Float(string='可租面积', digits=(16, 4))
merge_remarks = fields.Char(string='备注')
is_issues = fields.Boolean(string='是否上会')
issues_result = fields.Html(string="会议结果")
@@ -42,16 +42,16 @@ class PropertyMergeApproval(models.Model):
@api.onchange('property_merge_approval_line_ids')
def _onchange_property_merge_approval_line_ids(self):
name = []
- merge_building_area = 0
+ management_area = 0
merge_rent_area = 0
if self.property_merge_approval_line_ids:
for property_margin in self.property_merge_approval_line_ids:
property_name = str(property_margin.property_id.name) if property_margin.property_id.name else ""
name.append(property_name)
- merge_building_area += property_margin.building_area
+ management_area += property_margin.management_area
merge_rent_area += property_margin.rent_area
self.property_name = ','.join(name)
- self.merge_building_area = merge_building_area
+ self.management_area = management_area
self.merge_rent_area = merge_rent_area
def put_merge_message(self):
@@ -60,7 +60,7 @@ class PropertyMergeApproval(models.Model):
property_id = source_property.with_context(skip_contract_code_check=True).copy()
property_id.write({
'name': self.property_name,
- 'building_area': self.merge_building_area,
+ 'building_area': self.management_area,
'rent_area': self.merge_rent_area,
'effective_date': self.start_date,
'is_done_split': True,
@@ -107,6 +107,7 @@ class PropertyMergeApproval(models.Model):
latest_line.write({'end_date': self.start_date})
latest_line.copy({
'rent_area': self.merge_rent_area,
+ 'management_area': self.management_area,
'yuthon_property_id': property_id.id
})
property_id.manage_information_ids.write({'start_time': self.start_date,
@@ -138,7 +139,7 @@ class PropertyMergeApprovalLine(models.Model):
units = fields.Char(related='property_id.units', string='单元')
property_floor_id = fields.Many2one(related='property_id.property_floor_id', string='楼层')
asset_type_id = fields.Many2one(related='property_id.asset_type_id', string='资产类型')
- building_area = fields.Float(related='property_id.building_area', string='建筑面积', digits=(16, 4))
+ management_area = fields.Float(related='property_id.management_area', string='管理面积', digits=(16, 4))
rent_area = fields.Float(related='property_id.rent_area', string='可租面积', digits=(16, 4))
remarks = fields.Char(string='备注')
diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
index b460fba46..54c0bfa66 100644
--- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml
+++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
@@ -159,7 +159,7 @@
租金列表
property.rent.list
tree,search
- [('is_push', '=', False)]
+ [('is_push', '=', False), ('is_company', '=', True)]
{'search_default_group_admin_id': True, 'search_default_group_due_date': True}
diff --git a/yuthon_property_approval/views/property_merge_approval_views.xml b/yuthon_property_approval/views/property_merge_approval_views.xml
index 4d0a8f5d8..424a134ab 100644
--- a/yuthon_property_approval/views/property_merge_approval_views.xml
+++ b/yuthon_property_approval/views/property_merge_approval_views.xml
@@ -8,7 +8,7 @@
-
+
@@ -67,7 +67,7 @@
-
+
@@ -82,7 +82,7 @@
-
+
diff --git a/yuthon_property_approval/wizard/binding_information_wizard.py b/yuthon_property_approval/wizard/binding_information_wizard.py
index e1419fa58..d4b017603 100644
--- a/yuthon_property_approval/wizard/binding_information_wizard.py
+++ b/yuthon_property_approval/wizard/binding_information_wizard.py
@@ -20,6 +20,15 @@ class BindingInformationWizard(models.Model):
string='可用物业ID',
store=True
)
+ available_contract_ids = fields.Many2many(
+ 'property.lease.contract',
+ 'binding_information_wizard_available_contract_rel',
+ 'wizard_id',
+ 'contract_id',
+ compute='_compute_available_records',
+ string='可用合同ID',
+ store=True
+ )
@api.onchange('contract_ids')
def onchange_contract_ids(self):
@@ -37,17 +46,29 @@ class BindingInformationWizard(models.Model):
if new_property_ids:
self.property_ids = [(4, property_id) for property_id in new_property_ids]
+ @api.onchange('bank_id')
+ def _onchange_bank_id(self):
+ """计算可用的物业和合同ID"""
+ for record in self:
+ # 搜索未对账的应收记录
+ unreconciled_records = self.env['property.accounts.receivable'].search([
+ ('is_reconciliation', '=', False)
+ ])
+ contract_ids = list(set(record.contract_id.id for record in unreconciled_records if record.contract_id))
+
+ # 设置计算字段值
+ record.available_contract_ids = [(6, 0, contract_ids)] if contract_ids else [(5,)]
def confirm(self):
if self.bank_id.name:
- bank_ids = self.env['property.bank.statements'].search([('name', '=', self.bank_id.name),
- ('your_own_unit', '=', self.bank_id.your_own_unit)])
- for bank_id in bank_ids:
- if self.contract_ids:
- bank_id.write({
- 'contract_ids': [(6, 0, self.contract_ids.ids)],
- 'admin_id': self.contract_ids[0].admin_id.id if self.contract_ids[0].admin_id else False
+ if self.contract_ids:
+ new_contracts = self.contract_ids - self.bank_id.contract_ids
+ if new_contracts:
+ self.bank_id.write({
+ 'contract_ids': [(4, cont.id) for cont in new_contracts]
})
+
+ # 根据银行账号查找承租方信息
bank_account = self.env['property.bank.line'].search([
('bank', '=', self.bank_id.name),
('tenant_id.name', '!=', False),
@@ -61,18 +82,25 @@ class BindingInformationWizard(models.Model):
if invalid_bank_lines:
invalid_bank_lines.unlink()
+ bank_ids = self.env['property.bank.statements'].search([('name', '=', self.bank_id.name),
+ ('your_own_unit', '=',
+ self.bank_id.your_own_unit)])
+ for bank_id in bank_ids:
+ bank_id.write({
+ 'contract_ids': [(6, 0, self.bank_id.contract_ids.ids)],
+ })
+
if bank_account:
- all_contracts = self.contract_ids
- for contract in all_contracts:
- tenant_id = self.env['property.tenant.line'].sudo().search([
- ('tenant_id', '=', bank_account.tenant_id.id),
- ('lease_contract_id', '=', contract.id),
- ])
- if not tenant_id:
- self.env['property.tenant.line'].sudo().create({
- 'tenant_id': bank_account.tenant_id.id,
- 'lease_contract_id': contract.id,
- })
+ # 获取已存在的合同明细行的合同ID
+ existing_contract_ids = bank_account.tenant_id.property_contract_ids.mapped('lease_contract_id.id')
+ all_contracts = self.contract_ids | self.bank_id.contract_ids
+ # 过滤出需要新增的合同(排除已存在的)
+ new_contracts = all_contracts.filtered(lambda c: c.id not in existing_contract_ids)
+ for contract in new_contracts:
+ self.env['property.tenant.line'].sudo().create({
+ 'tenant_id': bank_account.tenant_id.id,
+ 'lease_contract_id': contract.id,
+ })
else:
tenant = self.env['property.tenant.information'].create({
'name': self.bank_id.name_account,
diff --git a/yuthon_property_approval/wizard/binding_information_wizard_views.xml b/yuthon_property_approval/wizard/binding_information_wizard_views.xml
index f13d73afd..b334dae9c 100644
--- a/yuthon_property_approval/wizard/binding_information_wizard_views.xml
+++ b/yuthon_property_approval/wizard/binding_information_wizard_views.xml
@@ -10,9 +10,10 @@
+
-
+