Accept Merge Request #1540: (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/1540
This commit is contained in:
@@ -1260,7 +1260,6 @@ class MrpProduction(models.Model):
|
||||
重新生成制造订单
|
||||
"""
|
||||
if self.is_scrap is True:
|
||||
technology_design_values = []
|
||||
procurement_requests = []
|
||||
sale_order = self.env['sale.order'].sudo().search([('name', '=', self.origin)])
|
||||
values = self.env['mrp.production'].create_production1_values(self)
|
||||
@@ -1352,69 +1351,6 @@ class MrpProduction(models.Model):
|
||||
productions.programming_state = '已编程'
|
||||
else:
|
||||
productions.programming_state = '编程中'
|
||||
if not technology_design_values:
|
||||
i = 0
|
||||
if self.product_id.categ_id.type == '成品':
|
||||
# 根据加工面板的面数及成品工序模板生成工序设计
|
||||
for k in (self.product_id.model_processing_panel.split(',')):
|
||||
if self.production_type == '自动化产线加工':
|
||||
product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
|
||||
[('product_model_type_id', '=',
|
||||
self.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', '=',
|
||||
self.product_id.product_model_type_id.id)],
|
||||
order='sequence asc'
|
||||
)
|
||||
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))
|
||||
elif self.product_id.categ_id.type == '坯料':
|
||||
i = 0
|
||||
embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
|
||||
[('embryo_model_type_id', '=', self.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 self.product_id.product_model_type_id.surface_technics_routing_tmpl_ids:
|
||||
if item.route_workcenter_id.surface_technics_id.id:
|
||||
for process_param in self.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 = self.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
|
||||
return productions
|
||||
|
||||
# 在之前的销售单上重新生成制造订单
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -321,24 +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)],
|
||||
@@ -379,7 +381,6 @@ class StockRule(models.Model):
|
||||
i,
|
||||
process_parameter))
|
||||
productions.technology_design_ids = technology_design_values
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -251,7 +251,7 @@
|
||||
decoration-danger="tag_type == '重新加工'"/>
|
||||
<field name="is_test_env" invisible="1"/>
|
||||
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
||||
attrs="{'invisible': [('rfid_code_old', '!=', False)]}" widget='qrcode_widget' />
|
||||
attrs="{'invisible': [('rfid_code_old', '!=', False)]}" />
|
||||
<field name="rfid_code" string="RFID码(手动输入框)" force_save="1" readonly="0" cache="True"
|
||||
attrs="{'invisible': ['|',('rfid_code_old', '!=', False), ('is_test_env', '=', False)]}"/>
|
||||
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
||||
|
||||
@@ -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