Commit 6b6faf72 by 夏超

[fix] 上推员工数据修改

parent fd109ef3
...@@ -96,10 +96,13 @@ class InheritRokeWorkstationPicking(RokeWorkstationPicking): ...@@ -96,10 +96,13 @@ class InheritRokeWorkstationPicking(RokeWorkstationPicking):
task_id_list = [] task_id_list = []
task_id_dict = {} task_id_dict = {}
# 用户id
user_id = http.request.uid or http.request.session.uid
# 人员id
emp = http.request.env['roke.employee'].search([('user_id', '=', user_id)], limit=1)
for v in line_data: for v in line_data:
product = http.request.env["roke.product"].sudo().search([("id", "=", v.get("material_id", 0))]) product = http.request.env["roke.product"].sudo().search([("id", "=", v.get("material_id", 0))])
task_id = http.request.env["roke.production.task"].sudo().search([("id", "=", v.get("task_id", 0))]) task_id = http.request.env["roke.production.task"].sudo().search([("id", "=", v.get("task_id", 0))])
_logger.info(f"aaaa____________{v.get('demand_qty', 0)}")
task_id_list.append({ task_id_list.append({
"material_code": product.code or "", "material_code": product.code or "",
"code": task_id.code or "", "code": task_id.code or "",
...@@ -167,13 +170,14 @@ class InheritRokeWorkstationPicking(RokeWorkstationPicking): ...@@ -167,13 +170,14 @@ class InheritRokeWorkstationPicking(RokeWorkstationPicking):
except Exception as e: except Exception as e:
return {"code": 1, "message": "数据库链接失败,请检查数据库链接参数", "data": None} return {"code": 1, "message": "数据库链接失败,请检查数据库链接参数", "data": None}
sql = """ sql = """
INSERT INTO WBLLD (WBLLD_RWBH, WBLLD_CPBH, WBLLD_XQSL, WBLLD_LLSL, WBLLD_datetime) INSERT INTO WBLLD (WBLLD_RWBH, WBLLD_CPBH, WBLLD_XQSL, WBLLD_LLSL, WBLLD_datetime, WBLLD_YGBH, WBLLD_YGMC)
VALUES VALUES
""" """
sql_list = [] sql_list = []
for v in task_id_list: for v in task_id_list:
sql_list.append(f""" sql_list.append(f"""
('{v.get("code", "")}', '{v.get("material_code", "")}', {v.get("demand_qty", 0)}, {v.get("qty", 0)}, '{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}') ('{v.get("code", "")}', '{v.get("material_code", "")}', {v.get("demand_qty", 0)}, {v.get("qty", 0)},
'{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}', '{emp.code or ""}', '{emp.name or ""}')
""") """)
if not sql_list: if not sql_list:
return {"code": 1, "message": "数据错误,请检查数据结构", "data": None} return {"code": 1, "message": "数据错误,请检查数据结构", "data": None}
......
...@@ -51,15 +51,18 @@ class InheritRokeResultPutWarehouseWizard(models.TransientModel): ...@@ -51,15 +51,18 @@ class InheritRokeResultPutWarehouseWizard(models.TransientModel):
insert_id = [] insert_id = []
for v in rows_data: for v in rows_data:
insert_id.append(v.get("WBCCB_CCID", 0)) insert_id.append(v.get("WBCCB_CCID", 0))
em = self.env["roke.employee"].search([("user_id", "=", self.env.uid)], limit=1)
insert_sql_data = [] insert_sql_data = []
for v in results: for v in results:
if v.id in insert_id: if v.id in insert_id:
continue continue
insert_sql_data.append(f""" insert_sql_data.append(f"""
('{v.product_id.code}', '{v.wo_id.code}', {v.qty or 0}, {v.id}, '{v.pt_id.code}', '{v.pt_id.task_type}', '{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}') ('{v.product_id.code}', '{v.wo_id.code}', {v.qty or 0}, {v.id}, '{v.pt_id.code}', '{v.pt_id.task_type}',
'{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}', '{em.code or ""}', '{em.name or ""}')
""") """)
sql = """ sql = """
INSERT INTO WBCCB (WBCCB_CPBH, WBCCB_GDBH, WBCCB_CCSL, WBCCB_CCID, WBCCB_RWBH, WBCCB_RWLX, WBCCB_datetime) INSERT INTO WBCCB (WBCCB_CPBH, WBCCB_GDBH, WBCCB_CCSL, WBCCB_CCID, WBCCB_RWBH, WBCCB_RWLX, WBCCB_datetime, WBCCB_YGBH, WBCCB_YGMC)
VALUES VALUES
""" """
if not insert_sql_data: if not insert_sql_data:
......
...@@ -24,14 +24,16 @@ class InheritRokeBomCreatePickingWizard(models.TransientModel): ...@@ -24,14 +24,16 @@ class InheritRokeBomCreatePickingWizard(models.TransientModel):
cur = conn.cursor() cur = conn.cursor()
except Exception as e: except Exception as e:
raise ValidationError("数据库链接失败,请检查数据库链接参数") raise ValidationError("数据库链接失败,请检查数据库链接参数")
em = self.env["roke.employee"].search([("user_id", "=", self.env.uid)], limit=1)
sql = """ sql = """
INSERT INTO WBLLD (WBLLD_RWBH, WBLLD_CPBH, WBLLD_XQSL, WBLLD_LLSL, WBLLD_datetime) INSERT INTO WBLLD (WBLLD_RWBH, WBLLD_CPBH, WBLLD_XQSL, WBLLD_LLSL, WBLLD_datetime, WBLLD_YGBH, WBLLD_YGMC)
VALUES VALUES
""" """
sql_list = [] sql_list = []
for v in self.line_ids: for v in self.line_ids:
sql_list.append(f""" sql_list.append(f"""
('{task_id.code}', '{v.material_id.code}', {v.demand_qty or 0}, {v.qty or 0}, '{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}') ('{task_id.code}', '{v.material_id.code}', {v.demand_qty or 0}, {v.qty or 0},
'{datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}', '{em.code or ""}', '{em.name or ""}')
""") """)
if not sql_list: if not sql_list:
raise ValidationError("数据错误") raise ValidationError("数据错误")
......
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