Accept Merge Request #1257: (feature/tax_sync -> develop)

Merge Request: 错误处理

Created By: @廖丹龙
Reviewed By: @胡尧
Approved By: @胡尧 
Accepted By: @廖丹龙
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1257?initial=true
This commit is contained in:
廖丹龙
2024-08-27 16:38:22 +08:00
committed by Coding

View File

@@ -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):