新增获得mrs下发编程单

This commit is contained in:
jinling.yang
2022-11-20 19:44:31 +08:00
parent a0b7b13c5e
commit aeb9b0f796
5 changed files with 51 additions and 3 deletions

View File

@@ -264,5 +264,5 @@ class CNCprocessing(models.Model):
FJGSD = fields.Char(string="加工深度(Z)") FJGSD = fields.Char(string="加工深度(Z)")
FSCCD = fields.Char(string="刀具伸出长度") FSCCD = fields.Char(string="刀具伸出长度")
FDJSpec = fields.Char(string="刀柄型号") FDJSpec = fields.Char(string="刀柄型号")
FJGDate = fields.Char(string="预计加工时间") FJGDate = fields.Datetime(string="预计加工时间")
FComment = fields.Char(string="备注") FComment = fields.Char(string="备注")

View File

@@ -10,7 +10,7 @@
""", """,
'category': 'YZ', 'category': 'YZ',
'website': 'https://www.sf.cs.jikimo.com', 'website': 'https://www.sf.cs.jikimo.com',
'depends': [], 'depends': ['sf_base'],
'data': [ 'data': [
# 'views/sale_process_order_view.xml' # 'views/sale_process_order_view.xml'
], ],

View File

@@ -0,0 +1 @@
from . import controllers

View File

@@ -1 +1,27 @@
from . import controllers # -*- coding: utf-8 -*-
import json
import logging
from datetime import date, timedelta
from odoo import http
from odoo.http import request
class Sf_Mrs_Connect(http.Controller):
@http.route('/api/cnc_processing/create', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
cors="*")
def get_cnc_processing_create(self, **kw):
"""
获取mrs下发的编程单
:param kw:
:return:
"""
logging.info('get_cnc_processing_create:%s' % kw)
try:
datas = request.httprequest.data
ret = json.loads(datas)
ret = json.loads(ret['result'])
for obj in ret:
request.env['cnc.processing'].with_user(request.env.ref("base.user_admin")).CNCprocessing_create(obj)
except Exception as e:
logging.info('get_cnc_processing_create error:%s' % e)

View File

@@ -21,6 +21,26 @@ class CNCprocessing(models.Model):
workorder_id = fields.Many2one('mrp.workorder', string="工单") workorder_id = fields.Many2one('mrp.workorder', string="工单")
# mrs下发编程单创建CNC加工
def CNCprocessing_create(self, obj):
workorder = self.env['mrp.workorder'].search([('production_id', '=', obj['manufacturing_order_no']),
('processing_panel', '=', obj['processing_panel']),
('routing_type', '=', 'CNC加工')])
self.env['cnc.processing'].create({
'workorder_id': workorder.id,
'FNo': obj['sequence_number'],
'FPGName': obj['program_name'],
'FKnifeName': obj['cutting_tool_name'],
'FDNo': obj['cutting_tool_no'],
'FWorkType': obj['processing_type'],
'FXY': obj['margin_x_y'],
'FZ': obj['margin_z'],
'FJGSD': obj['depth_of_processing_z'],
'FSCCD': obj['cutting_tool_extension_length'],
'FDJSpec': obj['cutting_tool_handle_type'],
# 'FJGDate': obj['']
})
class Tray(models.Model): class Tray(models.Model):
_inherit = 'sf.tray' _inherit = 'sf.tray'
@@ -259,6 +279,7 @@ class MrpWorkOrder(models.Model):
'embryo_long': self.product_id.bom_ids.bom_line_ids.product_id.long, 'embryo_long': self.product_id.bom_ids.bom_line_ids.product_id.long,
'embryo_height': self.product_id.bom_ids.bom_line_ids.product_id.height, 'embryo_height': self.product_id.bom_ids.bom_line_ids.product_id.height,
'embryo_width': self.product_id.bom_ids.bom_line_ids.product_id.width 'embryo_width': self.product_id.bom_ids.bom_line_ids.product_id.width
# 'factory_code': self.env.user.company_id.partner_id.
}] }]
configsettings = self.env['res.config.settings'].get_values() configsettings = self.env['res.config.settings'].get_values()
# token = configsettings['token'] # token = configsettings['token']