优化获取CNC程序:添加编程方式(人工/自动),如是快速订单,编程方式为人工

This commit is contained in:
jinling.yang
2024-04-18 18:40:05 +08:00
parent 3d1dd533b5
commit 59670fb3d7
4 changed files with 26 additions and 7 deletions

View File

@@ -114,7 +114,7 @@ class Manufacturing_Connect(http.Controller):
logging.info('RfidCode:%s' % ret['RfidCode']) logging.info('RfidCode:%s' % ret['RfidCode'])
if 'RfidCode' in ret: if 'RfidCode' in ret:
workorder = request.env['mrp.workorder'].sudo().search( workorder = request.env['mrp.workorder'].sudo().search(
[('routing_type', '=', '装夹预调'), ('rfid_code', '=', ret['RfidCode'])]) [('routing_type', '=', '装夹预调'), ('rfid_code', '=', ret['RfidCode'])], limit=1, order='id asc')
if workorder: if workorder:
for item in workorder: for item in workorder:
if item.material_center_point: if item.material_center_point:
@@ -122,8 +122,8 @@ class Manufacturing_Connect(http.Controller):
res['Datas'].append({ res['Datas'].append({
'XOffset': 0 if not item.material_center_point else offset[0], 'XOffset': 0 if not item.material_center_point else offset[0],
'YOffset': 0 if not item.material_center_point else offset[1], 'YOffset': 0 if not item.material_center_point else offset[1],
'ZOffet': 0 if not item.material_center_point else offset[2], 'ZOffset': 0 if not item.material_center_point else offset[2],
'COffset': 0 if not item.X_deviation_angle else item.X_deviation_angle, 'COffset': 0,
'Coordinate': 'G54' 'Coordinate': 'G54'
}) })
else: else:

View File

@@ -57,6 +57,8 @@ class MrpProduction(models.Model):
production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')], production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
string='上/下产线', default='待上产线') string='上/下产线', default='待上产线')
manual_quotation = fields.Boolean('人工编程', default=False)
@api.depends( @api.depends(
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state',
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state') 'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state')
@@ -132,6 +134,14 @@ class MrpProduction(models.Model):
# cnc程序获取 # cnc程序获取
def fetchCNC(self): def fetchCNC(self):
cnc = self.env['mrp.production'].search([('id', '=', self.id)]) cnc = self.env['mrp.production'].search([('id', '=', self.id)])
quick_order = self.env['quick.easy.order'].search([('id', '=', cnc.product_id.id)])
programme_way = False
if cnc.manual_quotation is True:
programme_way = 'manual operation'
else:
programme_way = 'auto'
if quick_order:
programme_way = 'manual operation'
try: try:
res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code, res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code,
'production_no': cnc.name, 'production_no': cnc.name,
@@ -148,6 +158,7 @@ class MrpProduction(models.Model):
'order_no': cnc.origin, 'order_no': cnc.origin,
'model_order_no': cnc.product_id.default_code.rsplit(' -', 1)[0], 'model_order_no': cnc.product_id.default_code.rsplit(' -', 1)[0],
'user': cnc.env.user.name, 'user': cnc.env.user.name,
'programme_way': programme_way,
'model_file': '' if not cnc.product_id.model_file else base64.b64encode( 'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
cnc.product_id.model_file).decode('utf-8') cnc.product_id.model_file).decode('utf-8')
} }

View File

@@ -46,6 +46,8 @@ class ResMrpWorkOrder(models.Model):
], string="工序类型") ], string="工序类型")
results = fields.Char('结果') results = fields.Char('结果')
manual_quotation = fields.Boolean('人工编程', default=False)
@api.onchange('users_ids') @api.onchange('users_ids')
def get_user_permissions(self): def get_user_permissions(self):
uid = self.env.uid uid = self.env.uid
@@ -984,9 +986,9 @@ class SfWorkOrderBarcodes(models.Model):
workorder = self.env['mrp.workorder'].browse(self.ids) workorder = self.env['mrp.workorder'].browse(self.ids)
# workorder = self.env['mrp.workorder'].search( # workorder = self.env['mrp.workorder'].search(
# [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)]) # [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)])
# workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)]) workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)])
# if workorder_old: if workorder_old:
# raise UserError('该托盘已绑定工件,请先解除绑定!!!') raise UserError('该托盘已绑定工件,请先解除绑定!!!')
if workorder: if workorder:
if workorder.routing_type == '装夹预调': if workorder.routing_type == '装夹预调':
if workorder.state in ['done']: if workorder.state in ['done']:
@@ -1046,7 +1048,7 @@ class SfWorkOrderBarcodes(models.Model):
for item in workorder_rfid: for item in workorder_rfid:
if item.state == "progress": if item.state == "progress":
item.write({'rfid_code': barcode}) item.write({'rfid_code': barcode})
# raise UserError('该托盘信息不存在!!!') raise UserError('该托盘信息不存在!!!')
# stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)]) # stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)])
# if stock_move_line.product_id.categ_type == '夹具': # if stock_move_line.product_id.categ_type == '夹具':
# workorder.write({ # workorder.write({

View File

@@ -142,6 +142,12 @@ class ResaleOrderLine(models.Model):
check_status = fields.Selection(related='order_id.check_status') check_status = fields.Selection(related='order_id.check_status')
class ProductTemplate(models.Model):
_inherit = 'product.template'
manual_quotation = fields.Boolean('人工编程', default=False)
class RePurchaseOrder(models.Model): class RePurchaseOrder(models.Model):
_inherit = 'purchase.order' _inherit = 'purchase.order'