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