优化制造订单报废
This commit is contained in:
@@ -275,19 +275,19 @@ class ResMrpWorkOrder(models.Model):
|
||||
production_programming = self.env['mrp.production'].search(domain, order='name asc')
|
||||
production_list = [production.name for production in production_programming]
|
||||
production_no_remanufacture = production_programming.filtered(lambda a: a.is_remanufacture is False)
|
||||
technology_design = self.env['sf.technology.design'].search(
|
||||
[('process_parameters_id', '=', order.surface_technics_parameters_id.id),
|
||||
('production_id', '=', order.production_id.id)])
|
||||
if technology_design.is_auto is False:
|
||||
domain = [('origin', '=', order.production_id.name)]
|
||||
else:
|
||||
domain = [('origin', '=', ','.join(production_list))]
|
||||
# technology_design = self.env['sf.technology.design'].search(
|
||||
# [('process_parameters_id', '=', order.surface_technics_parameters_id.id),
|
||||
# ('production_id', '=', order.production_id.id)])
|
||||
# if technology_design.is_auto is False:
|
||||
# domain = [('origin', '=', order.production_id.name)]
|
||||
# else:
|
||||
domain = [('purchase_type', '=', 'consignment'),('origin', '=', ','.join(production_list))]
|
||||
purchase = self.env['purchase.order'].search(domain)
|
||||
if not purchase:
|
||||
order.surface_technics_purchase_count = 0
|
||||
for line in purchase.order_line:
|
||||
if line.product_id.server_product_process_parameters_id == order.surface_technics_parameters_id:
|
||||
if (line.product_qty == len(production_no_remanufacture)) or technology_design.is_auto is False:
|
||||
if line.product_qty == len(production_no_remanufacture):
|
||||
order.surface_technics_purchase_count = len(purchase)
|
||||
else:
|
||||
order.surface_technics_purchase_count = 0
|
||||
@@ -301,13 +301,13 @@ class ResMrpWorkOrder(models.Model):
|
||||
domain = [('origin', '=', self.production_id.origin)]
|
||||
production_programming = self.env['mrp.production'].search(domain, order='name asc')
|
||||
production_list = [production.name for production in production_programming]
|
||||
technology_design = self.env['sf.technology.design'].search(
|
||||
[('process_parameters_id', '=', self.surface_technics_parameters_id.id),
|
||||
('production_id', '=', self.production_id.id)])
|
||||
if technology_design.is_auto is False:
|
||||
domain = [('origin', '=', self.production_id.name)]
|
||||
else:
|
||||
domain = [('origin', '=', ','.join(production_list))]
|
||||
# technology_design = self.env['sf.technology.design'].search(
|
||||
# [('process_parameters_id', '=', self.surface_technics_parameters_id.id),
|
||||
# ('production_id', '=', self.production_id.id)])
|
||||
# if technology_design.is_auto is False:
|
||||
# domain = [('origin', '=', self.production_id.name)]
|
||||
# else:
|
||||
domain = [('origin', '=', ','.join(production_list)), ('purchase_type', '=', 'consignment')]
|
||||
purchase_orders = self.env['purchase.order'].search(domain)
|
||||
result = {
|
||||
"type": "ir.actions.act_window",
|
||||
@@ -1011,7 +1011,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
return workorders_values_str
|
||||
|
||||
@api.depends('production_availability', 'blocked_by_workorder_ids', 'blocked_by_workorder_ids.state',
|
||||
'production_id.tool_state', 'production_id.schedule_state', 'sequence')
|
||||
'production_id.tool_state', 'production_id.schedule_state', 'sequence',
|
||||
'production_id.programming_state')
|
||||
def _compute_state(self):
|
||||
# super()._compute_state()
|
||||
for workorder in self:
|
||||
@@ -1077,7 +1078,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
# ================= 如果制造订单刀具状态为[无效刀、缺刀] 或者 制造订单状态为[返工]==========================
|
||||
if (workorder.production_id.tool_state in ['1', '2'] or workorder.production_id.state == 'rework'
|
||||
or workorder.production_id.schedule_state != '已排'
|
||||
or workorder.production_id.reservation_state != 'assigned'
|
||||
or len(
|
||||
workorder.production_id.picking_ids.filtered(lambda w: w.state not in ['done', 'cancel'])) != 0
|
||||
or workorder.production_id.workorder_ids.filtered(
|
||||
lambda wk: wk.sequence == workorder.sequence - 1).test_results in ['报废', '返工']):
|
||||
if workorder.state != 'waiting':
|
||||
|
||||
@@ -131,9 +131,9 @@ class StockRule(models.Model):
|
||||
if num > 1:
|
||||
for no in range(1, num + 1):
|
||||
Procurement = namedtuple('Procurement', ['product_id', 'product_qty',
|
||||
'product_uom', 'location_id', 'name', 'origin',
|
||||
'company_id',
|
||||
'values'])
|
||||
'product_uom', 'location_id', 'name', 'origin',
|
||||
'company_id',
|
||||
'values'])
|
||||
s = Procurement(product_id=item[0].product_id, product_qty=1.0, product_uom=item[0].product_uom,
|
||||
location_id=item[0].location_id,
|
||||
name=item[0].name,
|
||||
@@ -321,21 +321,26 @@ class StockRule(models.Model):
|
||||
i = 0
|
||||
if production_item.product_id.categ_id.type == '成品':
|
||||
# 根据加工面板的面数及成品工序模板生成工序设计
|
||||
for k in (production_item.product_id.model_processing_panel.split(',')):
|
||||
if production_item.production_type == '自动化产线加工':
|
||||
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
||||
[('product_model_type_id', '=', production_item.product_id.product_model_type_id.id)],
|
||||
order='sequence asc'
|
||||
)
|
||||
else:
|
||||
product_routing_workcenter = self.env['sf.manual.product.model.type.routing.sort'].search(
|
||||
[('manual_product_model_type_id', '=', production_item.product_id.product_model_type_id.id)],
|
||||
order='sequence asc'
|
||||
)
|
||||
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(',')):
|
||||
i += 1
|
||||
for route in product_routing_workcenter:
|
||||
technology_design_values.append(
|
||||
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(k, route, i, False))
|
||||
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)],
|
||||
@@ -376,7 +381,6 @@ class StockRule(models.Model):
|
||||
i,
|
||||
process_parameter))
|
||||
productions.technology_design_ids = technology_design_values
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -946,7 +950,7 @@ class ReStockMove(models.Model):
|
||||
move_lines_commands.append((0, 0, move_line_cmd))
|
||||
qty_by_location[loc.id] += 1
|
||||
return move_lines_commands
|
||||
|
||||
|
||||
def _merge_moves_fields(self):
|
||||
"""
|
||||
合并制造订单的完成move单据
|
||||
@@ -954,10 +958,11 @@ class ReStockMove(models.Model):
|
||||
res = super(ReStockMove, self)._merge_moves_fields()
|
||||
if self[0].origin and self.picking_type_id.name in ['生产发料', '内部调拨']:
|
||||
production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc')
|
||||
productions = self.env['mrp.production'].search([('origin', '=', production.origin), ('product_id', '=', production.product_id.id)])
|
||||
productions = self.env['mrp.production'].search(
|
||||
[('origin', '=', production.origin), ('product_id', '=', production.product_id.id)])
|
||||
res['origin'] = ','.join(productions.mapped('name'))
|
||||
return res
|
||||
|
||||
|
||||
def _get_new_picking_values(self):
|
||||
"""
|
||||
创建调拨单时,在此新增或修改调拨单的数据
|
||||
@@ -965,16 +970,16 @@ class ReStockMove(models.Model):
|
||||
res = super(ReStockMove, self)._get_new_picking_values()
|
||||
if self[0].origin and self.picking_type_id.name in ['生产发料', '内部调拨']:
|
||||
production = self.env['mrp.production'].search([('name', '=', self[0].origin)], limit=1, order='id asc')
|
||||
productions = self.env['mrp.production'].search([('origin', '=', production.origin), ('product_id', '=', production.product_id.id)])
|
||||
productions = self.env['mrp.production'].search(
|
||||
[('origin', '=', production.origin), ('product_id', '=', production.product_id.id)])
|
||||
res['origin'] = ','.join(productions.mapped('name'))
|
||||
res['retrospect_ref'] = production.product_id.name
|
||||
return res
|
||||
|
||||
|
||||
def _single_manufactuing_mo_generate_origin(self, res):
|
||||
"""
|
||||
单个制造订单的完成move单据修改来源为该制造订单关联的销售订单下所有成品相同的制造订单
|
||||
"""
|
||||
|
||||
|
||||
|
||||
class ReStockQuant(models.Model):
|
||||
|
||||
@@ -14,7 +14,8 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
||||
|
||||
def confirm(self):
|
||||
if self.is_technology_re_adjust is True:
|
||||
domain = [('origin', '=', self.origin), ('state', '=', 'technology_to_confirmed')]
|
||||
domain = [('origin', '=', self.origin), ('state', '=', 'technology_to_confirmed'),
|
||||
('product_id', '=', self.production_id.product_id.id)]
|
||||
else:
|
||||
domain = [('id', '=', self.production_id.id)]
|
||||
technology_designs = self.env['sf.technology.design'].sudo().search(
|
||||
@@ -112,9 +113,5 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
||||
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||
key=lambda a: a.sequence)
|
||||
if workorders[0].state in ['pending']:
|
||||
if workorder[0].production_id.product_id.categ_id.type == '成品':
|
||||
cnc_workorder = self.search(
|
||||
[('production_id', '=', item.id), ('routing_type', '=', 'CNC加工')],
|
||||
limit=1, order='id asc')
|
||||
if cnc_workorder.cnc_ids:
|
||||
workorders[0].state = 'waiting'
|
||||
if workorder[0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
||||
workorders[0].state = 'waiting'
|
||||
|
||||
@@ -15,7 +15,8 @@ class ProductionTechnologyWizard(models.TransientModel):
|
||||
|
||||
def confirm(self):
|
||||
if self.is_technology_confirm is True and self.production_id.product_id.categ_id.type == '成品':
|
||||
domain = [('origin', '=', self.origin), ('state', '=', 'technology_to_confirmed')]
|
||||
domain = [('origin', '=', self.origin), ('state', '=', 'technology_to_confirmed'),
|
||||
('product_id', '=', self.production_id.product_id.id)]
|
||||
else:
|
||||
domain = [('id', '=', self.production_id.id)]
|
||||
technology_designs = self.production_id.technology_design_ids
|
||||
@@ -63,9 +64,5 @@ class ProductionTechnologyWizard(models.TransientModel):
|
||||
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||
key=lambda a: a.sequence)
|
||||
if workorder[0].state in ['pending']:
|
||||
if workorder[0].production_id.product_id.categ_id.type == '成品':
|
||||
cnc_workorder = self.search(
|
||||
[('production_id', '=', item.id), ('routing_type', '=', 'CNC加工')],
|
||||
limit=1, order='id asc')
|
||||
if cnc_workorder.cnc_ids:
|
||||
workorder[0].state = 'waiting'
|
||||
if workorder[0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
|
||||
workorders[0].state = 'waiting'
|
||||
|
||||
@@ -50,6 +50,7 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
||||
return json.JSONEncoder().encode(res)
|
||||
for production in productions:
|
||||
production.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||
for panel in ret['processing_panel'].split(','):
|
||||
# 查询状态为进行中且工序类型为CNC加工的工单
|
||||
cnc_workorder_has = production.workorder_ids.filtered(
|
||||
@@ -104,7 +105,7 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
|
||||
return json.JSONEncoder().encode(res)
|
||||
else:
|
||||
res = {'status': 0, 'message': '该制造订单暂未开始'}
|
||||
res = {'status': 0, 'message': '没有查询到该制造订单'}
|
||||
return json.JSONEncoder().encode(res)
|
||||
except Exception as e:
|
||||
res = {'status': -1, 'message': '系统解析失败'}
|
||||
|
||||
Reference in New Issue
Block a user