修改获取CNC程序从工单到制造订单
This commit is contained in:
@@ -92,7 +92,7 @@ class MachineTool(models.Model):
|
||||
type_id = fields.Many2one('sf.machine_tool.type', '型号')
|
||||
brand_id = fields.Many2one('sf.machine.brand', string='品牌')
|
||||
state = fields.Selection(
|
||||
[("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")],
|
||||
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"),("空闲", "空闲"),("封存(报废)", "封存(报废)")],
|
||||
default='正常', string="机床状态")
|
||||
# 0606新增字段
|
||||
machine_tool_picture = fields.Binary('图片')
|
||||
|
||||
@@ -160,8 +160,9 @@ class SfMaintenanceEquipment(models.Model):
|
||||
type_id = fields.Many2one('sf.machine_tool.type', '型号')
|
||||
|
||||
state = fields.Selection(
|
||||
[("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")],
|
||||
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"),("空闲", "空闲"),("封存(报废)", "封存(报废)")],
|
||||
default='正常', string="机床状态")
|
||||
run_time = fields.Char('总运行时长')
|
||||
# 0606新增字段
|
||||
machine_tool_picture = fields.Binary('图片')
|
||||
heightened_way = fields.Selection([
|
||||
|
||||
@@ -26,3 +26,4 @@ class SfMaintenanceLogs(models.Model):
|
||||
recovery_time = fields.Datetime(string='复原时间')
|
||||
fault_duration = fields.Float(string='故障时长')
|
||||
note = fields.Text(string='备注')
|
||||
active = fields.Boolean('Active', default=True)
|
||||
|
||||
@@ -105,9 +105,10 @@
|
||||
<!-- Action -->
|
||||
|
||||
<record id="action_maintenance_logs" model="ir.actions.act_window">
|
||||
<field name="name">设备故障日志</field>
|
||||
<field name="name">设备故障日志</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sf.maintenance.logs</field>
|
||||
<field name="search_view_id" ref="view_maintenance_logs_search"/>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_maintenance_logs_tree"/>
|
||||
<field name="help" type="html">
|
||||
@@ -117,6 +118,23 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- <record id="action_maintenance_logs_button" model="ir.actions.act_window">-->
|
||||
<!-- <field name="name">设备故障日志</field>-->
|
||||
<!-- <field name="type">ir.actions.act_window</field>-->
|
||||
<!-- <field name="res_model">sf.maintenance.logs</field>-->
|
||||
<!-- <field name="search_view_id" ref="view_maintenance_logs_search"/>-->
|
||||
<!-- <field name="view_mode">tree,form</field>-->
|
||||
<!-- <field name="view_id" ref="view_maintenance_logs_tree"/>-->
|
||||
<!-- <field name="context">{-->
|
||||
<!-- 'default_maintenance_equipment_id': active_id-->
|
||||
<!-- }</field>-->
|
||||
<!-- <field name="help" type="html">-->
|
||||
<!-- <p class="oe_view_nocontent_create">-->
|
||||
<!-- 设备故障日志-->
|
||||
<!-- </p>-->
|
||||
<!-- </field>-->
|
||||
<!-- </record>-->
|
||||
|
||||
<!-- <record id="action_maintenance_logs" model="ir.actions.act_window">-->
|
||||
<!-- <field name="name">设备故障日志</field>-->
|
||||
<!-- <field name="res_model">sf.maintenance.logs</field>-->
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<button name="%(action_maintenance_logs)d"
|
||||
type="action"
|
||||
class="oe_stat_button"
|
||||
context="{'default_sf_maintenance_logs_ids': sf_maintenance_logs_ids}"
|
||||
context="{'search_default_maintenance_equipment_id': [active_id]}"
|
||||
icon="fa-wrench">
|
||||
<field string="设备故障日志" name="sf_maintenance_logs_ids" widget="statinfo"/>
|
||||
</button>
|
||||
@@ -56,6 +56,7 @@
|
||||
domain="[('brand_id', '=', brand_id)]"/>
|
||||
<field name="machine_tool_category" readonly="1" attrs="{'invisible': [('type_id', '=', False)]}"
|
||||
force_save="1"/>
|
||||
<field name="run_time" force_save="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='description']" position="before">
|
||||
<page string="设备参数" name="sf_equipment"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import base64
|
||||
import logging
|
||||
import re
|
||||
import requests
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
@@ -24,6 +25,7 @@ class MrpProduction(models.Model):
|
||||
programming_no = fields.Char('编程单号')
|
||||
work_state = fields.Char('业务状态')
|
||||
programming_state = fields.Char('编程状态')
|
||||
glb_file = fields.Binary("glb模型文件")
|
||||
|
||||
def action_check(self):
|
||||
"""
|
||||
@@ -55,7 +57,7 @@ class MrpProduction(models.Model):
|
||||
production.maintenance_count = len(production.request_ids)
|
||||
|
||||
# cnc程序获取
|
||||
def fetchCNC(self, requests=None):
|
||||
def fetchCNC(self):
|
||||
cnc = self.env['mrp.production'].search([('id', '=', self.id)])
|
||||
try:
|
||||
res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code,
|
||||
@@ -81,6 +83,7 @@ class MrpProduction(models.Model):
|
||||
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||
url = '/api/intelligent_programming/create'
|
||||
config_url = configsettings['sf_url'] + url
|
||||
res['token'] = configsettings['token']
|
||||
# res_str = json.dumps(res)
|
||||
ret = requests.post(config_url, json={}, data=res, headers=config_header)
|
||||
ret = ret.json()
|
||||
@@ -182,6 +185,7 @@ class MrpProduction(models.Model):
|
||||
'state': 'pending',
|
||||
}]
|
||||
if production.product_id.categ_id.type == '成品':
|
||||
production.fetchCNC()
|
||||
# 根据加工面板的面数及对应的工序模板生成工单
|
||||
i = 0
|
||||
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
|
||||
|
||||
@@ -22,7 +22,7 @@ class ResWorkcenter(models.Model):
|
||||
|
||||
|
||||
equipment_status = fields.Selection(
|
||||
[("正常", "正常"), ("故障", "故障"), ("不可用", "不可用")],
|
||||
[("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"),("空闲", "空闲"),("封存(报废)", "封存(报废)")],
|
||||
string="设备状态", related='equipment_id.state')
|
||||
|
||||
# @api.depends('equipment_id')
|
||||
|
||||
@@ -630,11 +630,11 @@ class CNCprocessing(models.Model):
|
||||
'remark': obj['remark']
|
||||
})
|
||||
self.get_cnc_processing_file(ret['folder_name'], cnc_processing, workorder.processing_panel)
|
||||
cnc_workorder.state = 'done'
|
||||
# cnc_workorder.state = 'done'
|
||||
cnc_workorder.work_state = '已编程'
|
||||
cnc_workorder.programming_state = '已编程'
|
||||
cnc_workorder.time_ids.date_end = datetime.now()
|
||||
cnc_workorder.button_finish()
|
||||
# cnc_workorder.time_ids.date_end = datetime.now()
|
||||
# cnc_workorder.button_finish()
|
||||
|
||||
# 根据程序名和加工面匹配到ftp里对应的Nc程序名
|
||||
def get_cnc_processing_file(self, folder_name, cnc_processing, processing_panel):
|
||||
|
||||
@@ -6,8 +6,8 @@ import os
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.modules import get_resource_path
|
||||
#from OCC.Extend.DataExchange import read_step_file
|
||||
#from OCC.Extend.DataExchange import write_stl_file
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
|
||||
|
||||
class ResProductMo(models.Model):
|
||||
|
||||
@@ -64,12 +64,13 @@
|
||||
<!-- <button name="archive" type="object" string="归档" icon="fa-archive" class="oe_highlight" attrs="{'invisible': [('active', '=', False)]}"/> -->
|
||||
<!-- <button name="unarchive" type="object" string="取消归档" icon="fa-archive" class="oe_highlight" attrs="{'invisible': [('active', '=', True)]}"/> -->
|
||||
<button name="action_check" string="审核" type="object" class="oe_highlight" attrs="{'invisible': [('check_status', '=', True)]}" groups="sf_base.group_plan_director"/>
|
||||
<div class="col-12 col-lg-6 o_setting_box" style="white-space: nowrap">
|
||||
<button type="object" class="oe_highlight" name="fetchCNC" string="获取CNC程序代码"
|
||||
/>
|
||||
</div>
|
||||
<!-- <button name="action_uncheck" string="禁用" type="object" class="oe_highlight" attrs="{'invisible': [('check_status', '=', False)]}" groups="sf_base.group_plan_director"/> -->
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='user_id']" position="after">
|
||||
<field name="programming_no"/>
|
||||
<field name="work_state" invisible="1"/>
|
||||
<field name="programming_state"/>
|
||||
</xpath>
|
||||
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -26,7 +26,8 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
cnc_production = request.env['mrp.production'].with_user(
|
||||
request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'])])
|
||||
if cnc_production:
|
||||
cnc_production.glb_file = base64.b64encode(ret['glb_file'])
|
||||
if ret['glb_file']:
|
||||
cnc_production.glb_file = base64.b64encode(ret['glb_file'])
|
||||
# 拉取所有加工面的程序文件
|
||||
# i = 1
|
||||
for r in ret['processing_panel']:
|
||||
@@ -35,7 +36,7 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
ret['folder_name'], r)
|
||||
if not download_state:
|
||||
res['status'] = -2
|
||||
res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.production_id.name)
|
||||
res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name)
|
||||
return json.JSONEncoder().encode(res)
|
||||
request.env['sf.cnc.processing'].with_user(
|
||||
request.env.ref("base.user_admin")).cnc_processing_create(cnc_production, ret)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import logging
|
||||
from odoo.modules import get_resource_path
|
||||
from odoo import fields, models, api
|
||||
#from quatotion import readSql, feature_recognize, auto_quatotion
|
||||
from quatotion import readSql, feature_recognize, auto_quatotion
|
||||
|
||||
__author__ = 'jinling.yang'
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -5,8 +5,8 @@ import os
|
||||
import json
|
||||
from datetime import datetime
|
||||
import requests
|
||||
#from OCC.Extend.DataExchange import read_step_file
|
||||
#from OCC.Extend.DataExchange import write_stl_file
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
from odoo import models, fields, api
|
||||
from odoo.modules import get_resource_path
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
|
||||
Reference in New Issue
Block a user