This commit is contained in:
李鹏宇
2026-04-03 10:41:03 +08:00
parent 59306ef2a5
commit f8cf88a384
2 changed files with 23 additions and 14 deletions
@@ -33,7 +33,7 @@
<field name="your_own_account" optional="hide"/>
<field name="your_own_unit" optional="hide"/>
<header>
<button name="other" type="object" class="oe_highlight" string="其他"/>
<button name="other" type="object" class="oe_highlight" string="其他"/>
</header>
<field name="name_account"/>
<field name="bank_branch"/>
@@ -46,7 +46,6 @@
<field name="your_own_account"/>
<field name="extract"/>
<field name="remake"/>
<field name="marking"/>
<field name="bank_state"/>
<field name="workflow_record_id" column_invisible="1"/>
<button name="open_record" string="流程" type="object" class="btn-primary" invisible="not workflow_record_id"/>
@@ -88,7 +87,6 @@
<field name="name_account"/>
<field name="name"/>
<field name="original_amount"/>
<field name="your_own_account" string="本方账号"/>
</search>
</field>
</record>
@@ -137,8 +135,7 @@
<field name="management_type_id"/>
<field name="is_penalty"/>
<field name="has_date"/>
<field name="reconciliation_date"/>
<field name="operation_date"/>
<field name="payout_date"/>
<button name="open_receivable" string="应收账单" type="object" class="btn btn-blue"/>
<button name="open_bank_statement" string="银行流水" type="object" class="btn btn-blue"/>
<button name="open_penalty_pay_lines" string="收款明细" type="object" class="btn btn-blue"/>
@@ -159,7 +156,6 @@
<field name="receivable_id"/>
<field name="company_id"/>
<field name="precinct_id"/>
<field name="operation_date"/>
</tree>
</field>
</record>
@@ -223,11 +219,4 @@
<field name="state">code</field>
<field name="code">action = model.update_company_id()</field>
</record>
<record id="all_update_your_own_unit" model="ir.actions.server">
<field name="name">更新账号单位</field>
<field name="model_id" ref="yuthon_property.model_property_bank_statements"/>
<field name="binding_model_id" ref="yuthon_property.model_property_bank_statements"/>
<field name="state">code</field>
<field name="code">action = model.update_your_own_unit()</field>
</record>
</odoo>
@@ -491,13 +491,16 @@ class PropertyStatementsWizard(models.Model):
lending_direction = 'borrow'
amount_str = get_val(8).replace(',', '') # I列:发生额
else:
_logger.info('[xy_debug] 跳过:direction_val=%r 行首=%r', direction_val, get_val(0))
return
try:
original_amount = float(amount_str)
except Exception:
_logger.info('[xy_debug] 金额转换失败:amount_str=%r', amount_str)
return
if not original_amount:
_logger.info('[xy_debug] 金额为0跳过')
return
name = get_val(9) # 对方账号
@@ -510,6 +513,7 @@ class PropertyStatementsWizard(models.Model):
your_own_unit = self.classify_by_last_four(your_own_account)
company_id = self._get_company_by_unit(your_own_unit)
if not company_id:
_logger.info('[xy_debug] 公司匹配失败:your_own_account=%r your_own_unit=%r', your_own_account, your_own_unit)
return
dedup_key = serial_number if serial_number and serial_number != '0' else (time_val + name)
@@ -536,12 +540,28 @@ class PropertyStatementsWizard(models.Model):
existing_record.write(bank_data)
def _get_company_by_unit(self, unit_name):
if unit_name in ['天河投资', '天投城建', '兴源公司']:
"""根据简称匹配 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 company_config:
# 用全称匹配 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'].sudo().search([('name', '=', '集团本部')], limit=1)
elif unit_name == '天河物管':
return self.env['res.company'].sudo().search([('name', '=', '天河物管')], limit=1)
elif unit_name == '天河粮储':
return self.env['res.company'].sudo().search([('name', '=', '天河粮储')], limit=1)
_logger.warning('[银行流水导入] 未能匹配公司: unit_name=%s', unit_name)
return False
def classify_by_last_four(self, input_str):