!11780 ai动态报表

Merge pull request !11780 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2026-05-29 08:05:35 +00:00
committed by Gitee
2 changed files with 43 additions and 1 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
'author': 'pengyuthon',
'website': 'https://www.pengyuthon.com',
'category': 'Human Resources/Attendances',
'version': '0.1',
'version': '17.0.0.2',
'license': 'LGPL-3',
'depends': ['mail', 'hr', 'soong_workflow', 'room', 'yuthon_issue', 'yuthon_trade'],
'data': [
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
# 迁移脚本:修复 yuthon.official.party 主送单位 Many2many 字段列名错误
# 旧的字段定义少了个逗号,导致 column1 变成 'official_idflat_id'
# 新版本修正为 'official_id',需要先重命名旧列
def migrate(cr, version):
# 检查关系表是否存在
cr.execute("""
SELECT EXISTS (
SELECT FROM information_schema.tables
WHERE table_name = 'yuthon_official_party_main_flats_rel'
)
""")
if not cr.fetchone()[0]:
return
# 检查是否有旧的错误列名
cr.execute("""
SELECT column_name FROM information_schema.columns
WHERE table_name = 'yuthon_official_party_main_flats_rel'
""")
cols = [r[0] for r in cr.fetchall()]
if 'official_idflat_id' in cols:
# 旧列存在,创建正确的新列并迁移数据
cr.execute("ALTER TABLE yuthon_official_party_main_flats_rel ADD COLUMN IF NOT EXISTS official_id INTEGER")
cr.execute("ALTER TABLE yuthon_official_party_main_flats_rel ADD COLUMN IF NOT EXISTS flat_id INTEGER")
cr.execute("""
UPDATE yuthon_official_party_main_flats_rel
SET official_id = official_idflat_id::integer
WHERE official_idflat_id IS NOT NULL
""")
# 删除旧列
cr.execute("ALTER TABLE yuthon_official_party_main_flats_rel DROP COLUMN IF EXISTS official_idflat_id")
# 删除可能存在的旧 yuthon_official_party_main_flats_rel_id 自动列
cr.execute("""
SELECT column_name FROM information_schema.columns
WHERE table_name = 'yuthon_official_party_main_flats_rel'
AND column_name LIKE '%rel_id'
""")
for row in cr.fetchall():
cr.execute(f'ALTER TABLE yuthon_official_party_main_flats_rel DROP COLUMN IF EXISTS "{row[0]}"')