From 21fcae435b62ab9bbfd0b76723f91f53f3007d76 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Tue, 4 Mar 2025 12:19:47 +0800 Subject: [PATCH] bugfix --- platformbiz/product.py | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 platformbiz/product.py diff --git a/platformbiz/product.py b/platformbiz/product.py new file mode 100644 index 0000000..6203587 --- /dev/null +++ b/platformbiz/product.py @@ -0,0 +1,56 @@ +from appPublic.uniqueID import getID +from appPublic.log import debug +from accounting.openaccount import openRetailRelationshipAccounts + +asunc def get_accounting_orgid(sor): + return '0' + +async def agree_products_clone(sor, orgid, agreeid): + """ + adid:agreedetailid + sor: + return None + """ + sql = """select a.id, +a.name, +a.prodtypeid, +a.description, +a.prod_state, +a.product_code, +a.spec_note, +d.id as agreeid, +d.providerid, +d.resellerid +from product a, agreeproduct b, agreedetail c, agreement d +where a.id = b.providerpid + and b.resellerpid is null + and c.id = b.agreedetailid + and d.id = c.agreeid + and d.id = ${agreeid}$ + and a.orgid = ${orgid}$ +""" + recs = await sor.sqlExe(sql, {'agreeid':agreeid, 'orgid':orgid}) + if len(recs) < 1: + debug(f'{orgid=}, {agreeid=}, {sql=}: found no data') + return + + for rec in recs: + d = { + "id":getID(), + "name":rec.name, + "prodtypeid":rec.prodtypeid, + "orgid":rec.resellerid, + "providerid":rec.providerid, + "agreeid":rec.agreeid, + "providerpid":rec.id, + "description":rec.description, + "prod_state":rec.prod_state, + "product_code":rec.product_code, + "spec_note":rec.spec_note + } + await sor.C('product', d) + +async def open_agree_account(sor, providerid, sellerid): + accounting_orgid = await get_accounting_orgid(sor) + await openRetailRelationshipAccounts(sor, accounting_orgid, providerid, sellerid) +