合并
This commit is contained in:
@@ -285,27 +285,39 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||||
productions._create_workorder2(self.processing_panel)
|
productions._create_workorder2(self.processing_panel)
|
||||||
else:
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
return {
|
# def fetchCNCing(self):
|
||||||
'name': _("工单"),
|
# return None
|
||||||
'view_mode': 'form',
|
|
||||||
'res_model': 'mrp.workorder',
|
|
||||||
'res_id': self.id,
|
|
||||||
'type': 'ir.actions.act_window',
|
|
||||||
}
|
|
||||||
|
|
||||||
# cnc程序获取
|
|
||||||
# cnc程序获取
|
# cnc程序获取
|
||||||
def fetchCNC(self):
|
def fetchCNC(self):
|
||||||
|
try:
|
||||||
cnc = self.env['mrp.workorder'].search(
|
cnc = self.env['mrp.workorder'].search(
|
||||||
[('routing_type', '=', 'CNC加工'), ('production_id', '=', self.production_id.id)], limit=1)
|
[('routing_type', '=', 'CNC加工'), ('production_id', '=', self.production_id.id)], limit=1)
|
||||||
res = {'model_code': cnc.product_id.barcode, 'production_no': self.production_id.name,
|
logging.info('fetchCNC-cnc:%s' % cnc)
|
||||||
|
# if cnc.product_id.upload_model_file:
|
||||||
|
# logging.info('fetchCNC-upload_model_file:%s' % cnc.product_id.upload_model_file)
|
||||||
|
# attachments = cnc.product_id.upload_model_file[0]
|
||||||
|
# logging.info('fetchCNC-attachment1:%s' % attachments)
|
||||||
|
# logging.info('fetchCNC-attachment1:%s' % cnc.product_id.upload_model_file[0])
|
||||||
|
# logging.info('fetchCNC-attachment2:%s' % cnc.product_id.upload_model_file[0].datas)
|
||||||
|
# logging.info('fetchCNC-attachment:%s' % attachments.datas)
|
||||||
|
# base64_data = base64.b64encode(attachments.datas)
|
||||||
|
# logging.info('fetchCNC-attachment1:%s' % attachments)
|
||||||
|
# base64_datas = base64_data.decode('utf-8')
|
||||||
|
# model_code = hashlib.sha1(base64_datas.encode('utf-8')).hexdigest()
|
||||||
|
# logging.info('fetchCNC-model_code:%s' % model_code)
|
||||||
|
logging.info('fetchCNC-model_code1:%s' % cnc.product_id.model_code)
|
||||||
|
res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code,
|
||||||
|
'production_no': self.production_id.name,
|
||||||
'machine_tool_code': cnc.workcenter_id.machine_tool_id.code,
|
'machine_tool_code': cnc.workcenter_id.machine_tool_id.code,
|
||||||
'material_code': cnc.env['sf.production.materials'].search(
|
'material_code': cnc.env['sf.production.materials'].search(
|
||||||
[('id', '=', cnc.product_id.materials_id.id)]).materials_no,
|
[('id', '=', cnc.product_id.materials_id.id)]).materials_no,
|
||||||
'material_type_code': cnc.env['sf.materials.model'].search(
|
'material_type_code': cnc.env['sf.materials.model'].search(
|
||||||
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
|
[('id', '=', cnc.product_id.materials_type_id.id)]).materials_no,
|
||||||
'machining_precision': cnc.product_id.model_machining_precision,
|
'machining_processing_panel': cnc.product_id.model_processing_panel,
|
||||||
|
# 'machining_precision': cnc.product_id.model_machining_precision,
|
||||||
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
|
'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length,
|
||||||
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
|
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
|
||||||
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
|
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
|
||||||
@@ -322,8 +334,25 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
# res_str = json.dumps(res)
|
# res_str = json.dumps(res)
|
||||||
ret = requests.post(config_url, json={}, data=res, headers=config_header)
|
ret = requests.post(config_url, json={}, data=res, headers=config_header)
|
||||||
ret = ret.json()
|
ret = ret.json()
|
||||||
|
logging.info('fetchCNC-ret:%s' % ret)
|
||||||
if ret['status'] == 1:
|
if ret['status'] == 1:
|
||||||
return self.write({'programming_no': ret['programming_no'], 'is_programming': True})
|
self.write(
|
||||||
|
{'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'})
|
||||||
|
else:
|
||||||
|
logging.info('fetchCNC-error:%s' % cnc)
|
||||||
|
raise UserError(ret['message'])
|
||||||
|
except Exception as e:
|
||||||
|
logging.info('fetchCNC error:%s' % e)
|
||||||
|
raise UserError(e)
|
||||||
|
|
||||||
|
# return {
|
||||||
|
# 'name': _("工单"),
|
||||||
|
# 'view_mode': 'form',
|
||||||
|
# 'res_model': 'mrp.workorder',
|
||||||
|
# 'res_id': self.id,
|
||||||
|
# 'type': 'ir.actions.act_window',
|
||||||
|
# 'target': 'new'
|
||||||
|
# }
|
||||||
|
|
||||||
def json_workorder_str1(self, k, production, route):
|
def json_workorder_str1(self, k, production, route):
|
||||||
workorders_values_str = [0, '', {
|
workorders_values_str = [0, '', {
|
||||||
|
|||||||
Reference in New Issue
Block a user