优化制造订单
This commit is contained in:
@@ -647,9 +647,11 @@ class MrpProduction(models.Model):
|
|||||||
for i in range(len(sorted_workorders) - 1):
|
for i in range(len(sorted_workorders) - 1):
|
||||||
if m == 0:
|
if m == 0:
|
||||||
is_pick = False
|
is_pick = False
|
||||||
|
logging.info(sorted_workorders[i].sequence)
|
||||||
|
logging.info(sorted_workorders[i + 1].sequence)
|
||||||
|
logging.info(sorted_workorders[i + 1].sequence - 1)
|
||||||
if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
|
if sorted_workorders[i].supplier_id.id == sorted_workorders[i + 1].supplier_id.id and \
|
||||||
sorted_workorders[i].is_subcontract == sorted_workorders[i + 1].is_subcontract and \
|
sorted_workorders[i].sequence == sorted_workorders[i + 1].sequence - 1:
|
||||||
sorted_workorders[i].id == sorted_workorders[i + 1].id - 1:
|
|
||||||
if sorted_workorders[i] not in consecutive_workorders:
|
if sorted_workorders[i] not in consecutive_workorders:
|
||||||
consecutive_workorders.append(sorted_workorders[i])
|
consecutive_workorders.append(sorted_workorders[i])
|
||||||
consecutive_workorders.append(sorted_workorders[i + 1])
|
consecutive_workorders.append(sorted_workorders[i + 1])
|
||||||
@@ -659,7 +661,7 @@ class MrpProduction(models.Model):
|
|||||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
||||||
production)
|
production)
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
self.env['purchase.order'].get_purchase_order(consecutive_workorders,
|
||||||
production,
|
production,
|
||||||
product_id_to_production_names)
|
product_id_to_production_names)
|
||||||
if sorted_workorders[i] in consecutive_workorders:
|
if sorted_workorders[i] in consecutive_workorders:
|
||||||
@@ -670,13 +672,13 @@ class MrpProduction(models.Model):
|
|||||||
if is_pick is False:
|
if is_pick is False:
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
|
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
|
||||||
production)
|
production)
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
self.env['purchase.order'].get_purchase_order(sorted_workorders[i],
|
||||||
production,
|
production,
|
||||||
product_id_to_production_names)
|
product_id_to_production_names)
|
||||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders,
|
||||||
production)
|
production)
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
self.env['purchase.order'].get_purchase_order(consecutive_workorders,
|
||||||
production,
|
production,
|
||||||
product_id_to_production_names)
|
product_id_to_production_names)
|
||||||
if sorted_workorders[i] in consecutive_workorders:
|
if sorted_workorders[i] in consecutive_workorders:
|
||||||
@@ -685,18 +687,18 @@ class MrpProduction(models.Model):
|
|||||||
m = 0
|
m = 0
|
||||||
if m == len(consecutive_workorders) - 1 and m != 0:
|
if m == len(consecutive_workorders) - 1 and m != 0:
|
||||||
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
self.env['stock.picking'].create_outcontract_picking(consecutive_workorders, production)
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
self.env['purchase.order'].get_purchase_order(consecutive_workorders,
|
||||||
production,
|
production,
|
||||||
product_id_to_production_names)
|
product_id_to_production_names)
|
||||||
if is_pick is False and m == 0:
|
if is_pick is False and m == 0:
|
||||||
if len(sorted_workorders) == 1:
|
if len(sorted_workorders) == 1:
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production)
|
self.env['stock.picking'].create_outcontract_picking(sorted_workorders, production)
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
self.env['purchase.order'].get_purchase_order(sorted_workorders,
|
||||||
production,
|
production,
|
||||||
product_id_to_production_names)
|
product_id_to_production_names)
|
||||||
else:
|
else:
|
||||||
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production)
|
self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i], production)
|
||||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
self.env['purchase.order'].get_purchase_order(sorted_workorders[i],
|
||||||
production,
|
production,
|
||||||
product_id_to_production_names)
|
product_id_to_production_names)
|
||||||
|
|
||||||
|
|||||||
@@ -710,7 +710,7 @@ class ReStockMove(models.Model):
|
|||||||
return {
|
return {
|
||||||
'name': self.env['stock.picking']._get_name_Res(rescode),
|
'name': self.env['stock.picking']._get_name_Res(rescode),
|
||||||
'origin': item.name,
|
'origin': item.name,
|
||||||
'surface_technics_parameters_id': sorted_workorders.surface_technics_parameters_id.id,
|
# 'surface_technics_parameters_id': sorted_workorders.surface_technics_parameters_id.id,
|
||||||
'company_id': self.mapped('company_id').id,
|
'company_id': self.mapped('company_id').id,
|
||||||
'user_id': False,
|
'user_id': False,
|
||||||
'move_type': self.mapped('group_id').move_type or 'direct',
|
'move_type': self.mapped('group_id').move_type or 'direct',
|
||||||
|
|||||||
@@ -96,15 +96,14 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str(special.production_id, special))
|
self.env['mrp.workorder'].json_workorder_str(special.production_id, special))
|
||||||
special.production_id.write({'workorder_ids': workorders_values})
|
special.production_id.write({'workorder_ids': workorders_values})
|
||||||
special.production_id.get_subcontract_pick()
|
|
||||||
else:
|
else:
|
||||||
if len(workorder.blocked_by_workorder_ids) > 1:
|
if len(workorder.blocked_by_workorder_ids) > 1:
|
||||||
if workorder.sequence == 1:
|
if workorder.sequence == 1:
|
||||||
workorder.blocked_by_workorder_ids = None
|
workorder.blocked_by_workorder_ids = None
|
||||||
else:
|
else:
|
||||||
workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
|
workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
|
||||||
special.production_id._reset_work_order_sequence()
|
productions._reset_work_order_sequence()
|
||||||
special.production_id.get_subcontract_pick_purchase()
|
productions.get_subcontract_pick_purchase()
|
||||||
for item in productions:
|
for item in productions:
|
||||||
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||||
key=lambda a: a.sequence)
|
key=lambda a: a.sequence)
|
||||||
|
|||||||
@@ -244,9 +244,8 @@ class RePurchaseOrder(models.Model):
|
|||||||
production_process = product_id_to_production_names.get(
|
production_process = product_id_to_production_names.get(
|
||||||
production.product_id.id)
|
production.product_id.id)
|
||||||
for pp in consecutive_process_parameters:
|
for pp in consecutive_process_parameters:
|
||||||
if pp.gain_way == '外协':
|
|
||||||
server_template = self.env['product.template'].search(
|
server_template = self.env['product.template'].search(
|
||||||
[('server_product_process_parameters_id', '=', pp.id),
|
[('server_product_process_parameters_id', '=', pp.surface_technics_parameters_id.id),
|
||||||
('detailed_type', '=', 'service')])
|
('detailed_type', '=', 'service')])
|
||||||
purchase_order_line = self.env['purchase.order.line'].search(
|
purchase_order_line = self.env['purchase.order.line'].search(
|
||||||
[('product_id', '=', server_template.product_variant_id.id),
|
[('product_id', '=', server_template.product_variant_id.id),
|
||||||
@@ -269,6 +268,7 @@ class RePurchaseOrder(models.Model):
|
|||||||
'product_qty': len(production_process),
|
'product_qty': len(production_process),
|
||||||
'product_uom': server_template.uom_id.id
|
'product_uom': server_template.uom_id.id
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if server_product_process:
|
if server_product_process:
|
||||||
self.env['purchase.order'].sudo().create({
|
self.env['purchase.order'].sudo().create({
|
||||||
'partner_id': server_template.seller_ids[0].partner_id.id,
|
'partner_id': server_template.seller_ids[0].partner_id.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user