处理同步报错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' _name = 'sf.production.process'
_description = '表面工艺' _description = '表面工艺'
process_encode = fields.Char("编码") code = fields.Char("编码")
name = fields.Char('名称') name = fields.Char('名称')
remark = fields.Text("备注") remark = fields.Text("备注")
processing_order_ids = fields.One2many('sf.processing.order', 'production_process_id', string='工序') 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) name = fields.Char('名称', index=True)
remark = fields.Text('备注', 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', processing_order_ids = fields.Many2many('sf.processing.order', 'sf_associated_processes',
index=True, string='工序') index=True, string='工序')
active = fields.Boolean('有效', default=True) active = fields.Boolean('有效', default=True)

View File

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

View File

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