Accept Merge Request #1576: (feature/修复外协出入库单 -> develop)
Merge Request: 修复外协出入库单 Created By: @杨金灵 Reviewed By: @胡尧 Approved By: @胡尧 Accepted By: @杨金灵 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1576
This commit is contained in:
@@ -309,7 +309,8 @@ class MrpProduction(models.Model):
|
||||
for move in production.move_raw_ids if move.product_id):
|
||||
production.state = 'progress'
|
||||
# 新添加的状态逻辑
|
||||
if production.state in ['to_close', 'progress', 'technology_to_confirmed'] and production.schedule_state == '未排':
|
||||
if production.state in ['to_close', 'progress',
|
||||
'technology_to_confirmed'] and production.schedule_state == '未排':
|
||||
if not production.workorder_ids or production.is_adjust is True:
|
||||
production.state = 'technology_to_confirmed'
|
||||
else:
|
||||
@@ -356,7 +357,6 @@ class MrpProduction(models.Model):
|
||||
if production.tool_state == '2':
|
||||
production.state = 'rework'
|
||||
|
||||
|
||||
# 退回调整
|
||||
def technology_back_adjust(self):
|
||||
process_parameters = []
|
||||
@@ -849,15 +849,20 @@ class MrpProduction(models.Model):
|
||||
purchase_order = self.env['purchase.order'].search(
|
||||
[('state', '=', 'draft'), ('origin', '=', item.name),
|
||||
('purchase_type', '=', 'consignment')])
|
||||
for line in purchase_order.order_line:
|
||||
server_template = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=', workorder.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), ('id', '=', line.id),
|
||||
('product_qty', '=', 1)], limit=1, order='id desc')
|
||||
if purchase_order_line:
|
||||
line.unlink()
|
||||
server_template = self.env['product.template'].search(
|
||||
[('server_product_process_parameters_id', '=',
|
||||
workorder.surface_technics_parameters_id.id),
|
||||
('detailed_type', '=', 'service')])
|
||||
for po in purchase_order:
|
||||
for line in po.order_line:
|
||||
if line.product_id == server_template.product_variant_id:
|
||||
continue
|
||||
if server_template.server_product_process_parameters_id != line.product_id.server_product_process_parameters_id:
|
||||
purchase_order_line = self.env['purchase.order.line'].search(
|
||||
[('product_id', '=', server_template.product_variant_id.id), ('id', '=', line.id),
|
||||
('product_qty', '=', 1)], limit=1, order='id desc')
|
||||
if purchase_order_line:
|
||||
line.unlink()
|
||||
|
||||
def _reset_work_order_sequence(self):
|
||||
"""
|
||||
@@ -898,8 +903,6 @@ class MrpProduction(models.Model):
|
||||
for cw in cancel_work_ids:
|
||||
cw.sequence = sequence + 1
|
||||
|
||||
|
||||
|
||||
def _reset_work_order_sequence_1(self):
|
||||
"""
|
||||
工单工序排序方法(旧)
|
||||
|
||||
@@ -1246,10 +1246,14 @@ class ResMrpWorkOrder(models.Model):
|
||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
||||
('location_dest_id', '=', self.env['stock.location'].search(
|
||||
[('barcode', 'ilike', 'VL-SPOC')]).id),
|
||||
('origin', '=', self.production_id.name)])
|
||||
if move_out.state != 'done':
|
||||
move_out.write({'state': 'assigned', 'production_id': False})
|
||||
self.env['stock.move.line'].create(move_out.get_move_line(self.production_id, self))
|
||||
('origin', '=', self.production_id.name), ('state', 'not in', ['cancel', 'done'])])
|
||||
for mo in move_out:
|
||||
pick = self.env['stock.picking'].search([('id', '=', mo.picking_id.id), ('name', 'ilike', 'OCOUT'),
|
||||
('partner_id', '=', self.supplier_id.id)])
|
||||
if pick:
|
||||
if mo.state != 'done':
|
||||
mo.write({'state': 'assigned', 'production_id': False})
|
||||
self.env['stock.move.line'].create(mo.get_move_line(self.production_id, self))
|
||||
|
||||
# move_out._action_assign()
|
||||
if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress':
|
||||
|
||||
@@ -290,7 +290,7 @@ class StockRule(models.Model):
|
||||
else:
|
||||
mrp_production = production
|
||||
# if sale_order:
|
||||
# sale_order.write({'schedule_status': 'to schedule'})
|
||||
# sale_order.write({'schedule_status': 'to schedule'})
|
||||
self.env['sf.production.plan'].sudo().with_company(company_id).create({
|
||||
'name': production.name,
|
||||
'order_deadline': sale_order.deadline_of_delivery,
|
||||
@@ -301,7 +301,6 @@ class StockRule(models.Model):
|
||||
'product_id': production.product_id.id,
|
||||
'state': 'draft',
|
||||
})
|
||||
technology_design_values = []
|
||||
all_production = productions
|
||||
grouped_product_ids = {k: list(g) for k, g in groupby(all_production, key=lambda x: x.product_id.id)}
|
||||
# 初始化一个字典来存储每个product_id对应的生产订单名称列表
|
||||
@@ -311,6 +310,7 @@ class StockRule(models.Model):
|
||||
# 为同一个product_id创建一个生产订单名称列表
|
||||
product_id_to_production_names[product_id] = [production.name for production in all_production]
|
||||
for production_item in productions:
|
||||
technology_design_values = []
|
||||
production_programming = self.env['mrp.production'].search(
|
||||
[('product_id.id', '=', production_item.product_id.id),
|
||||
('origin', '=', production_item.origin)],
|
||||
@@ -325,70 +325,69 @@ class StockRule(models.Model):
|
||||
else:
|
||||
production_item.write({'programming_no': production_programming.programming_no,
|
||||
'programming_state': '编程中'})
|
||||
if not technology_design_values:
|
||||
i = 0
|
||||
if production_item.product_id.categ_id.type == '成品':
|
||||
# 根据加工面板的面数及成品工序模板生成工序设计
|
||||
if production_item.production_type == '自动化产线加工':
|
||||
model = 'sf.product.model.type.routing.sort'
|
||||
domain = [
|
||||
('product_model_type_id', '=', production_item.product_id.product_model_type_id.id)]
|
||||
else:
|
||||
model = 'sf.manual.product.model.type.routing.sort'
|
||||
domain = [('manual_product_model_type_id', '=',
|
||||
production_item.product_id.product_model_type_id.id)]
|
||||
product_routing_workcenter = self.env[model].search(domain, order='sequence asc')
|
||||
if production_item.production_type == '自动化产线加工':
|
||||
for k in (production_item.product_id.model_processing_panel.split(',')):
|
||||
for route in product_routing_workcenter:
|
||||
i += 1
|
||||
technology_design_values.append(
|
||||
self.env['sf.technology.design'].json_technology_design_str(k, route, i, False))
|
||||
else:
|
||||
i = 0
|
||||
if production_item.product_id.categ_id.type == '成品':
|
||||
# 根据加工面板的面数及成品工序模板生成工序设计
|
||||
if production_item.production_type == '自动化产线加工':
|
||||
model = 'sf.product.model.type.routing.sort'
|
||||
domain = [
|
||||
('product_model_type_id', '=', production_item.product_id.product_model_type_id.id)]
|
||||
else:
|
||||
model = 'sf.manual.product.model.type.routing.sort'
|
||||
domain = [('manual_product_model_type_id', '=',
|
||||
production_item.product_id.product_model_type_id.id)]
|
||||
product_routing_workcenter = self.env[model].search(domain, order='sequence asc')
|
||||
if production_item.production_type == '自动化产线加工':
|
||||
for k in (production_item.product_id.model_processing_panel.split(',')):
|
||||
for route in product_routing_workcenter:
|
||||
i += 1
|
||||
technology_design_values.append(
|
||||
self.env['sf.technology.design'].json_technology_design_str(False, route, i, False))
|
||||
elif production_item.product_id.categ_id.type == '坯料':
|
||||
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
|
||||
[('embryo_model_type_id', '=', production_item.product_id.embryo_model_type_id.id)],
|
||||
order='sequence asc'
|
||||
)
|
||||
for route_embryo in embryo_routing_workcenter:
|
||||
self.env['sf.technology.design'].json_technology_design_str(k, route, i, False))
|
||||
else:
|
||||
for route in product_routing_workcenter:
|
||||
i += 1
|
||||
technology_design_values.append(
|
||||
self.env['sf.technology.design'].json_technology_design_str(False, route_embryo, i,
|
||||
False))
|
||||
surface_technics_arr = []
|
||||
route_workcenter_arr = []
|
||||
for item in production_item.product_id.product_model_type_id.surface_technics_routing_tmpl_ids:
|
||||
if item.route_workcenter_id.surface_technics_id.id:
|
||||
for process_param in production_item.product_id.model_process_parameters_ids:
|
||||
if item.route_workcenter_id.surface_technics_id == process_param.process_id:
|
||||
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'].search(
|
||||
[('id', 'in', surface_technics_arr)],
|
||||
order='sequence asc'
|
||||
)
|
||||
for p in production_process:
|
||||
logging.info('production_process:%s' % p.name)
|
||||
process_parameter = production_item.product_id.model_process_parameters_ids.filtered(
|
||||
lambda pm: pm.process_id.id == p.id)
|
||||
if process_parameter:
|
||||
i += 1
|
||||
route_production_process = self.env[
|
||||
'mrp.routing.workcenter'].search(
|
||||
[('surface_technics_id', '=', p.id),
|
||||
('id', 'in', route_workcenter_arr)])
|
||||
technology_design_values.append(
|
||||
self.env['sf.technology.design'].json_technology_design_str(False,
|
||||
route_production_process,
|
||||
i,
|
||||
process_parameter))
|
||||
productions.technology_design_ids = technology_design_values
|
||||
self.env['sf.technology.design'].json_technology_design_str(False, route, i, False))
|
||||
elif production_item.product_id.categ_id.type == '坯料':
|
||||
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
|
||||
[('embryo_model_type_id', '=', production_item.product_id.embryo_model_type_id.id)],
|
||||
order='sequence asc'
|
||||
)
|
||||
for route_embryo in embryo_routing_workcenter:
|
||||
i += 1
|
||||
technology_design_values.append(
|
||||
self.env['sf.technology.design'].json_technology_design_str(False, route_embryo, i,
|
||||
False))
|
||||
surface_technics_arr = []
|
||||
route_workcenter_arr = []
|
||||
for item in production_item.product_id.product_model_type_id.surface_technics_routing_tmpl_ids:
|
||||
if item.route_workcenter_id.surface_technics_id.id:
|
||||
for process_param in production_item.product_id.model_process_parameters_ids:
|
||||
if item.route_workcenter_id.surface_technics_id == process_param.process_id:
|
||||
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'].search(
|
||||
[('id', 'in', surface_technics_arr)],
|
||||
order='sequence asc'
|
||||
)
|
||||
for p in production_process:
|
||||
logging.info('production_process:%s' % p.name)
|
||||
process_parameter = production_item.product_id.model_process_parameters_ids.filtered(
|
||||
lambda pm: pm.process_id.id == p.id)
|
||||
if process_parameter:
|
||||
i += 1
|
||||
route_production_process = self.env[
|
||||
'mrp.routing.workcenter'].search(
|
||||
[('surface_technics_id', '=', p.id),
|
||||
('id', 'in', route_workcenter_arr)])
|
||||
technology_design_values.append(
|
||||
self.env['sf.technology.design'].json_technology_design_str(False,
|
||||
route_production_process,
|
||||
i,
|
||||
process_parameter))
|
||||
production_item.technology_design_ids = technology_design_values
|
||||
productions.write({'state': 'technology_to_confirmed'})
|
||||
return True
|
||||
|
||||
@@ -636,39 +635,24 @@ class StockPicking(models.Model):
|
||||
return '%s%s' % (rescode, num)
|
||||
|
||||
def button_validate(self):
|
||||
if self.picking_type_id.barcode == 'OCOUT':
|
||||
move_out = self.env['stock.move'].search(
|
||||
[('location_id', '=', self.env['stock.location'].search(
|
||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id),
|
||||
('location_dest_id', '=', self.env['stock.location'].search(
|
||||
[('barcode', 'ilike', 'VL-SPOC')]).id),
|
||||
('origin', '=', self.origin)])
|
||||
res = super().button_validate()
|
||||
if res is True and self.picking_type_id.sequence_code == 'OCOUT':
|
||||
# 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), ('picking_id', '=', self.id)])
|
||||
if self.location_id == move_in.location_id and self.location_dest_id == move_in.location_dest_id:
|
||||
if move_out.origin == move_in.origin:
|
||||
move_in.write({'production_id': False})
|
||||
if move_out.picking_id.state != 'done':
|
||||
raise UserError(
|
||||
_('该入库单对应的单号为%s的出库单还未完成,不能进行验证操作!' % move_out.picking_id.name))
|
||||
res = super().button_validate()
|
||||
if res is True and self.picking_type_id.barcode == 'OCIN':
|
||||
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.state != 'done':
|
||||
move_in.write({'state': 'assigned'})
|
||||
self.env['stock.move.line'].create(move_in.get_move_line(production, None))
|
||||
('origin', '=', self.origin), ('state', 'not in', ['cancel', 'done'])])
|
||||
production = self.env['mrp.production'].search([('name', '=', self.origin)])
|
||||
for mi in move_in:
|
||||
pick = self.env['stock.picking'].search([('id', '=', mi.picking_id.id), ('name', 'ilike', 'OCIN'),
|
||||
('partner_id', '=', self.partner_id.id)])
|
||||
if pick:
|
||||
if mi.state != 'done':
|
||||
mi.write({'state': 'assigned'})
|
||||
self.env['stock.move.line'].create(mi.get_move_line(production, None))
|
||||
|
||||
return res
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
||||
workorder.picking_ids.write({'state': 'cancel'})
|
||||
workorder.picking_ids.move_ids.write({'state': 'cancel'})
|
||||
purchase_order = self.env['purchase.order'].search(
|
||||
[('origin', '=', workorder.production_id.origin)])
|
||||
[('origin', '=', workorder.production_id.name)])
|
||||
for line in purchase_order.order_line:
|
||||
if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id:
|
||||
purchase_order.write({'state': 'cancel'})
|
||||
@@ -104,6 +104,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
||||
self.env['mrp.workorder'].json_workorder_str(special.production_id, special))
|
||||
special.production_id.write({'workorder_ids': workorders_values})
|
||||
else:
|
||||
logging.info(workorder.blocked_by_workorder_ids)
|
||||
if len(workorder.blocked_by_workorder_ids) > 1:
|
||||
if workorder.sequence == 1:
|
||||
workorder.blocked_by_workorder_ids = None
|
||||
|
||||
@@ -80,7 +80,7 @@ class ProductionTechnologyWizard(models.TransientModel):
|
||||
workorder.picking_ids.write({'state': 'cancel'})
|
||||
workorder.picking_ids.move_ids.write({'state': 'cancel'})
|
||||
purchase_order = self.env['purchase.order'].search(
|
||||
[('origin', '=', workorder.production_id.origin)])
|
||||
[('origin', '=', workorder.production_id.name)])
|
||||
for line in purchase_order.order_line:
|
||||
if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id:
|
||||
purchase_order.write({'state': 'cancel'})
|
||||
|
||||
@@ -265,17 +265,20 @@ class RePurchaseOrder(models.Model):
|
||||
}))
|
||||
for purchase in purchase_order:
|
||||
for po in purchase.order_line:
|
||||
if server_template.server_product_process_parameters_id == pp.surface_technics_parameters_id:
|
||||
if po.product_id == server_template.product_variant_id:
|
||||
continue
|
||||
if server_template.server_product_process_parameters_id != po.product_id.server_product_process_parameters_id:
|
||||
purchase_order_line = self.env['purchase.order.line'].search(
|
||||
[('product_id', '=', server_template.product_variant_id.id),
|
||||
('product_qty', '=', 1.0), ('id', '=', po.id)], limit=1,
|
||||
('product_qty', '=', 1.0), ('id', '=', purchase.id)], limit=1,
|
||||
order='id desc')
|
||||
if not purchase_order_line and purchase not in purchase_order:
|
||||
if not purchase_order_line:
|
||||
server_product_process.append((0, 0, {
|
||||
'product_id': server_template.product_variant_id.id,
|
||||
'product_qty': 1,
|
||||
'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,
|
||||
|
||||
Reference in New Issue
Block a user