处理同步报错bug

This commit is contained in:
qihao.gong@jikimo.com
2023-10-11 15:41:55 +08:00
parent ecb1f4140e
commit e505285a91
3 changed files with 26 additions and 30 deletions

View File

@@ -316,16 +316,16 @@ class sfProductionProcess(models.Model):
for item in result['production_process_yesterday_list']:
if item:
brand = self.env['sf.production.process'].search(
[("process_encode", '=', item['code'])])
[("code", '=', item['code'])])
if brand:
brand.name = item['name'],
brand.category_id = self.env['sf.production.process.category'].search(
[("code", '=', item['category_code'])]).id,
brand.process_encode = item['code'],
brand.code = item['code'],
brand.remark = item['remark'],
brand.active = item['active'],
brand.remark = item['remark']
production_process = self.search([("process_encode", '=', item['code'])])
production_process = self.search([("code", '=', item['code'])])
category = self.env['sf.production.process.category'].search(
[("code", '=', item['category_code'])])
if production_process:
@@ -338,7 +338,7 @@ class sfProductionProcess(models.Model):
"name": item['name'],
"category_id": self.env['sf.production.process.category'].search(
[("code", '=', item['category_code'])]).id,
"process_encode": item['code'],
"code": item['code'],
"remark": item['remark'],
"active": item['active'],
})
@@ -358,14 +358,14 @@ class sfProductionProcess(models.Model):
if result['status'] == 1:
for item in result['production_process_all_list']:
if item:
production_process = self.search([("process_encode", '=', item['code'])])
production_process = self.search([("code", '=', item['code'])])
category = self.env['sf.production.process.category'].search(
[("code", '=', item['category_code'])])
if not production_process:
self.create({
"name": item['name'],
"category_id": category.id,
"process_encode": item['process_encode'],
"code": item['code'],
"remark": item['remark'],
"active": item['active'],
})
@@ -397,7 +397,7 @@ class sfProcessingTechnology(models.Model):
if result['status'] == 1:
for item in result['processing_technology_yesterday_list']:
if item:
processing_technology = self.search([("process_encode", '=', item['process_encode'])])
processing_technology = self.search([("code", '=', item['code'])])
if processing_technology:
processing_technology.name = item['name']
processing_technology.remark = item['remark']
@@ -405,7 +405,7 @@ class sfProcessingTechnology(models.Model):
else:
self.create({
"name": item['name'],
"process_encode": item['process_encode'],
"code": item['code'],
"remark": item['remark'],
"active": item['active'],
})
@@ -425,11 +425,11 @@ class sfProcessingTechnology(models.Model):
if result['status'] == 1:
for item in result['processing_technology_all_list']:
if item:
processing_technology = self.search([("process_encode", '=', item['process_encode'])])
processing_technology = self.search([("code", '=', item['code'])])
if not processing_technology:
self.create({
"name": item['name'],
"process_encode": item['process_encode'],
"code": item['code'],
"remark": item['remark'],
"active": item['active'],
})
@@ -584,7 +584,7 @@ class MachineBrand(models.Model):
brand = self.search([("code", '=', item['code'])])
if brand:
brand.name = item['name']
brand.image_brand = '' if not item['image_brand'] else base64.b64encode(item.image_brand)
brand.image_brand = '' if not item['image_brand'] else base64.b64decode(item['image_brand'])
brand.active = item['active']
brand.remark = item['remark']
brand.tag_ids = self.env['sf.machine.brand.tags'].search([("name", 'in', item['tag_ids'])]).ids
@@ -592,7 +592,7 @@ class MachineBrand(models.Model):
self.create({
"name": item['name'],
"code": item['code'],
"image_brand": '' if not item['image_brand'] else base64.b64encode(item.image_brand),
"image_brand": '' if not item['image_brand'] else base64.b64decode(item['image_brand']),
"active": item['active'],
"remark": item['remark'],
"tag_ids": self.env['sf.machine.brand.tags'].search([("name", 'in', item['tag_ids'])]).ids,
@@ -614,22 +614,18 @@ class MachineBrand(models.Model):
for item in result['machine_brand_all_list']:
brand = self.search([("code", '=', item['code'])])
if not brand:
if item.get('image_brand'):
image = base64.b64decode(item['image_brand'])
else:
image = ''
self.create({
"name": item['name'],
"code": item['code'],
"remark": item['remark'],
"image_brand": image,
"image_brand": '' if not item['image_brand'] else base64.b64decode(item['image_brand']),
"tag_ids": self.env['sf.machine.brand.tags'].search(
[("name", 'in', item['tag_ids'])]).ids
})
else:
brand.name = item['name']
brand.remark = item['remark']
brand.image_brand = '' if not item['image_brand'] else base64.b64encode(item.image_brand)
brand.image_brand = '' if not item['image_brand'] else base64.b64decode(item['image_brand'])
brand.tag_ids = self.env['sf.machine.brand.tags'].search(
[("name", 'in', item['tag_ids'])]).ids
else:
@@ -909,7 +905,7 @@ class sfProductionProcessParameter(models.Model):
_description = '表面工艺可选参数'
url = '/api/production_process_parameter/list'
# 定时同步每日表面工艺
# 定时同步每日表面工艺可选参数
def sync_production_process_parameter_yesterday(self):
sf_sync_config = self.env['res.config.settings'].get_values()
token = sf_sync_config['token']
@@ -924,7 +920,7 @@ class sfProductionProcessParameter(models.Model):
if item:
production_process_parameter = self.search([("code", '=', item['code'])])
process = self.env['sf.production.process'].search(
[('process_encode', '=', item['process_id_code'])])
[('code', '=', item['process_id_code'])])
if production_process_parameter:
production_process_parameter.name = item['name']
production_process_parameter.active = item['active']
@@ -943,7 +939,7 @@ class sfProductionProcessParameter(models.Model):
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']
@@ -961,7 +957,7 @@ class sfProductionProcessParameter(models.Model):
production_process_parameter = self.search(
[("code", '=', item['code'])])
process = self.env['sf.production.process'].search(
[('process_encode', '=', item['process_id_code'])])
[('code', '=', item['process_id_code'])], limit=1)
if not production_process_parameter:
_logger.info('create可选参数:%s' % item)
self.create({