sf新增表面工艺参数同步接口和基础对象,新增dockerfile和requirements.txt文件

This commit is contained in:
gqh
2023-03-14 14:56:18 +08:00
parent fddc8100d6
commit 84ef243b9f
32 changed files with 223 additions and 1262 deletions

View File

@@ -948,3 +948,75 @@ class sfProcessingOrder(models.Model):
})
else:
raise ValidationError("认证未通过")
class sfProductionProcessParameter(models.Model):
_inherit = 'sf.production.process.parameter'
_description = '表面工艺可选参数'
url = '/api/production_process_parameter/list'
# 定时同步每日表面工艺
def sync_production_process_parameter(self):
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'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['mrs_production_process_parameter_yesterday_list']:
if item:
brand = self.env['sf.production.process.parameter'].search(
[("code", '=', item['code'])])
if brand:
brand.name = item['name'],
brand.code = item['code'],
brand.active = item['active'],
brand.price = item['price'],
else:
self.env['sf.production.process.parameter'].create({
"name": item['name'],
"code": item['code'],
"active": item['active'],
"price" : item['price'],
"process_id": self.env['sf.production.process'].search(
[('process_encode', '=', item['process_id_code'])]).id,
'materials_model_ids': self.env['sf.materials.model'].search(
[('materials_no', 'in', item['materials_model_ids_codes'])])
})
else:
raise ValidationError("认证未通过") # 定时同步表面工艺
# 同步所有表面工艺
def sync_all_production_process_parameter(self):
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'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['mrs_production_process_parameter_all_list']:
if item:
brand = self.env['sf.production.process.parameter'].search(
[("code", '=', item['code'])])
if not brand:
self.env['sf.production.process.parameter'].create({
"name": item['name'],
"code": item['code'],
"price": item['price'],
"active": item['active'],
"process_id": self.env['sf.production.process'].search(
[('process_encode', '=', item['process_id_code'])]).id,
'materials_model_ids': self.env['sf.materials.model'].search(
[('materials_no', 'in', item['materials_model_ids_codes'])])
})
else:
raise ValidationError("认证未通过")