处理同步报错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

@@ -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)

View File

@@ -24,7 +24,7 @@
<field name="model">sf.processing.technology</field>
<field name="arch" type="xml">
<tree string="加工工艺" create="0" edit="0" delete="1">
<field name="process_encode"/>
<field name="code"/>
<field name="name"/>
</tree>
</field>
@@ -35,7 +35,7 @@
<field name="arch" type="xml">
<search>
<field name="name" string="名称搜索" filter_domain="[('name','ilike',self)]"/>
<field name="process_encode" string="编码搜索" filter_domain="[('process_encode','ilike',self)]"/>
<field name="code" string="编码搜索" filter_domain="[('code','ilike',self)]"/>
<filter name="filter_active" string="已归档" domain="[('active','=',False)]"/>
</search>
</field>
@@ -64,7 +64,7 @@
<page string="表面工艺">
<field name='production_process_ids' widget="ony2many">
<tree editable="bottom">
<field name="process_encode" string="编码号" readonly="1" force_save="1"/>
<field name="code" string="编码号" readonly="1" force_save="1"/>
<field name="name" string="名称" required="1"/>
<field name='category_id' default="default" invisible="1"/>
<field name="remark"/>
@@ -105,7 +105,7 @@
<field name="model">sf.production.process</field>
<field name="arch" type="xml">
<tree string="表面工艺" create="0" edit="0" delete="1">
<field name="process_encode"/>
<field name="code"/>
<field name="name" string="名称"/>
<field name="remark"/>
</tree>
@@ -124,7 +124,7 @@
</div>
<group>
<group>
<field name="process_encode"/>
<field name="code"/>
</group>
<notebook>
<page string="可选参数">
@@ -186,7 +186,7 @@
<field name="arch" type="xml">
<search>
<field name="name" string="名称搜索" filter_domain="[('name','ilike',self)]"/>
<field name="process_encode" string="编码搜索" filter_domain="[('process_encode','ilike',self)]"/>
<field name="code" string="编码搜索" filter_domain="[('code','ilike',self)]"/>
<filter name="filter_active" string="已归档" domain="[('active','=',False)]"/>
</search>
</field>

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({