删除工序,加工工艺,新增表面工艺可选参数相关视图

This commit is contained in:
qihao.gong@jikimo.com
2024-03-08 17:32:21 +08:00
parent 70d6fb5660
commit b16d2c2864
7 changed files with 228 additions and 183 deletions

View File

@@ -34,8 +34,8 @@ class ResConfigSettings(models.TransientModel):
_logger.info("同步资源库表面工艺类别完成")
self.env['sf.production.process'].sync_all_production_process()
_logger.info("同步资源库表面工艺完成")
self.env['sf.processing.technology'].sync_all_processing_technology()
_logger.info("同步资源库加工工艺")
# self.env['sf.processing.technology'].sync_all_processing_technology()
# _logger.info("同步资源库加工工艺")
self.env['sf.machine.brand.tags'].sync_all_machine_brand_tags()
_logger.info("同步资源库品牌类别完成")
self.env['sf.machine.brand'].sync_all_machine_brand()

View File

@@ -40,10 +40,10 @@ class MrStaticResourceDataSync(models.Model):
logging.info("表面工艺已每日同步成功")
self.env['sf.production.process.parameter'].sync_production_process_parameter_yesterday()
logging.info("表面工艺可选参数已每日同步成功")
self.env['sf.processing.technology'].sync_processing_technology_yesterday()
logging.info("加工工艺已每日同步成功")
self.env['sf.processing.order'].sync_processing_order_yesterday()
logging.info("工序已同步已每日同步成功")
# self.env['sf.processing.technology'].sync_processing_technology_yesterday()
# logging.info("加工工艺已每日同步成功")
# self.env['sf.processing.order'].sync_processing_order_yesterday()
# logging.info("工序已同步已每日同步成功")
self.env['sf.fixture.material'].sync_fixture_material_yesterday()
logging.info("夹具物料已每日同步成功")
self.env['sf.multi_mounting.type'].sync_multi_mounting_type_yesterday()
@@ -367,64 +367,64 @@ class sfProductionProcess(models.Model):
raise ValidationError("表面工艺认证未通过")
class sfProcessingTechnology(models.Model):
_inherit = 'sf.processing.technology'
_description = '加工工艺'
url = '/api/processing_technology/list'
# 定时同步加工工艺
def sync_processing_technology_yesterday(self):
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['processing_technology_yesterday_list']:
if item:
processing_technology = self.search(
[("code", '=', item['process_encode']), ('active', 'in', [True, False])])
if processing_technology:
processing_technology.name = item['name']
processing_technology.remark = item['remark']
processing_technology.active = item['active']
else:
self.create({
"name": item['name'],
"code": item['process_encode'],
"remark": item['remark'],
"active": item['active'],
})
else:
raise ValidationError("加工工艺认证未通过")
# 同步所有加工工艺
def sync_all_processing_technology(self):
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['processing_technology_all_list']:
if item:
processing_technology = self.search(
[("code", '=', item['process_encode']), ('active', 'in', [True, False])])
if not processing_technology:
self.create({
"name": item['name'],
"code": item['process_encode'],
"remark": item['remark'],
"active": item['active'],
})
else:
processing_technology.name = item['name']
processing_technology.remark = item['remark']
processing_technology.active = item['active']
else:
raise ValidationError("加工工艺认证未通过")
# class sfProcessingTechnology(models.Model):
# _inherit = 'sf.processing.technology'
# _description = '加工工艺'
# url = '/api/processing_technology/list'
#
# # 定时同步加工工艺
# def sync_processing_technology_yesterday(self):
# config = self.env['res.config.settings'].get_values()
# headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
# strUrl = config['sf_url'] + self.url
# r = requests.post(strUrl, json={}, data=None, headers=headers)
# r = r.json()
# result = json.loads(r['result'])
# if result['status'] == 1:
# for item in result['processing_technology_yesterday_list']:
# if item:
# processing_technology = self.search(
# [("code", '=', item['process_encode']), ('active', 'in', [True, False])])
# if processing_technology:
# processing_technology.name = item['name']
# processing_technology.remark = item['remark']
# processing_technology.active = item['active']
# else:
# self.create({
# "name": item['name'],
# "code": item['process_encode'],
# "remark": item['remark'],
# "active": item['active'],
# })
# else:
# raise ValidationError("加工工艺认证未通过")
#
# # 同步所有加工工艺
# def sync_all_processing_technology(self):
# config = self.env['res.config.settings'].get_values()
# headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
# strUrl = config['sf_url'] + self.url
# r = requests.post(strUrl, json={}, data=None, headers=headers)
# r = r.json()
# result = json.loads(r['result'])
# if result['status'] == 1:
# for item in result['processing_technology_all_list']:
# if item:
# processing_technology = self.search(
# [("code", '=', item['process_encode']), ('active', 'in', [True, False])])
# if not processing_technology:
# self.create({
# "name": item['name'],
# "code": item['process_encode'],
# "remark": item['remark'],
# "active": item['active'],
# })
# else:
# processing_technology.name = item['name']
# processing_technology.remark = item['remark']
# processing_technology.active = item['active']
# else:
# raise ValidationError("加工工艺认证未通过")
class MachineBrandTags(models.Model):
@@ -1000,50 +1000,50 @@ class MachineToolType(models.Model):
raise ValidationError("机床型号认证未通过")
class sfProcessingOrder(models.Model):
_inherit = 'sf.processing.order'
_description = '工序'
url = '/api/processing_order/list'
# 定时同步工序
def sync_processing_order_yesterday(self):
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['processing_order_yesterday_list']:
processing_order = self.search([("id", '=', item['id']), ('active', 'in', [True, False])])
if processing_order:
processing_order.sequence = item['sequence']
else:
self.create({
"sequence": item['sequence'],
})
else:
raise ValidationError("工序认证未通过")
# 同步所有工序
def sync_all_processing_order(self):
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
if result['status'] == 1:
for item in result['processing_order_all_list']:
processing_order = self.search([("id", '=', item['id']), ('active', 'in', [True, False])])
if not processing_order:
self.create({
"sequence": item['sequence'],
})
else:
processing_order.sequence = item['sequence']
else:
raise ValidationError("工序认证未通过")
# class sfProcessingOrder(models.Model):
# _inherit = 'sf.processing.order'
# _description = '工序'
# url = '/api/processing_order/list'
#
# # 定时同步工序
# def sync_processing_order_yesterday(self):
# config = self.env['res.config.settings'].get_values()
# headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
# strUrl = config['sf_url'] + self.url
# r = requests.post(strUrl, json={}, data=None, headers=headers)
# r = r.json()
# result = json.loads(r['result'])
# if result['status'] == 1:
# for item in result['processing_order_yesterday_list']:
# processing_order = self.search([("id", '=', item['id']), ('active', 'in', [True, False])])
# if processing_order:
# processing_order.sequence = item['sequence']
# else:
# self.create({
# "sequence": item['sequence'],
# })
# else:
# raise ValidationError("工序认证未通过")
#
# # 同步所有工序
# def sync_all_processing_order(self):
# config = self.env['res.config.settings'].get_values()
# headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
# strUrl = config['sf_url'] + self.url
# r = requests.post(strUrl, json={}, data=None, headers=headers)
# r = r.json()
# result = json.loads(r['result'])
# if result['status'] == 1:
# for item in result['processing_order_all_list']:
# processing_order = self.search([("id", '=', item['id']), ('active', 'in', [True, False])])
# if not processing_order:
# self.create({
# "sequence": item['sequence'],
# })
# else:
# processing_order.sequence = item['sequence']
# else:
# raise ValidationError("工序认证未通过")
class sfProductionProcessParameter(models.Model):