Commit 588aeb06 by 夏超

[fix] 大东联推送

parent 1b2cc3c1
......@@ -14,8 +14,12 @@ class InheritRokeResultPutWarehouseWizard(models.TransientModel):
@api.model
def default_get(self, field_names):
if self.env.context.get('active_model') != "roke.production.result" or \
self.env._context.get('active_model') != "roke.production.result":
return super(InheritRokeResultPutWarehouseWizard, self).default_get(field_names)
results = self.env['roke.production.result'].browse(self.env.context.get('active_ids') or
self.env._context.get('active_ids'))
self.env._context = None
system_id = self.env.ref("roke_workstation_sync_ps.roke_workstation_sync_ps_integrate_system")
sync_address = system_id.sync_address
sync_port = system_id.sync_port
......@@ -26,9 +30,11 @@ class InheritRokeResultPutWarehouseWizard(models.TransientModel):
conn = pymssql.connect(host=sync_address, user=sync_uname, password=sync_passwd, database=db_name)
cur = conn.cursor()
except Exception as e:
_logger.info("数据库链接失败,请检查数据库链接参数")
raise ValidationError("数据库链接失败,请检查数据库链接参数")
ids_str = [f"'{v.id}'" for v in results]
if not ids_str:
_logger.info("数据不需要同步")
return super(InheritRokeResultPutWarehouseWizard, self).default_get(field_names)
sql = f"""
select WBCCB_CCID
......@@ -73,9 +79,12 @@ class InheritRokeResultPutWarehouseWizard(models.TransientModel):
try:
cur.execute(sql)
conn.commit()
_logger.info("数据同步成功")
cur.execute(storage_sql)
conn.commit()
_logger.info("存储过程运行成功")
except Exception as e:
_logger.info("数据上传失败")
raise ValidationError("数据上传失败")
finally:
cur.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment