Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/优化制造订单和编程
This commit is contained in:
@@ -820,54 +820,56 @@ class ResMrpWorkOrder(models.Model):
|
||||
raise UserError(_('请先完成上一步工单'))
|
||||
|
||||
def button_finish(self):
|
||||
if self.routing_type == '装夹预调':
|
||||
if not self.material_center_point and self.X_deviation_angle > 0:
|
||||
raise UserError("请对前置三元检测定位参数进行计算定位")
|
||||
if not self.rfid_code:
|
||||
raise UserError("请扫RFID码进行绑定")
|
||||
if self.routing_type == '解除装夹':
|
||||
'''
|
||||
记录结束时间
|
||||
'''
|
||||
self.date_finished = datetime.now()
|
||||
if self.picking_out_id:
|
||||
picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)])
|
||||
if picking_out.workorder_out_id:
|
||||
order_line_ids = []
|
||||
for item in picking_out.workorder_out_id:
|
||||
server_product = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', item.surface_technics_parameters_id.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
if server_product:
|
||||
order_line_ids.append((0, 0, {
|
||||
'product_id': server_product.product_variant_id.id,
|
||||
'product_qty': 1,
|
||||
'product_uom': server_product.uom_id.id
|
||||
}))
|
||||
else:
|
||||
raise UserError(
|
||||
'请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name)
|
||||
self.env['purchase.order'].create({
|
||||
'partner_id': server_product.seller_ids.partner_id.id,
|
||||
'state': 'draft',
|
||||
'order_line': order_line_ids,
|
||||
})
|
||||
super().button_finish()
|
||||
is_production_id = True
|
||||
for workorder in self.production_id.workorder_ids:
|
||||
if workorder.state != 'done':
|
||||
is_production_id = False
|
||||
if is_production_id == True and self.name == '解除装夹':
|
||||
for workorder in self.production_id.workorder_ids:
|
||||
workorder.rfid_code_old = workorder.rfid_code
|
||||
workorder.rfid_code = None
|
||||
for move_raw_id in self.production_id.move_raw_ids:
|
||||
move_raw_id.quantity_done = move_raw_id.product_uom_qty
|
||||
self.process_state = '已完工'
|
||||
self.production_id.button_mark_done1()
|
||||
# self.production_id.state = 'done'
|
||||
# if self.routing_type == '装夹预调':
|
||||
# self.workpiece_delivery_ids.write({''})
|
||||
for record in self:
|
||||
if record.routing_type == '装夹预调':
|
||||
if not record.material_center_point and record.X_deviation_angle > 0:
|
||||
raise UserError("请对前置三元检测定位参数进行计算定位")
|
||||
if not record.rfid_code:
|
||||
raise UserError("请扫RFID码进行绑定")
|
||||
record.workpiece_delivery_ids[0].write({'status': '待下发'})
|
||||
|
||||
if record.routing_type == '解除装夹':
|
||||
'''
|
||||
记录结束时间
|
||||
'''
|
||||
record.date_finished = datetime.now()
|
||||
|
||||
if record.picking_out_id:
|
||||
picking_out = record.env['stock.picking'].search([('id', '=', record.picking_out_id.id)])
|
||||
if picking_out.workorder_out_id:
|
||||
order_line_ids = []
|
||||
for item in picking_out.workorder_out_id:
|
||||
server_product = record.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', item.surface_technics_parameters_id.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
if server_product:
|
||||
order_line_ids.append((0, 0, {
|
||||
'product_id': server_product.product_variant_id.id,
|
||||
'product_qty': 1,
|
||||
'product_uom': server_product.uom_id.id
|
||||
}))
|
||||
else:
|
||||
raise UserError(
|
||||
'请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name)
|
||||
record.env['purchase.order'].create({
|
||||
'partner_id': server_product.seller_ids.partner_id.id,
|
||||
'state': 'draft',
|
||||
'order_line': order_line_ids,
|
||||
})
|
||||
super().button_finish()
|
||||
is_production_id = True
|
||||
for workorder in record.production_id.workorder_ids:
|
||||
if workorder.state != 'done':
|
||||
is_production_id = False
|
||||
if is_production_id == True and record.name == '解除装夹':
|
||||
for workorder in record.production_id.workorder_ids:
|
||||
workorder.rfid_code_old = workorder.rfid_code
|
||||
workorder.rfid_code = None
|
||||
for move_raw_id in record.production_id.move_raw_ids:
|
||||
move_raw_id.quantity_done = move_raw_id.product_uom_qty
|
||||
record.process_state = '已完工'
|
||||
record.production_id.button_mark_done1()
|
||||
# self.production_id.state = 'done'
|
||||
|
||||
# 将FTP的检测报告文件下载到临时目录
|
||||
def download_reportfile_tmp(self, workorder, reportpath):
|
||||
@@ -1056,10 +1058,11 @@ class SfWorkOrderBarcodes(models.Model):
|
||||
workorder = self.env['mrp.workorder'].browse(self.ids)
|
||||
# workorder_preset = self.env['mrp.workorder'].search(
|
||||
# [('routing_type', '=', '装夹预调'), ('rfid_code', '=', barcode)])
|
||||
workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)])
|
||||
if workorder_old:
|
||||
workorder_olds = self.env['mrp.workorder'].search(
|
||||
[('routing_type', '=', '装夹预调'), ('rfid_code', '=', barcode)])
|
||||
if workorder_olds:
|
||||
name = ''
|
||||
for workorder in workorder_old:
|
||||
for workorder in workorder_olds:
|
||||
name = '%s %s' % (name, workorder.production_id.name)
|
||||
raise UserError('该托盘已绑定【%s】制造订单,请先解除绑定!!!' % name)
|
||||
if workorder:
|
||||
@@ -1089,6 +1092,8 @@ class SfWorkOrderBarcodes(models.Model):
|
||||
for item in workorder_rfid:
|
||||
item.write({'rfid_code': barcode})
|
||||
logging.info("Rfid绑定成功!!!")
|
||||
else:
|
||||
raise UserError('该Rfid【%s】绑定的是【%s】, 不是托盘!!!' % (barcode, lot.product_id.name))
|
||||
self.process_state = '待检测'
|
||||
self.date_start = datetime.now()
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user