Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造代码优化
# Conflicts: # sf_sale/models/sale_order.py
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
import json
|
||||
import base64
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
|
||||
@@ -21,9 +20,9 @@ class Manufacturing_Connect(http.Controller):
|
||||
res = {'Succeed': True, 'Datas': []}
|
||||
datas = request.httprequest.data
|
||||
ret = json.loads(datas)
|
||||
ret = json.loads(ret['result'])
|
||||
logging.info('RfidCode:%s' % ret)
|
||||
workorder = request.env['mrp.workorder'].sudo().search([('name', '=', ret['RfidCode'])])
|
||||
workorder = request.env['mrp.workorder'].sudo().search(
|
||||
[('production_id.name', '=', 'WH/MO/00071'), ('routing_type', '=', '装夹')])
|
||||
if workorder:
|
||||
for item in workorder:
|
||||
res['Datas'].append({
|
||||
@@ -33,10 +32,186 @@ class Manufacturing_Connect(http.Controller):
|
||||
'Quantity': 1,
|
||||
'MaterialId': item.product_id.default_code,
|
||||
'MaterialName': item.product_id.name,
|
||||
# 'Spec':item.mat,
|
||||
'Material': item.materials_type_id.name
|
||||
'Spec': '%s×%s×%s' % (item.move_raw_ids.materiel_length, item.move_raw_ids.materiel_width,
|
||||
item.move_raw_ids.materiel_height),
|
||||
'Material': item.product_id.materials_type_id.name
|
||||
})
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('get_Work_Info error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@http.route('/AutoDeviceApi/GetShiftPlan', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def get_ShiftPlan(self, **kw):
|
||||
"""
|
||||
自动化每天获取机台日计划
|
||||
:param kw:
|
||||
:return:
|
||||
"""
|
||||
logging.info('get_ShiftPlan:%s' % kw)
|
||||
try:
|
||||
res = {'Succeed': True, 'Datas': []}
|
||||
datas = request.httprequest.data
|
||||
ret = json.loads(datas)
|
||||
ret = json.loads(ret['result'])
|
||||
logging.info('RfidCode:%s' % ret)
|
||||
workorder = request.env['mrp.workorder'].sudo().search([('name', '=', ret['ProductionLine'])])
|
||||
if workorder:
|
||||
for item in workorder:
|
||||
date_planned_start = ''
|
||||
date_planned_finished = ''
|
||||
if item.date_planned_start is not False:
|
||||
planned_start = item.date_planned_start.strftime("%Y-%m-%d %H:%M:%S")
|
||||
date_planned_start = request.env['sf.sync.common'].sudo().get_add_time(planned_start)
|
||||
if item.date_planned_finished is not False:
|
||||
planned_finished = item.date_planned_finished.strftime("%Y-%m-%d %H:%M:%S")
|
||||
date_planned_finished = request.env['sf.sync.common'].sudo().get_add_time(planned_finished)
|
||||
res['Datas'].append({
|
||||
'BillId': item.production_id.name,
|
||||
'RfidCode': item.RfidCode,
|
||||
'CraftName': item.name,
|
||||
'Quantity': 1,
|
||||
'WortkStart': date_planned_start,
|
||||
'WorkEnd': date_planned_finished,
|
||||
'MaterialId': item.product_id.default_code,
|
||||
'MaterialName': item.product_id.name,
|
||||
# 'Spec':item.mat,
|
||||
'Material': item.materials_type_id.name
|
||||
})
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('get_ShiftPlan error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@http.route('/AutoDeviceApi/QcCheck', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def get_qcCheck(self, **kw):
|
||||
"""
|
||||
工件预调(前置三元检测)
|
||||
1、前置三元检测在产线外:三元检测设备把测量信息上传给MES,
|
||||
MES生成检测定位数据。中控系统传递RFID编号给MES获取测量偏置结果。(来源为三元检测工单上的字段)
|
||||
:param kw:
|
||||
:return:
|
||||
"""
|
||||
logging.info('get_qcCheck:%s' % kw)
|
||||
try:
|
||||
res = {'Succeed': True, 'Datas': []}
|
||||
datas = request.httprequest.data
|
||||
ret = json.loads(datas)
|
||||
ret = json.loads(ret['result'])
|
||||
logging.info('RfidCode:%s' % ret)
|
||||
workorder = request.env['mrp.workorder'].sudo().search([('routing_type', '=', '前置三元定位检测')])
|
||||
if workorder:
|
||||
for item in workorder:
|
||||
res['Datas'].append({
|
||||
'XOffset': item.production_id.name,
|
||||
'YOffset': item.RfidCode,
|
||||
'ZOffet': item.name,
|
||||
'COffset': 1
|
||||
})
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('get_qcCheck error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@http.route('/AutoDeviceApi/FeedBackStart', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def button_Work_START(self, **kw):
|
||||
"""
|
||||
工单任务开始
|
||||
:param kw:
|
||||
:return:
|
||||
"""
|
||||
logging.info('button_Work_START:%s' % kw)
|
||||
try:
|
||||
res = {'Succeed': True, 'Datas': []}
|
||||
datas = request.httprequest.data
|
||||
ret = json.loads(datas)
|
||||
if not ret['BillId']:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传制造订单号'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
if not ret['CraftId']:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传工序名称'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
if not ret['DeviceId']:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传设备号'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
production_id = ret['BillId']
|
||||
routing_type = ret['CraftId']
|
||||
workorder = request.env['mrp.workorder'].sudo().search(
|
||||
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
|
||||
workorder.button_start()
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('button_Work_START error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@http.route('/AutoDeviceApi/FeedBackEnd', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def button_Work_End(self, **kw):
|
||||
"""
|
||||
工单任务结束
|
||||
:param kw:
|
||||
:return:
|
||||
"""
|
||||
logging.info('button_Work_End:%s' % kw)
|
||||
try:
|
||||
res = {'Succeed': True, 'Datas': []}
|
||||
datas = request.httprequest.data
|
||||
ret = json.loads(datas)
|
||||
if not ret['BillId']:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传制造订单号'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
if not ret['CraftId']:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传工序名称'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
if not ret['DeviceId']:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传设备号'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
production_id = ret['BillId']
|
||||
routing_type = ret['CraftId']
|
||||
workorder = request.env['mrp.workorder'].sudo().search(
|
||||
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
|
||||
workorder.button_finish()
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('button_Work_End error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@http.route('/AutoDeviceApi/QcCheck', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||
cors="*")
|
||||
def Workorder_QcCheck(self, **kw):
|
||||
"""
|
||||
零件质检
|
||||
:param kw:
|
||||
:return:
|
||||
"""
|
||||
logging.info('Workorder_QcCheck:%s' % kw)
|
||||
try:
|
||||
res = {'Succeed': True, 'Datas': []}
|
||||
datas = request.httprequest.data
|
||||
ret = json.loads(datas)
|
||||
if not ret['BillId']:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传制造订单号'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
if not ret['CraftId']:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传工序名称'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
if not ret['DeviceId']:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传设备号'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
if not ret['Quality']:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传检测结果'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
if not ret['ReportPaht']:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传检查报告文件(地址)'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
production_id = ret['BillId']
|
||||
routing_type = ret['CraftId']
|
||||
request.env['mrp.workorder'].sudo().search(
|
||||
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('Workorder_QcCheck error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="sequence_routing_workcenter" model="ir.sequence">
|
||||
<field name="name">工序编码规则</field>
|
||||
<field name="code">mrp.routing.workcenter</field>
|
||||
<field name="padding">4</field>
|
||||
<field name="company_id" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record id="sequence_stock_picking_out" model="ir.sequence">
|
||||
<field name="name">YourCompany Sequence ocout</field>
|
||||
<field name="prefix">WH/OCOUT/</field>
|
||||
|
||||
@@ -450,10 +450,10 @@ class MrpProduction(models.Model):
|
||||
|
||||
for route in routingworkcenter:
|
||||
|
||||
if route.routing_type == '后置三元质量检测':
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str1(k, production, route)
|
||||
)
|
||||
# if route.routing_type == '后置三元质量检测':
|
||||
# workorders_values.append(
|
||||
# self.env['mrp.workorder'].json_workorder_str1(k, production, route)
|
||||
# )
|
||||
if route.routing_type == 'CNC加工':
|
||||
workorders_values.append(
|
||||
self.env['mrp.workorder'].json_workorder_str1(k, production, route))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
from odoo import fields, models
|
||||
from odoo import fields, models, api
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ResMrpRoutingWorkcenter(models.Model):
|
||||
@@ -10,7 +11,7 @@ class ResMrpRoutingWorkcenter(models.Model):
|
||||
('装夹预调', '装夹预调'),
|
||||
# ('前置三元定位检测', '前置三元定位检测'),
|
||||
('CNC加工', 'CNC加工'),
|
||||
('后置三元质量检测', '后置三元质量检测'),
|
||||
# ('后置三元质量检测', '后置三元质量检测'),
|
||||
('解除装夹', '解除装夹'),
|
||||
('切割', '切割'),
|
||||
('表面工艺', '表面工艺')
|
||||
@@ -21,13 +22,17 @@ class ResMrpRoutingWorkcenter(models.Model):
|
||||
bom_id = fields.Many2one('mrp.bom', required=False)
|
||||
surface_technics_id = fields.Many2one('sf.production.process', string="表面工艺")
|
||||
|
||||
def generate_code(self):
|
||||
return self.env['ir.sequence'].next_by_code('mrp.routing.workcenter')
|
||||
|
||||
code = fields.Char('编码', default=generate_code)
|
||||
|
||||
# 获得当前登陆者公司
|
||||
def get_company_id(self):
|
||||
self.company_id = self.env.user.company_id.id
|
||||
|
||||
company_id = fields.Many2one('res.company', compute="get_company_id", related=False)
|
||||
|
||||
|
||||
# 排产的时候, 根据坯料的长宽高比对一下机床的最大加工尺寸.不符合就不要分配给这个加工中心(机床).
|
||||
# 工单对应的工作中心,根据工序中的工作中心去匹配,
|
||||
# 如果只配置了一个工作中心,则默认采用该工作中心;
|
||||
|
||||
@@ -35,7 +35,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
('装夹预调', '装夹预调'),
|
||||
# ('前置三元定位检测', '前置三元定位检测'),
|
||||
('CNC加工', 'CNC加工'),
|
||||
('后置三元质量检测', '后置三元质量检测'),
|
||||
# ('后置三元质量检测', '后置三元质量检测'),
|
||||
('解除装夹', '解除装夹'),
|
||||
('切割', '切割'), ('表面工艺', '表面工艺')
|
||||
], string="工序类型")
|
||||
@@ -216,9 +216,9 @@ class ResMrpWorkOrder(models.Model):
|
||||
elif route.routing_type == 'CNC加工':
|
||||
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||
[('name', '=', 'CNC加工')]).time_cycle
|
||||
elif route.routing_type == '后置三元质量检测':
|
||||
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||
[('name', '=', '后置三元质量检测')]).time_cycle
|
||||
# elif route.routing_type == '后置三元质量检测':
|
||||
# duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||
# [('name', '=', '后置三元质量检测')]).time_cycle
|
||||
elif route.routing_type == '解除装夹':
|
||||
duration_expected = self.env['mrp.routing.workcenter'].sudo().search(
|
||||
[('name', '=', '解除装夹')]).time_cycle
|
||||
@@ -232,7 +232,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
'processing_panel': k,
|
||||
'quality_point_ids': route.route_workcenter_id.quality_point_ids,
|
||||
'routing_type': route.routing_type,
|
||||
'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起',
|
||||
'work_state': '待发起',
|
||||
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids,
|
||||
route.routing_type,
|
||||
production.product_id),
|
||||
@@ -597,6 +597,7 @@ class CNCprocessing(models.Model):
|
||||
cnc_id = fields.Many2one('ir.attachment')
|
||||
sequence_number = fields.Char('序号')
|
||||
program_name = fields.Char('程序名')
|
||||
functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型')
|
||||
cutting_tool_name = fields.Char('刀具名称')
|
||||
cutting_tool_no = fields.Char('刀号')
|
||||
processing_type = fields.Char('加工类型')
|
||||
|
||||
@@ -870,6 +870,11 @@ class SfMaintenanceEquipmentTool(models.Model):
|
||||
_description = '机床刀位'
|
||||
|
||||
equipment_id = fields.Many2one('maintenance.equipment', string='设备')
|
||||
|
||||
code = fields.Char('机床刀位号')
|
||||
name = fields.Char('刀位号', compute='_compute_name')
|
||||
|
||||
# 待删除字段
|
||||
product_template_id = fields.Many2one('product.template', string='功能刀具名称',
|
||||
domain="[('categ_type', '=', '刀具')]")
|
||||
image_1920 = fields.Binary('图片', related='product_template_id.image_1920')
|
||||
@@ -882,9 +887,6 @@ class SfMaintenanceEquipmentTool(models.Model):
|
||||
life_value_max = fields.Char('最大寿命值')
|
||||
alarm_value = fields.Char('报警值')
|
||||
used_value = fields.Char('已使用值')
|
||||
code = fields.Char('机床刀位号')
|
||||
|
||||
name = fields.Char('', compute='_compute_name')
|
||||
|
||||
@api.depends('code')
|
||||
def _compute_name(self):
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
<field name="model">mrp.routing.workcenter</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_routing_workcenter_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="name" position="before">
|
||||
<field name="code" readonly="1"/>
|
||||
</field>
|
||||
<field name="workcenter_id" position="replace">
|
||||
<field name="workcenter_ids" widget="many2many_tags" string="工作中心" required="0"/>
|
||||
<field name="surface_technics_id"
|
||||
|
||||
@@ -398,6 +398,21 @@
|
||||
</xpath>
|
||||
|
||||
|
||||
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<field name="results" invisible="1"/>
|
||||
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<group>
|
||||
<field name="test_results" widget="selection" attrs='{"invisible":[("results","!=",False)]}'/>
|
||||
<field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>
|
||||
</group>
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
|
||||
string="检测确认"
|
||||
attrs='{"invisible": ["|","|",("state","!=","progress"),("user_permissions","=",False),("results","=","合格")]}'/>
|
||||
</div>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<page string="CNC程序" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>
|
||||
<field name="cnc_ids" widget="one2many" string="工作程序">
|
||||
@@ -423,20 +438,6 @@
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<field name="results" invisible="1"/>
|
||||
<page string="后置三元检测" attrs='{"invisible": [("routing_type","!=","后置三元质量检测")]}'>
|
||||
<group>
|
||||
<field name="test_results" widget="selection" attrs='{"invisible":[("results","!=",False)]}'/>
|
||||
<field name="results" readonly="1" attrs='{"invisible":[("results","!=","合格")]}'/>
|
||||
</group>
|
||||
<div class="col-12 col-lg-6 o_setting_box">
|
||||
<button type="object" class="oe_highlight" name="recreateManufacturingOrWorkerOrder"
|
||||
string="检测确认"
|
||||
attrs='{"invisible": ["|","|",("state","!=","progress"),("user_permissions","=",False),("results","=","合格")]}'/>
|
||||
</div>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//page[1]" position="before">
|
||||
<page string="解除装夹" attrs='{"invisible": [("routing_type","!=","解除装夹")]}'>
|
||||
<!-- <field name="tray_id" readonly="1"/>-->
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
|
||||
<!-- 设备增加刀具库位table-->
|
||||
设备增加刀具库位table
|
||||
<record id="sf_manufacturing_hr_equipment_view_form" model="ir.ui.view">
|
||||
<field name="name">sf_manufacturing_equipment.form</field>
|
||||
<field name="model">maintenance.equipment</field>
|
||||
@@ -13,17 +13,6 @@
|
||||
<field name = 'product_template_ids' >
|
||||
<tree editable='bottom'>
|
||||
<field name="code"/>
|
||||
<field name="product_template_id"/>
|
||||
<field name="image_1920" widget="image"/>
|
||||
<field name="categ_type"/>
|
||||
<field name="diameter"/>
|
||||
<field name="precision"/>
|
||||
<field name="tool_code"/>
|
||||
<field name="hilt_name"/>
|
||||
<field name="hilt_code"/>
|
||||
<field name="life_value_max"/>
|
||||
<field name="alarm_value"/>
|
||||
<field name="used_value"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
||||
Reference in New Issue
Block a user