From e505285a919c7241458f79c0ec2e708264810350 Mon Sep 17 00:00:00 2001 From: "qihao.gong@jikimo.com" Date: Wed, 11 Oct 2023 15:41:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=90=8C=E6=AD=A5=E6=8A=A5?= =?UTF-8?q?=E9=94=99bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/common.py | 4 +-- sf_base/views/common_view.xml | 12 ++++----- sf_mrs_connect/models/sync_common.py | 40 +++++++++++++--------------- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/sf_base/models/common.py b/sf_base/models/common.py index 15b4c65f..e202a40e 100644 --- a/sf_base/models/common.py +++ b/sf_base/models/common.py @@ -101,7 +101,7 @@ class MrsProductionProcess(models.Model): _name = 'sf.production.process' _description = '表面工艺' - process_encode = fields.Char("编码") + code = fields.Char("编码") name = fields.Char('名称') remark = fields.Text("备注") processing_order_ids = fields.One2many('sf.processing.order', 'production_process_id', string='工序') @@ -118,7 +118,7 @@ class MrsProcessingTechnology(models.Model): name = fields.Char('名称', index=True) remark = fields.Text('备注', index=True) - process_encode = fields.Char("编码") + code = fields.Char("编码") processing_order_ids = fields.Many2many('sf.processing.order', 'sf_associated_processes', index=True, string='工序') active = fields.Boolean('有效', default=True) diff --git a/sf_base/views/common_view.xml b/sf_base/views/common_view.xml index 156ecdab..a4853907 100644 --- a/sf_base/views/common_view.xml +++ b/sf_base/views/common_view.xml @@ -24,7 +24,7 @@ sf.processing.technology - + @@ -35,7 +35,7 @@ - + @@ -64,7 +64,7 @@ - + @@ -105,7 +105,7 @@ sf.production.process - + @@ -124,7 +124,7 @@ - + @@ -186,7 +186,7 @@ - + diff --git a/sf_mrs_connect/models/sync_common.py b/sf_mrs_connect/models/sync_common.py index b322808b..a326d024 100644 --- a/sf_mrs_connect/models/sync_common.py +++ b/sf_mrs_connect/models/sync_common.py @@ -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({