错误处理
This commit is contained in:
@@ -28,8 +28,8 @@ class StatusChange(models.Model):
|
|||||||
raise UserError(_("请先至【产品】中创建【表面工艺参数】为%s的服务产品", ", ".join(server_product_none)))
|
raise UserError(_("请先至【产品】中创建【表面工艺参数】为%s的服务产品", ", ".join(server_product_none)))
|
||||||
|
|
||||||
# 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法)
|
# 使用super()来调用原始方法(在本例中为'sale.order'模型的'action_confirm'方法)
|
||||||
|
try:
|
||||||
res = super(StatusChange, self).action_confirm()
|
res = super(StatusChange, self).action_confirm()
|
||||||
|
|
||||||
# 原有方法执行后,进行额外的操作(如调用外部API)
|
# 原有方法执行后,进行额外的操作(如调用外部API)
|
||||||
process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
config = self.env['res.config.settings'].get_values()
|
config = self.env['res.config.settings'].get_values()
|
||||||
@@ -43,9 +43,16 @@ class StatusChange(models.Model):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
url1 = config['bfm_url_new'] + '/api/get/state/get_order'
|
url1 = config['bfm_url_new'] + '/api/get/state/get_order'
|
||||||
requests.post(url1, json=json1, data=None)
|
ret = requests.post(url1, json=json1, data=None)
|
||||||
|
ret = ret.json()
|
||||||
|
if not ret.get('error'):
|
||||||
logging.info('接口已经执行=============')
|
logging.info('接口已经执行=============')
|
||||||
|
else:
|
||||||
|
logging.error('工厂加工同步订单状态失败 {}'.format(ret.text))
|
||||||
|
raise UserError('工厂加工同步订单状态失败')
|
||||||
|
except UserError as e:
|
||||||
|
logging.error('工厂加工同步订单状态失败 {}'.format(e))
|
||||||
|
raise UserError('工厂加工同步订单状态失败')
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def action_cancel(self):
|
def action_cancel(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user