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