From aa2c1604d1f78aad72824884ccf3b752ae2594a0 Mon Sep 17 00:00:00 2001 From: ymq Date: Wed, 26 Aug 2026 18:10:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(suppliers):=20=E5=BA=93=E5=90=8D=E5=86=99?= =?UTF-8?q?=E6=AD=BB=20sage=20=E6=94=B9=20get=5Fmodule=5Fdbname=20?= =?UTF-8?q?=E8=B7=A8=E5=BA=94=E7=94=A8=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 单库应用(如 pipeline)get_module_dbname 全返回主库,写死 'sage' 会把供应商 机构写到错库。开户旁路化:失败不阻断供应商创建。 --- wwwroot/api/suppliers_create.dspy | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/wwwroot/api/suppliers_create.dspy b/wwwroot/api/suppliers_create.dspy index 8b1e019..5af5436 100644 --- a/wwwroot/api/suppliers_create.dspy +++ b/wwwroot/api/suppliers_create.dspy @@ -32,10 +32,18 @@ try: 'updated_at': now_org } db = DBPools() - async with db.sqlorContext('sage') as sor_sage: - await sor_sage.C('organization', org_rec) - # 开账:accounting_orgid='0', 当前用户与供应商的往来账 - await openRetailRelationshipAccounts(sor_sage, '0', new_orgid, user_orgid) + # 库名用 get_module_dbname 跨应用取(单库应用全返回主库,不能写死 'sage') + org_dbname = get_module_dbname('rbac') + acc_dbname = get_module_dbname('accounting') + async with db.sqlorContext(org_dbname) as sor_org: + await sor_org.C('organization', org_rec) + # 开账:accounting_orgid='0', 当前用户与供应商的往来账(旁路,失败不阻断创建) + try: + async with db.sqlorContext(acc_dbname) as sor_acc: + await openRetailRelationshipAccounts(sor_acc, '0', new_orgid, user_orgid) + await sor_acc.sqlExe("COMMIT", {}) + except Exception as _acc_e: + debug(f'suppliers_create: open accounts skipped: {_acc_e}') data['orgid'] = new_orgid