This commit is contained in:
gqh
2022-10-10 10:52:24 +08:00
parent 88bed4d910
commit 839de4c95f
11 changed files with 108 additions and 80 deletions

View File

@@ -60,7 +60,7 @@
<record model="ir.cron" id="sf_cron6">
<field name="name">同步资源库控制系统</field>
<field name="model_id" ref="model_mrs_machine_tool_type_control_system"/>
<field name="model_id" ref="model_mrs_machine_control_system"/>
<field name="state">code</field>
<field name="code">model.sync_machine_tool_type_control_system()</field>
<field name="interval_number">1</field>

View File

@@ -20,13 +20,13 @@ class ResConfigSettings(models.TransientModel):
self.env['mrs.production.process'].sync_all_production_process()
self.env['mrs.processing.technology'].sync_all_processing_technology()
self.env['mrs.machine.brand.tags'].sync_all_machine_brand_tags()
self.env['mrs.machine_tool.type.control_system'].sync_all_machine_tool_type_control_system()
self.env['mrs.machine.brand'].sync_all_machine_brand()
self.env['mrs.machine.control_system'].sync_all_machine_tool_type_control_system()
# self.env['mrs.machine_tool'].sync_all_machine_tool()
self.env['mrs.machine_tool.type'].sync_all_machine_tool_type()
self.env['mrs.cutting_tool.category'].sync_all_cutting_tool_category()
self.env['mrs.cutting_tool.type'].sync_all_cutting_tool_type()
self.env['mrs.processing.order'].sync_all_processing_order()
# self.env['mrs.processing.order'].sync_all_processing_order()
return _logger.info("同步资源库成功")

View File

@@ -350,12 +350,13 @@ class MachineBrandTags(models.Model):
"color": item['color'],
})
else:
raise ValidationError("认证未通过")
class MachineControlSystem(models.Model):
_inherit = 'mrs.machine_tool.type.control_system'
_inherit = 'mrs.machine.control_system'
_description = '控制系统'
url = '/api/machine_control_system/list'
@@ -373,7 +374,7 @@ class MachineControlSystem(models.Model):
if result['status'] == 1:
for item in result['machine_control_system_yesterday_list']:
if item:
brand = self.env['mrs.machine_tool.type.control_system'].search(
brand = self.env['mrs.machine.control_system'].search(
[("code", '=', item['code'])])
if brand:
brand.id = item['id'],
@@ -381,7 +382,7 @@ class MachineControlSystem(models.Model):
brand.code = item['code'],
brand.active = item['active']
else:
self.env['mrs.machine_tool.type.control_system'].create({
self.env['mrs.machine.control_system'].create({
"id": item['id'],
"name": item['name'],
"code": item['code'],
@@ -409,12 +410,13 @@ class MachineControlSystem(models.Model):
if result['status'] == 1:
for item in result['machine_control_system_all_list']:
if item:
self.env['mrs.machine_tool.type.control_system'].create({
self.env['mrs.machine.control_system'].create({
"id": item['id'],
"name": item['name'],
"code": item['code'],
# "brand_id": item['brand_id'],
"brand_id": self.env['mrs.machine.brand'].search(
[("id", '=', item['brand_id'])]),
"active": item['active'],
# "tag_ids": item['tag_ids']
@@ -482,7 +484,9 @@ class MachineBrand(models.Model):
"code": item['code'],
# "image_brand": item['image_brand'],
"active": item['active'],
# "tag_ids": item['tag_ids']
"tag_ids": self.env['mrs.machine.brand.tags'].search(
[("id", 'in', item['tag_ids'])])
})
else:
@@ -534,10 +538,10 @@ class MachineTool(models.Model):
kw = json.dumps(machine_tool_list, ensure_ascii=False)
print(type(kw))
r = requests.post(strurl, json={}, data={'kw':kw}, headers=headers)
print(r)
r = requests.post(strurl, json={}, data={'kw': kw}, headers=headers)
else:
raise _logger.info("没有注册机床")
raise ValidationError("没有机床信息")
# 定时同步机床
def sync_machine_tool(self):