优化坯料的制造订单

This commit is contained in:
jinling.yang
2024-11-21 11:45:48 +08:00
parent 085d26669f
commit b415278997
4 changed files with 43 additions and 35 deletions

View File

@@ -56,6 +56,7 @@ class MrpProduction(models.Model):
production.deadline_of_delivery = False
else:
production.deadline_of_delivery = False
def _compute_default_delivery_status(self):
try:
if self.state == 'cancel':
@@ -676,7 +677,7 @@ class MrpProduction(models.Model):
'operation_id': operation.id,
'state': 'pending',
}]
if production.product_id.categ_id.type == '成品':
if production.product_id.categ_id.type in ['成品', '坯料']:
# # 根据工序设计生成工单
for route in production.technology_design_ids:
workorder_has = self.env['mrp.workorder'].search([('name', '=', route.route_id.name)])
@@ -691,16 +692,16 @@ class MrpProduction(models.Model):
self.env[
'mrp.workorder']._json_workorder_surface_process_str(
production, route, product_production_process.seller_ids[0].partner_id.id))
elif production.product_id.categ_id.type == '坯料':
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
[('embryo_model_type_id', '=', production.product_id.embryo_model_type_id.id)],
order='sequence asc'
)
for route_embryo in embryo_routing_workcenter:
workorder_embryo_has = self.env['mrp.workorder'].search([('name', '=', route.route_id.name)])
if not workorder_embryo_has:
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str('', production, route_embryo))
# elif production.product_id.categ_id.type == '坯料':
# embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
# [('embryo_model_type_id', '=', production.product_id.embryo_model_type_id.id)],
# order='sequence asc'
# )
# for route_embryo in embryo_routing_workcenter:
# workorder_embryo_has = self.env['mrp.workorder'].search([('name', '=', route_embryo.route_id.name)])
# if not workorder_embryo_has:
# workorders_values.append(
# self.env['mrp.workorder'].json_workorder_str('', production, route_embryo))
production.workorder_ids = workorders_values
for workorder in production.workorder_ids:
workorder.duration_expected = workorder._get_duration_expected()
@@ -990,15 +991,17 @@ class MrpProduction(models.Model):
last_time = pro_plan.date_planned_start
# 预置时间
works = self.workorder_ids
for index,work in enumerate(works):
for index, work in enumerate(works):
count = type_map.get(work.routing_type)
date_planned_end = None
date_planned_start = None
if self.production_type=='自动化产线加工':
date_planned_start,date_planned_end,last_time = work.auto_production_process(last_time,count,type_map)
elif self.production_type=='':
date_planned_start,date_planned_end,last_time = work.manual_offline_process(last_time,index)
work.update_work_start_end(date_planned_start,date_planned_end)
if self.production_type == '自动化产线加工':
date_planned_start, date_planned_end, last_time = work.auto_production_process(last_time, count,
type_map)
elif self.production_type == '':
date_planned_start, date_planned_end, last_time = work.manual_offline_process(last_time, index)
work.update_work_start_end(date_planned_start, date_planned_end)
# def
def process_range_time(self):
for production in self:

View File

@@ -794,7 +794,7 @@ class ResMrpWorkOrder(models.Model):
'operation_id': False,
'name': route.name if hasattr(route, 'routing_type') else route.route_id.name,
'processing_panel': False if hasattr(route, 'routing_type') else route.panel,
'sequence': 1 if hasattr(route, 'routing_type') else route.sequence,
'sequence': route.sequence,
'quality_point_ids': False if hasattr(route, 'routing_type') else route.route_id.quality_point_ids,
'routing_type': route.routing_type if hasattr(route, 'routing_type') else route.route_id.routing_type,
'workcenter_id': False if hasattr(route, 'routing_type') else self.env[
@@ -1993,7 +1993,7 @@ class CMMprogram(models.Model):
}))
return cmm_program
def update_work_start_end(self,date_planned_start,date_planned_end):
def update_work_start_end(self, date_planned_start, date_planned_end):
self.leave_id.write({
'date_from': date_planned_start,
'date_to': date_planned_end,
@@ -2031,7 +2031,8 @@ class CMMprogram(models.Model):
date_planned_end = date_planned_start + duration_expected
last_time = date_planned_end
return date_planned_start, date_planned_end, last_time
def manual_offline_process(self,last_time,is_first):
def manual_offline_process(self, last_time, is_first):
date_planned_end = None
date_planned_start = None
duration_expected = datetime.timedelta(minutes=self.duration_expected)
@@ -2043,4 +2044,4 @@ class CMMprogram(models.Model):
else:
date_planned_start = last_time + reserve_time
date_planned_end = date_planned_start + duration_expected
return date_planned_start, date_planned_end,last_time
return date_planned_start, date_planned_end, last_time

View File

@@ -104,15 +104,17 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
else:
workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
productions._reset_work_order_sequence()
productions._reset_subcontract_pick_purchase()
productions.get_subcontract_pick_purchase()
if self.production_id.product_id.categ_id.type == '成品':
productions._reset_subcontract_pick_purchase()
productions.get_subcontract_pick_purchase()
productions.is_adjust = True
for item in productions:
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
key=lambda a: a.sequence)
if workorders[0].state in ['pending']:
cnc_workorder = self.search(
[('production_id', '=', item.id), ('routing_type', '=', 'CNC加工')],
limit=1, order='id asc')
if cnc_workorder.cnc_ids:
workorders[0].state = 'waiting'
if workorder[0].production_id.product_id.categ_id.type == '成品':
cnc_workorder = self.search(
[('production_id', '=', item.id), ('routing_type', '=', 'CNC加工')],
limit=1, order='id asc')
if cnc_workorder.cnc_ids:
workorders[0].state = 'waiting'

View File

@@ -14,7 +14,7 @@ class ProductionTechnologyWizard(models.TransientModel):
is_technology_confirm = fields.Boolean(default=False)
def confirm(self):
if self.is_technology_confirm is True:
if self.is_technology_confirm is True and self.production_id.product_id.categ_id.type == '成品':
domain = [('origin', '=', self.origin), ('state', '=', 'technology_to_confirmed')]
else:
domain = [('id', '=', self.production_id.id)]
@@ -56,14 +56,16 @@ class ProductionTechnologyWizard(models.TransientModel):
# lambda td: td.is_auto is False and td.process_parameters_id is not False)
# # if special:
productions._create_workorder(False)
productions.get_subcontract_pick_purchase()
if self.production_id.product_id.categ_id.type == '成品':
productions.get_subcontract_pick_purchase()
productions.is_adjust = False
for item in productions:
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
key=lambda a: a.sequence)
if workorder[0].state in ['pending']:
cnc_workorder = self.search(
[('production_id', '=', item.id), ('routing_type', '=', 'CNC加工')],
limit=1, order='id asc')
if cnc_workorder.cnc_ids:
workorder[0].state = 'waiting'
if workorder[0].production_id.product_id.categ_id.type == '成品':
cnc_workorder = self.search(
[('production_id', '=', item.id), ('routing_type', '=', 'CNC加工')],
limit=1, order='id asc')
if cnc_workorder.cnc_ids:
workorder[0].state = 'waiting'