优化接口

This commit is contained in:
jinling.yang
2023-01-11 16:23:19 +08:00
parent 39136bb137
commit 6d48618253

View File

@@ -44,9 +44,6 @@ class Sf_Bf_Connect(http.Controller):
# else:
product = request.env['product.template'].sudo().product_create(product_id, item, order_id,
kw['order_number'], i)
# order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
logging.info('order_id:%s' % order_id)
logging.info('product:%s' % product)
bom_data = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).get_bom(product)
logging.info('bom_data:%s' % bom_data)
if bom_data:
@@ -60,7 +57,7 @@ class Sf_Bf_Connect(http.Controller):
self_machining_embryo = request.env['product.template'].sudo().no_bom_product_create(
self_machining_id,
item,
order_id, 'self_machining')
order_id, 'self_machining', i)
# 创建胚料的bom
self_machining_bom = request.env['mrp.bom'].with_user(
request.env.ref("base.user_admin")).bom_create(
@@ -79,7 +76,8 @@ class Sf_Bf_Connect(http.Controller):
outsource_embryo = request.env['product.template'].sudo().no_bom_product_create(outsource_id,
item,
order_id,
'subcontract')
'subcontract',
i)
# 创建胚料的bom
outsource_bom = request.env['mrp.bom'].with_user(request.env.ref("base.user_admin")).bom_create(
outsource_embryo,
@@ -95,16 +93,17 @@ class Sf_Bf_Connect(http.Controller):
purchase_embryo = request.env['product.template'].sudo().no_bom_product_create(purchase_id,
item,
order_id,
'purchase')
'purchase', i)
# 产品配置bom
product_bom_purchase = request.env['mrp.bom'].with_user(
request.env.ref("base.user_admin")).bom_create(product, 'normal', False)
product_bom_purchase.with_user(request.env.ref("base.user_admin")).bom_create_line_has(
purchase_embryo)
order_id.with_user(request.env.ref("base.user_admin")).sale_order_create_line(product, item)
i += 1
i += 1
res['factory_order_no'] = order_id.name
except Exception as e:
logging.info('get_bfm_process_order_list error:%s' % e)
res['status'] = -1
res['message'] = '工厂创建销售订单和产品失败,请联系管理员'
return json.JSONEncoder().encode(res)