批量处理工艺调整
This commit is contained in:
@@ -194,6 +194,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
else:
|
||||
domain = [('origin', '=', ','.join(production_list))]
|
||||
purchase = self.env['purchase.order'].search(domain)
|
||||
if not purchase:
|
||||
order.surface_technics_purchase_count = 0
|
||||
for line in purchase.order_line:
|
||||
if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id:
|
||||
if (line.product_qty == len(production_no_remanufacture)) or technology_design.is_auto is False:
|
||||
@@ -908,25 +910,44 @@ class ResMrpWorkOrder(models.Model):
|
||||
return workorders_values_str
|
||||
|
||||
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
|
||||
'production_id.tool_state')
|
||||
'production_id.tool_state', 'production_id.schedule_state')
|
||||
def _compute_state(self):
|
||||
# super()._compute_state()
|
||||
for workorder in self:
|
||||
logging.info(workorder.name)
|
||||
logging.info(workorder.state)
|
||||
logging.info(workorder.sequence)
|
||||
logging.info(workorder.id)
|
||||
# logging.info(workorder.blocked_by_workorder_ids)
|
||||
# logging.info(workorder.blocked_by_workorder_ids.name)
|
||||
# logging.info(workorder.blocked_by_workorder_ids.sequence)
|
||||
logging.info('----------------------')
|
||||
if workorder.sequence != 1:
|
||||
previous_workorder = self.env['mrp.workorder'].search(
|
||||
[('production_id', '=', workorder.production_id.id),
|
||||
('sequence', '=', workorder.sequence - 1)])
|
||||
if workorder.state == 'pending':
|
||||
if all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
||||
workorder.state = 'ready' if workorder.production_id.reservation_state == 'assigned' else 'waiting'
|
||||
continue
|
||||
if workorder.production_id.reservation_state == 'assigned' and workorder.production_id.schedule_state == '已排':
|
||||
if (workorder.sequence == 1 and not workorder.blocked_by_workorder_ids) or (
|
||||
workorder.blocked_by_workorder_ids.state in ('done', 'cancel')) or (
|
||||
previous_workorder.state in (
|
||||
'done', 'cancel') and not workorder.blocked_by_workorder_ids):
|
||||
workorder.state = 'ready'
|
||||
continue
|
||||
if workorder.production_id.schedule_state == '未排' and workorder.state in ('waiting', 'ready'):
|
||||
if workorder.sequence != 1:
|
||||
workorder.state = 'pending'
|
||||
continue
|
||||
if workorder.state not in ('waiting', 'ready'):
|
||||
continue
|
||||
if workorder.state in (
|
||||
'waiting') and workorder.sequence == 1 and workorder.production_id.schedule_state == '已排':
|
||||
workorder.state = 'ready'
|
||||
continue
|
||||
if not all([wo.state in ('done', 'cancel') for wo in workorder.blocked_by_workorder_ids]):
|
||||
workorder.state = 'pending'
|
||||
if workorder.state in ['waiting']:
|
||||
previous_workorder = self.env['mrp.workorder'].search(
|
||||
[('production_id', '=', workorder.production_id.id),
|
||||
('sequence', '=', workorder.sequence - 1)])
|
||||
if previous_workorder.state == 'waiting':
|
||||
workorder.state = 'pending'
|
||||
if workorder.sequence == 1 and workorder.state == 'pending':
|
||||
@@ -934,7 +955,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
continue
|
||||
if workorder.production_id.reservation_state not in ('waiting', 'confirmed', 'assigned'):
|
||||
continue
|
||||
if workorder.production_id.reservation_state == 'assigned' and workorder.state == 'waiting':
|
||||
if workorder.production_id.reservation_state == 'assigned' and workorder.state == 'waiting' and workorder.production_id.schedule_state == '已排':
|
||||
workorder.state = 'ready'
|
||||
elif workorder.production_id.reservation_state != 'assigned' and workorder.state == 'ready':
|
||||
workorder.state = 'waiting'
|
||||
@@ -991,7 +1012,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
'done', 'rework',
|
||||
'cancel']:
|
||||
if workorder.production_id.is_rework is False:
|
||||
if re_work or cnc_workorder or unclamp_workorder:
|
||||
if re_work or cnc_workorder or unclamp_workorder :
|
||||
workorder.state = 'ready'
|
||||
# if (re_work or cnc_workorder) and workorder.production_id.is_rework is False:
|
||||
# workorder.state = 'ready'
|
||||
@@ -1001,7 +1022,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
workorder.state = 'ready'
|
||||
else:
|
||||
production_programming = self.env['mrp.production'].search(
|
||||
[('programming_no', '=', self.production_id.programming_no)], order='name asc')
|
||||
[('origin', '=', self.production_id.origin)], order='name asc')
|
||||
production_no_remanufacture = production_programming.filtered(
|
||||
lambda a: a.is_remanufacture is False)
|
||||
production_list = [production.name for production in production_programming]
|
||||
@@ -1088,7 +1109,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
'actual_start_time': datetime.now()
|
||||
})
|
||||
|
||||
if self.routing_type == '装夹预调':
|
||||
if self.sequence == 1:
|
||||
# 判断是否有坯料的序列号信息
|
||||
boolean = False
|
||||
if self.production_id.move_raw_ids:
|
||||
@@ -1196,9 +1217,9 @@ class ResMrpWorkOrder(models.Model):
|
||||
if record.routing_type == '装夹预调':
|
||||
if not record.rfid_code and record.is_rework is False:
|
||||
raise UserError("请扫RFID码进行绑定")
|
||||
if record.is_rework is False:
|
||||
if not record.material_center_point:
|
||||
raise UserError("坯料中心点为空,请检查")
|
||||
# if record.is_rework is False:
|
||||
# if not record.material_center_point:
|
||||
# raise UserError("坯料中心点为空,请检查")
|
||||
# if record.X_deviation_angle <= 0:
|
||||
# raise UserError("X偏差角度小于等于0,请检查!本次计算的X偏差角度为:%s" % record.X_deviation_angle)
|
||||
record.process_state = '待加工'
|
||||
@@ -1230,23 +1251,10 @@ class ResMrpWorkOrder(models.Model):
|
||||
'''
|
||||
record.date_finished = datetime.now()
|
||||
if record.routing_type == '表面工艺':
|
||||
logging.info('record.picking_ids:%s' % record.picking_ids)
|
||||
logging.info('record.picking_out:%s' % record.picking_ids[0])
|
||||
if record.picking_ids:
|
||||
for pick_item in record.picking_ids:
|
||||
if pick_item.state not in ['done']:
|
||||
raise UserError(
|
||||
'请先完成该工单的工艺外协再进行操作')
|
||||
picking_out = record.env['stock.move.line'].search(
|
||||
[('picking_id', '=', record.picking_ids[0].id)])
|
||||
logging.info('picking_out:%s' % picking_out.picking_id.name)
|
||||
# if picking_out:
|
||||
# order_line_ids = []
|
||||
# logging.info('surface_technics_parameters_id:%s' % record.surface_technics_parameters_id.name)
|
||||
#
|
||||
# else:
|
||||
# raise UserError(
|
||||
# '请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name)
|
||||
picks = record.picking_ids.filtered(lambda p: p.state not in ('done'))
|
||||
# if picks:
|
||||
# raise UserError('请先完成该工单的工艺外协再进行操作')
|
||||
tem_date_planned_finished = record.date_planned_finished
|
||||
tem_date_finished = record.date_finished
|
||||
logging.info('routing_type:%s' % record.routing_type)
|
||||
|
||||
Reference in New Issue
Block a user