优化及调试表面工艺外协出入库单,‘胚料’修改为‘坯料’

This commit is contained in:
jinling.yang
2023-04-20 19:39:12 +08:00
parent 4e2947c107
commit 82dcfb5018
13 changed files with 142 additions and 230 deletions

View File

@@ -138,31 +138,35 @@ class MrpProduction(models.Model):
surface_technics_arr.append(item.route_workcenter_id.surface_technics_id.id)
route_workcenter_arr.append(item.route_workcenter_id.id)
if surface_technics_arr:
production_process = self.env['sf.production.process.category'].search(
production_process_category = self.env['sf.production.process.category'].search(
[('production_process_ids.id', 'in', surface_technics_arr)],
order='sequence asc'
)
if production_process:
for p in production_process:
for pitem in p.production_process_ids:
if pitem.id in surface_technics_arr:
for param in production.product_id.model_process_parameters_ids:
process_parameter = self.env['sf.production.process.parameter'].search(
[('process_id.id', '=', pitem.id), ('id', '=', param.id)])
# 产品为表面工艺服务的供应商
product_production_process = self.env['product.template'].search(
[('server_product_process_parameters_id', '=', process_parameter.id)])
if process_parameter:
for ritem in route_workcenter_arr:
route_production_process = self.env['mrp.routing.workcenter'].search(
[('surface_technics_id', '=', pitem.id), ('id', '=', ritem)])
if route_production_process:
workorders_values.append(
self.env['mrp.workorder']._json_workorder_surface_process_str(
production, route_production_process,
process_parameter,
product_production_process.seller_ids[0].id))
elif production.product_id.categ_id.type == '胚料':
#用filter刷选表面工艺id'是否存在工艺类别对象里
if production_process_category:
for p in production_process_category:
production_process = p.production_process_ids.filtered(
lambda pp: pp.id in surface_technics_arr)
if production_process:
process_parameter = production.product_id.model_process_parameters_ids.filtered(
lambda pm: pm.process_id.id == production_process.id)
if process_parameter:
# 产品为表面工艺服务的供应商
product_production_process = self.env['product.template'].search(
[('server_product_process_parameters_id', '=', process_parameter.id)])
if product_production_process:
route_production_process = self.env[
'mrp.routing.workcenter'].search(
[('surface_technics_id', '=', production_process.id),
('id', 'in', route_workcenter_arr)])
if route_production_process:
workorders_values.append(
self.env[
'mrp.workorder']._json_workorder_surface_process_str(
production, route_production_process,
process_parameter,
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'
@@ -171,23 +175,49 @@ class MrpProduction(models.Model):
workorders_values.append(
self.env['mrp.workorder'].json_workorder_str('', production, route))
production.workorder_ids = workorders_values
aa = self.env['mrp.workorder'].get_no_data(production.id)
if aa:
consecutive_workorders = []
m =0
sorted_workorders = sorted(aa, key=lambda w: w.id)
for i in range(len(sorted_workorders) - 1):
if sorted_workorders[i].supplier_id == sorted_workorders[i + 1].supplier_id and \
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
consecutive_workorders.append(sorted_workorders[i])
consecutive_workorders.append(sorted_workorders[i + 1])
m+1
process_parameter_workorder = self.env['mrp.workorder'].search(
[('surface_technics_parameters_id', '!=', False), ('production_id', '=', production.id)])
if process_parameter_workorder:
is_pick = False
consecutive_workorders = []
m = 0
sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.id)
for i in range(len(sorted_workorders) - 1):
if m == 0:
is_pick = False
# if sorted_workorders[i].id in consecutive_workorders:
# consecutive_workorders = [x for x in consecutive_workorders if x not in sorted_workorders[i].id]
# continue
if sorted_workorders[i].supplier_id == sorted_workorders[i + 1].supplier_id and \
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
if sorted_workorders[i] not in consecutive_workorders:
consecutive_workorders.append(sorted_workorders[i])
consecutive_workorders.append(sorted_workorders[i + 1])
m += 1
continue
else:
if m == len(consecutive_workorders)-1 and m != 0:
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
if sorted_workorders[i] in consecutive_workorders:
is_pick = True
consecutive_workorders = []
m = 0
# 当前面的连续工序生成对应的外协出入库单再生成当前工序的外协出入库单
if is_pick is False:
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production)
if m == len(consecutive_workorders)-1 and m != 0:
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
if sorted_workorders[i] in consecutive_workorders:
is_pick = True
consecutive_workorders = []
m = 0
if m == len(consecutive_workorders) - 1 and m != 0:
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
if is_pick is False:
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production)
for workorder in production.workorder_ids:
workorder.duration_expected = workorder._get_duration_expected()
# 在之前的销售单上重新生成制造订单
def create_production1_values(self, production):
production_values_str = {'origin': production.origin,
@@ -210,6 +240,20 @@ class MrpProduction(models.Model):
'user_id': production.user_id.id}
return production_values_str
def _get_stock_move_values_Res(self,item,location_src_id,location_dest_id):
move_values = {
'name': item.name if item.name else '/',
'company_id': item.company_id.id,
'product_id': item.bom_id.bom_line_ids.product_id.id,
'product_uom': item.bom_id.bom_line_ids.product_uom_id.id,
'product_uom_qty': 1.0,
'location_id': location_src_id,
'location_dest_id': location_dest_id,
'origin': item.origin,
'picking_type_id': self.picking_type_id.id,
}
return move_values
# 工单排序
def _reset_work_order_sequence1(self, k):
sequen = 0