优化表面工艺
This commit is contained in:
@@ -272,73 +272,79 @@ class StockRule(models.Model):
|
||||
product_id_to_production_names[product_id] = [production.name for production in all_production]
|
||||
for production_item in productions:
|
||||
if production_item.product_id.id in product_id_to_production_names:
|
||||
# sorted_process_parameters = sorted(production_item.product_id.model_process_parameters_ids, key=lambda w: w.id)
|
||||
# consecutive_process_parameters = []
|
||||
# m = 0
|
||||
# for i in range(len(sorted_process_parameters) - 1):
|
||||
# if m == 0:
|
||||
# is_pick = False
|
||||
# if sorted_process_parameters[i].supplier_id.id == sorted_process_parameters[i + 1].supplier_id.id and :
|
||||
# if sorted_process_parameters[i] not in consecutive_process_parameters:
|
||||
# consecutive_process_parameters.append(sorted_process_parameters[i])
|
||||
# consecutive_process_parameters.append(sorted_process_parameters[i + 1])
|
||||
# m += 1
|
||||
# continue
|
||||
# else:
|
||||
# if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||
# self.env['stock.picking'].create_outcontract_picking(consecutive_process_parameters,
|
||||
# production_item)
|
||||
# if sorted_process_parameters[i] in consecutive_workorders:
|
||||
# is_pick = True
|
||||
# consecutive_process_parameters = []
|
||||
# m = 0
|
||||
# # 当前面的连续工序生成对应的采购单再生成当前工序的外协采购单
|
||||
# if is_pick is False:
|
||||
# self.env['stock.picking'].create_outcontract_picking(sorted_workorders[i],
|
||||
# production_item)
|
||||
# if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||
# self.env['stock.picking'].create_outcontract_picking(consecutive_process_parameters,
|
||||
# production_item)
|
||||
# if sorted_process_parameters[i] in consecutive_process_parameters:
|
||||
# is_pick = True
|
||||
# consecutive_process_parameters = []
|
||||
# m = 0
|
||||
# if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||
# self.env['stock.picking'].create_outcontract_picking(consecutive_process_parameters, production_item)
|
||||
# if is_pick is False and m == 0:
|
||||
# if len(sorted_process_parameters) == 1:
|
||||
# self.env['stock.picking'].create_outcontract_picking(sorted_process_parameters, production_item)
|
||||
# else:
|
||||
# self.env['stock.picking'].create_outcontract_picking(sorted_process_parameters[i], production_item)
|
||||
for pp in production_item.product_id.model_process_parameters_ids:
|
||||
if pp.gain_way == '外协':
|
||||
server_product = 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_product.id)])
|
||||
if not purchase_order_line:
|
||||
is_exist = False
|
||||
else:
|
||||
for item in purchase_order_line:
|
||||
purchase_order = self.env['purchase.order'].search(
|
||||
[('state', '=', 'draft'), ('origin', 'ilike', production_item.name),
|
||||
('id', '=', item.order_id)])
|
||||
if not purchase_order:
|
||||
is_exist = False
|
||||
if is_exist is False:
|
||||
production_process = product_id_to_production_names.get(
|
||||
production_item.product_id.id)
|
||||
self.env['purchase.order'].sudo().create({
|
||||
'partner_id': server_product.seller_ids.partner_id.id,
|
||||
'origin': ','.join(production_process),
|
||||
'state': 'draft',
|
||||
'order_line': [(0, 0, {
|
||||
'product_id': server_product.product_variant_id.id,
|
||||
'product_qty': len(production_process),
|
||||
'product_uom': server_product.uom_id.id
|
||||
})]
|
||||
})
|
||||
sorted_process_parameters = sorted(production_item.product_id.model_process_parameters_ids,
|
||||
key=lambda w: w.id)
|
||||
consecutive_process_parameters = []
|
||||
m = 0
|
||||
for i in range(len(sorted_process_parameters) - 1):
|
||||
if m == 0:
|
||||
is_purchase = False
|
||||
if sorted_process_parameters[i].supplier_id.id == sorted_process_parameters[
|
||||
i + 1].supplier_id.id and sorted_process_parameters[i].gain_way == '外协':
|
||||
if sorted_process_parameters[i] not in consecutive_process_parameters:
|
||||
consecutive_process_parameters.append(sorted_process_parameters[i])
|
||||
consecutive_process_parameters.append(sorted_process_parameters[i + 1])
|
||||
m += 1
|
||||
continue
|
||||
else:
|
||||
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
||||
production_item,
|
||||
product_id_to_production_names)
|
||||
if sorted_process_parameters[i] in consecutive_workorders:
|
||||
is_purchase = True
|
||||
consecutive_process_parameters = []
|
||||
m = 0
|
||||
# 当前面的连续采购单生成再生成当前工序的外协采购单
|
||||
if is_purchase is False:
|
||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters[i],
|
||||
production_item, product_id_to_production_names)
|
||||
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters,
|
||||
production_item, product_id_to_production_names)
|
||||
if sorted_process_parameters[i] in consecutive_process_parameters:
|
||||
is_purchase = True
|
||||
consecutive_process_parameters = []
|
||||
m = 0
|
||||
if m == len(consecutive_process_parameters) - 1 and m != 0:
|
||||
self.env['purchase.order'].get_purchase_order(consecutive_process_parameters, production_item,
|
||||
product_id_to_production_names)
|
||||
if is_purchase is False and m == 0:
|
||||
if len(sorted_process_parameters) == 1:
|
||||
self.env['purchase.order'].get_purchase_order(sorted_process_parameters, production_item,
|
||||
product_id_to_production_names)
|
||||
else:
|
||||
self.env['purchase.order'].get_purchase_order(sorted_process_parameters[i], production_item,
|
||||
product_id_to_production_names)
|
||||
# for pp in production_item.product_id.model_process_parameters_ids:
|
||||
# if pp.gain_way == '外协':
|
||||
# server_product = 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_product.id)])
|
||||
# if not purchase_order_line:
|
||||
# is_exist = False
|
||||
# else:
|
||||
# for item in purchase_order_line:
|
||||
# purchase_order = self.env['purchase.order'].search(
|
||||
# [('state', '=', 'draft'), ('origin', 'ilike', production_item.name),
|
||||
# ('id', '=', item.order_id)])
|
||||
# if not purchase_order:
|
||||
# is_exist = False
|
||||
# if is_exist is False:
|
||||
# production_process = product_id_to_production_names.get(
|
||||
# production_item.product_id.id)
|
||||
# self.env['purchase.order'].sudo().create({
|
||||
# 'partner_id': server_product.seller_ids.partner_id.id,
|
||||
# 'origin': ','.join(production_process),
|
||||
# 'state': 'draft',
|
||||
# 'order_line': [(0, 0, {
|
||||
# 'product_id': server_product.product_variant_id.id,
|
||||
# 'product_qty': len(production_process),
|
||||
# 'product_uom': server_product.uom_id.id
|
||||
# })]
|
||||
# })
|
||||
|
||||
# # 同一个产品多个制造订单对应一个编程单和模型库
|
||||
# # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
|
||||
@@ -575,18 +581,18 @@ class StockPicking(models.Model):
|
||||
_('该入库单对应的单号为%s的出库单还未完成,不能进行验证操作!' % move_out.picking_id.name))
|
||||
res = super().button_validate()
|
||||
# if res is True:
|
||||
# if self.id == move_out.picking_id.id:
|
||||
# # if move_out.move_line_ids.workorder_id.state == 'progress':
|
||||
# move_in = self.env['stock.move'].search(
|
||||
# [('location_dest_id', '=', self.env['stock.location'].search(
|
||||
# [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
||||
# ('location_id', '=', self.env['stock.location'].search(
|
||||
# [('barcode', 'ilike', 'VL-SPOC')]).id),
|
||||
# ('origin', '=', self.origin)])
|
||||
# production = self.env['mrp.production'].search([('name', '=', self.origin)])
|
||||
# if move_in:
|
||||
# move_in.write({'state': 'assigned'})
|
||||
# self.env['stock.move.line'].create(move_in.get_move_line(production, None))
|
||||
# if self.id == move_out.picking_id.id:
|
||||
# # if move_out.move_line_ids.workorder_id.state == 'progress':
|
||||
# move_in = self.env['stock.move'].search(
|
||||
# [('location_dest_id', '=', self.env['stock.location'].search(
|
||||
# [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
||||
# ('location_id', '=', self.env['stock.location'].search(
|
||||
# [('barcode', 'ilike', 'VL-SPOC')]).id),
|
||||
# ('origin', '=', self.origin)])
|
||||
# production = self.env['mrp.production'].search([('name', '=', self.origin)])
|
||||
# if move_in:
|
||||
# move_in.write({'state': 'assigned'})
|
||||
# self.env['stock.move.line'].create(move_in.get_move_line(production, None))
|
||||
|
||||
return res
|
||||
|
||||
|
||||
Reference in New Issue
Block a user