1、新增机床刀具组接口,在刀具组新建和更新时调用接口;2、新增零件特采接口,在质量检测审核之后调用接口;
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import custom_quality
|
||||
from . import quality
|
||||
|
||||
34
sf_quality/models/quality.py
Normal file
34
sf_quality/models/quality.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import json
|
||||
import requests
|
||||
from odoo import fields, models, api
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
|
||||
|
||||
class QualityCheck(models.Model):
|
||||
_inherit = "quality.check"
|
||||
_description = '零件特采'
|
||||
|
||||
# ==========零件特采接口==========
|
||||
def _register_tool_groups(self):
|
||||
create_url = '/AutoDeviceApi/FeedBackOut'
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(self, token, sf_secret_key)
|
||||
strurl = sf_sync_config['sf_url'] + create_url
|
||||
val = {
|
||||
'RfidCode': None,
|
||||
}
|
||||
kw = json.dumps(val, ensure_ascii=False)
|
||||
r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if r == 200:
|
||||
return "零件特采发送成功"
|
||||
else:
|
||||
raise ValidationError("零件特采发送失败")
|
||||
|
||||
@api.onchange('quality_state')
|
||||
def _onchange_quality_state(self):
|
||||
if self.quality_state in ['pass', 'fail']:
|
||||
self._register_tool_groups()
|
||||
Reference in New Issue
Block a user