优化制造订单
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,31 +244,31 @@ 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.surface_technics_parameters_id.id),
|
||||||
[('server_product_process_parameters_id', '=', pp.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),
|
('product_qty', '=', len(production_process))], limit=1, order='id desc')
|
||||||
('product_qty', '=', len(production_process))], limit=1, order='id desc')
|
if not purchase_order_line:
|
||||||
if not purchase_order_line:
|
server_product_process.append((0, 0, {
|
||||||
server_product_process.append((0, 0, {
|
'product_id': server_template.product_variant_id.id,
|
||||||
'product_id': server_template.product_variant_id.id,
|
'product_qty': len(production_process),
|
||||||
'product_qty': len(production_process),
|
'product_uom': server_template.uom_id.id
|
||||||
'product_uom': server_template.uom_id.id
|
}))
|
||||||
}))
|
else:
|
||||||
else:
|
for item in purchase_order_line:
|
||||||
for item in purchase_order_line:
|
if production.name in production_process:
|
||||||
if production.name in production_process:
|
purchase_order = self.env['purchase.order'].search(
|
||||||
purchase_order = self.env['purchase.order'].search(
|
[('state', '=', 'draft'), ('origin', '=', ','.join(production_process)),
|
||||||
[('state', '=', 'draft'), ('origin', '=', ','.join(production_process)),
|
('id', '=', item.order_id.id)])
|
||||||
('id', '=', item.order_id.id)])
|
if not purchase_order:
|
||||||
if not purchase_order:
|
server_product_process.append((0, 0, {
|
||||||
server_product_process.append((0, 0, {
|
'product_id': server_template.product_variant_id.id,
|
||||||
'product_id': server_template.product_variant_id.id,
|
'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,
|
||||||
@@ -276,7 +276,7 @@ class RePurchaseOrder(models.Model):
|
|||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
'purchase_type': 'consignment',
|
'purchase_type': 'consignment',
|
||||||
'order_line': server_product_process})
|
'order_line': server_product_process})
|
||||||
# self.env.cr.commit()
|
# self.env.cr.commit()
|
||||||
|
|
||||||
@api.onchange('order_line')
|
@api.onchange('order_line')
|
||||||
def _onchange_order_line(self):
|
def _onchange_order_line(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user