diff --git a/sf_mrs_connect/models/sync_common.py b/sf_mrs_connect/models/sync_common.py index 3d309689..1d96c027 100644 --- a/sf_mrs_connect/models/sync_common.py +++ b/sf_mrs_connect/models/sync_common.py @@ -32,20 +32,18 @@ class sfProductionMaterials(models.Model): if result['status'] == 1: for item in result['production_materials_yesterday_list']: if item: - brand = self.env['sf.production.materials'].search( + materials = self.env['sf.production.materials'].search( [("materials_no", '=', item['materials_no'])]) - if brand: - brand.id = item['id'], - brand.name = item['name'], - brand.remark = item['remark'], - brand.active = item['active'] + if materials: + materials.name = item['name'] + materials.remark = item['remark'] + materials.active = item['active'] else: self.env['sf.production.materials'].create({ - "id": item['id'], "name": item['name'], "materials_no": item['materials_no'], "remark": item['remark'], - "active": item['active'] + "active": item['active'], }) else: raise ValidationError("认证未通过") @@ -65,17 +63,20 @@ class sfProductionMaterials(models.Model): if result['status'] == 1: for item in result['production_materials_all_list']: if item: - - brand = self.env['sf.production.materials'].search( + materials = self.env['sf.production.materials'].search( [("materials_no", '=', item['materials_no'])]) - if not brand: + if not materials: self.env['sf.production.materials'].create({ - "id": item['id'], "name": item['name'], "materials_no": item['materials_no'], "remark": item['remark'], - "active": item['active'] + "active": item['active'], }) + else: + materials.name = item['name'] + materials.remark = item['remark'] + materials.active = item['active'] + else: raise ValidationError("认证未通过") @@ -102,23 +103,22 @@ class sfMaterialModel(models.Model): materials_model = self.env['sf.materials.model'].search( [("materials_no", '=', item['materials_no'])]) if materials_model: - materials_model.id = item['id'], - materials_model.name = item['name'], - materials_model.materials_no = item['materials_no'], - materials_model.remark = item['remark'], - materials_model.tensile_strength = item['tensile_strength'], - materials_model.hardness = item['hardness'], - materials_model.materials_no = item['materials_no'], - materials_model.rough_machining = item['rough_machining'], - materials_model.finish_machining = item['finish_machining'], - materials_model.mf_materia_post = item['mf_materia_post'], + materials_model.name = item['name'] + materials_model.materials_no = item['materials_no'] + materials_model.remark = item['remark'] + materials_model.tensile_strength = item['tensile_strength'] + materials_model.hardness = item['hardness'] + materials_model.materials_no = item['materials_no'] + materials_model.rough_machining = item['rough_machining'] + materials_model.finish_machining = item['finish_machining'] + materials_model.mf_materia_post = item['mf_materia_post'] materials_model.materials_id = self.env['sf.production.materials'].search( - [("materials_no", '=', item['materials_id.materials_no'])]).id, - materials_model.need_h = item['need_h'], + [("materials_no", '=', item['materials_id.materials_no'])]).id + materials_model.need_h = item['need_h'] materials_model.density = item['density'] + materials_model.active = item['active'] else: self.env['sf.materials.model'].create({ - "id": item['id'], "name": item['name'], "materials_no": item['materials_no'], "remark": item['remark'], @@ -132,8 +132,6 @@ class sfMaterialModel(models.Model): "need_h": item['need_h'], "mf_materia_post": item['mf_materia_post'], "density": item['density'], - # "tag_ids": item['tag_ids'] - }) else: raise ValidationError("认证未通过") @@ -171,6 +169,22 @@ class sfMaterialModel(models.Model): # "tag_ids": item['tag_ids'] }) + else: + materials_model.name = item['name'] + materials_model.materials_no = item['materials_no'] + materials_model.remark = item['remark'] + materials_model.tensile_strength = item['tensile_strength'] + materials_model.hardness = item['hardness'] + materials_model.materials_no = item['materials_no'] + materials_model.rough_machining = item['rough_machining'] + materials_model.finish_machining = item['finish_machining'] + materials_model.mf_materia_post = item['mf_materia_post'] + materials_model.materials_id = self.env['sf.production.materials'].search( + [("materials_no", '=', item['materials_id.materials_no'])]).id + materials_model.need_h = item['need_h'] + materials_model.density = item['density'] + materials_model.active = item['active'] + else: raise ValidationError("认证未通过") @@ -197,8 +211,8 @@ class sfProductionProcessCategory(models.Model): production_process_category = self.env['sf.production.process.category'].search( [("code", '=', item['code'])]) if production_process_category: - production_process_category.name = item['name'], - production_process_category.code = item['code'], + production_process_category.name = item['name'] + production_process_category.code = item['code'] production_process_category.active = item['active'] else: self.env['sf.production.process.category'].create({ @@ -231,6 +245,9 @@ class sfProductionProcessCategory(models.Model): "code": item['code'], "active": item['active'], }) + else: + category.name = item['name'] + category.active = item['active'] else: raise ValidationError("认证未通过") @@ -254,16 +271,15 @@ class sfProductionProcess(models.Model): if result['status'] == 1: for item in result['production_process_yesterday_list']: if item: - brand = self.env['sf.production.process'].search( + production_process = self.env['sf.production.process'].search( [("process_encode", '=', item['process_encode'])]) - 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['process_encode'], - brand.remark = item['remark'], - brand.active = item['active'], - brand.remark = item['remark'] + if production_process: + production_process.name = item['name'] + production_process.category_id = self.env['sf.production.process.category'].search( + [("code", '=', item['category_code'])]).id + production_process.process_encode = item['process_encode'] + production_process.remark = item['remark'] + production_process.active = item['active'] else: self.env['sf.production.process'].create({ "name": item['name'], @@ -290,9 +306,9 @@ class sfProductionProcess(models.Model): if result['status'] == 1: for item in result['production_process_all_list']: if item: - brand = self.env['sf.production.process'].search( + production_process = self.env['sf.production.process'].search( [("process_encode", '=', item['process_encode'])]) - if not brand: + if not production_process: self.env['sf.production.process'].create({ "name": item['name'], "category_id": self.env['sf.production.process.category'].search( @@ -303,6 +319,12 @@ class sfProductionProcess(models.Model): # "tag_ids": item['tag_ids'] }) + else: + production_process.name = item['name'] + production_process.category_id = self.env['sf.production.process.category'].search( + [("code", '=', item['category_code'])]).id + production_process.remark = item['remark'] + production_process.active = item['active'] else: raise ValidationError("认证未通过") @@ -326,14 +348,12 @@ class sfProcessingTechnology(models.Model): if result['status'] == 1: for item in result['processing_technology_yesterday_list']: if item: - brand = self.env['sf.processing.technology'].search( + processing_technology = self.env['sf.processing.technology'].search( [("process_encode", '=', item['process_encode'])]) - if brand: - brand.id = item['id'], - brand.name = item['name'], - brand.process_encode = item['process_encode'], - brand.remark = item['remark'], - brand.active = item['active'] + if processing_technology: + processing_technology.name = item['name'] + processing_technology.remark = item['remark'] + processing_technology.active = item['active'] else: self.env['sf.processing.technology'].create({ "id": item['id'], @@ -361,18 +381,20 @@ class sfProcessingTechnology(models.Model): if result['status'] == 1: for item in result['processing_technology_all_list']: if item: - brand = self.env['sf.processing.technology'].search( + processing_technology = self.env['sf.processing.technology'].search( [("process_encode", '=', item['process_encode'])]) - if not brand: + if not processing_technology: self.env['sf.processing.technology'].create({ "id": item['id'], "name": item['name'], "process_encode": item['process_encode'], "remark": item['remark'], "active": item['active'], - # "tag_ids": item['tag_ids'] - }) + else: + processing_technology.name = item['name'] + processing_technology.remark = item['remark'] + processing_technology.active = item['active'] else: raise ValidationError("认证未通过")