diff --git a/yuthon_property/views/property_bank_statements_views.xml b/yuthon_property/views/property_bank_statements_views.xml
index 4c8c6c172..8e760fb12 100644
--- a/yuthon_property/views/property_bank_statements_views.xml
+++ b/yuthon_property/views/property_bank_statements_views.xml
@@ -87,6 +87,7 @@
+
diff --git a/yuthon_property/wizard/property_statements_wizard.py b/yuthon_property/wizard/property_statements_wizard.py
index 455c2ac10..ab9396d31 100644
--- a/yuthon_property/wizard/property_statements_wizard.py
+++ b/yuthon_property/wizard/property_statements_wizard.py
@@ -466,26 +466,46 @@ class PropertyStatementsWizard(models.Model):
# self.env['property.bank.statements'].create(bank_data)
def _get_company_by_unit(self, unit_name):
- """根据账号单位返回对应公司"""
+ """根据简称匹配 yuthon.property.company 配置,再匹配 res.company"""
+ if not unit_name:
+ return False
+ # 先从物业公司配置表找到全称
+ company_config = self.env['yuthon.property.company'].sudo().search(
+ [('referred', '=', unit_name)], limit=1
+ )
+ if not company_config:
+ return False
+ # 用全称匹配 res.company
+ company = self.env['res.company'].sudo().search(
+ [('name', '=', company_config.name)], limit=1
+ )
+ if company:
+ return company
+ # 如果全称匹不到,兼容旧逻辑
if unit_name in ['天河投资', '天投城建']:
- return self.env['res.company'].search([('name', '=', '集团本部')], limit=1)
+ return self.env['res.company'].sudo().search([('name', '=', '集团本部')], limit=1)
elif unit_name == '天河物管':
- return self.env['res.company'].search([('name', '=', '天河物管')], limit=1)
+ return self.env['res.company'].sudo().search([('name', '=', '天河物管')], limit=1)
elif unit_name == '天河粮储':
- return self.env['res.company'].search([('name', '=', '天河粮储')], limit=1)
+ return self.env['res.company'].sudo().search([('name', '=', '天河粮储')], limit=1)
return False
def classify_by_last_four(self, input_str):
- if not isinstance(input_str, str) or len(input_str) < 4:
- return "天投城建" # 输入不是字符串或长度不足4,默认为天投城建
-
- last_four = input_str[-4:] # 获取后四位字符
-
- if last_four == "3619":
- return "天河物管"
- elif last_four == "0222":
- return "天河投资"
- elif last_four == "9661":
- return "天河粮储"
- else:
- return "天投城建"
\ No newline at end of file
+ """根据本方账号匹配 yuthon.property.company 中的收租公司账号,返回简称"""
+ if not isinstance(input_str, str) or not input_str.strip():
+ return ''
+ account = input_str.strip()
+ # 从物业公司配置表中查找匹配的收租公司账号
+ company_config = self.env['yuthon.property.company'].sudo().search(
+ [('rent_account', '=', account)], limit=1
+ )
+ if company_config and company_config.referred:
+ return company_config.referred
+ # 兼容旧逻辑:账号后四位模糊匹配
+ last_four = account[-4:] if len(account) >= 4 else ''
+ company_config = self.env['yuthon.property.company'].sudo().search(
+ [('rent_account', 'like', last_four)], limit=1
+ )
+ if company_config and company_config.referred:
+ return company_config.referred
+ return ''
\ No newline at end of file