优化制造订单报废向导
This commit is contained in:
@@ -918,7 +918,7 @@ class MrpProduction(models.Model):
|
|||||||
logging.info('get_new_program error:%s' % e)
|
logging.info('get_new_program error:%s' % e)
|
||||||
raise UserError("从云平台获取最新程序失败,请联系管理员")
|
raise UserError("从云平台获取最新程序失败,请联系管理员")
|
||||||
|
|
||||||
def recreateManufacturing(self):
|
def recreateManufacturing(self, item):
|
||||||
"""
|
"""
|
||||||
重新生成制造订单
|
重新生成制造订单
|
||||||
"""
|
"""
|
||||||
@@ -930,7 +930,7 @@ class MrpProduction(models.Model):
|
|||||||
values)
|
values)
|
||||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||||
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||||
productions._create_workorder()
|
productions._create_workorder(item)
|
||||||
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \
|
||||||
(
|
(
|
||||||
p.move_dest_ids.procure_method != 'make_to_order' and
|
p.move_dest_ids.procure_method != 'make_to_order' and
|
||||||
@@ -1023,6 +1023,7 @@ class MrpProduction(models.Model):
|
|||||||
'product_id': productions.product_id.id,
|
'product_id': productions.product_id.id,
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
})
|
})
|
||||||
|
return productions
|
||||||
|
|
||||||
# 在之前的销售单上重新生成制造订单
|
# 在之前的销售单上重新生成制造订单
|
||||||
def create_production1_values(self, production, sale_order):
|
def create_production1_values(self, production, sale_order):
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
<!-- <attribute name="statusbar_visible">draft,confirmed,progress,pending_processing,completed,done -->
|
<!-- <attribute name="statusbar_visible">draft,confirmed,progress,pending_processing,completed,done -->
|
||||||
<!-- </attribute> -->
|
<!-- </attribute> -->
|
||||||
<attribute name="statusbar_visible">
|
<attribute name="statusbar_visible">
|
||||||
confirmed,pending_cam,progress,rework,scrapdone
|
confirmed,pending_cam,progress,rework,scrap,done
|
||||||
</attribute>
|
</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//sheet//group//group[2]//label" position="before">
|
<xpath expr="//sheet//group//group[2]//label" position="before">
|
||||||
|
|||||||
@@ -202,7 +202,7 @@
|
|||||||
<xpath expr="//label[1]" position="before">
|
<xpath expr="//label[1]" position="before">
|
||||||
<field name='routing_type' readonly="1"/>
|
<field name='routing_type' readonly="1"/>
|
||||||
<field name='process_state' attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
<field name='process_state' attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
||||||
<field name="rfid_code" force_save="1" readonly="1" cache="True"
|
<field name="rfid_code" force_save="1" readonly="0" cache="True"
|
||||||
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
|
attrs="{'invisible': [('rfid_code_old', '!=', False)]}"/>
|
||||||
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
<field name="rfid_code_old" readonly="1" attrs="{'invisible': [('rfid_code_old', '=', False)]}"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|||||||
@@ -17,6 +17,63 @@ class ProductionWizard(models.TransientModel):
|
|||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.is_reprogramming is True:
|
if self.is_reprogramming is True:
|
||||||
self.production_id.update_programming_state()
|
self.production_id.update_programming_state()
|
||||||
|
if self.is_remanufacture is True:
|
||||||
|
ret = {'programming_list': []}
|
||||||
|
scrap_cnc = self.production_id.workorder_ids.filtered(lambda crw: crw.routing_type == 'CNC加工').cnc_ids
|
||||||
|
scrap_cmm = self.production_id.workorder_ids.filtered(lambda cm: cm.routing_type == 'CNC加工').cmm_ids
|
||||||
|
for item_line in scrap_cnc:
|
||||||
|
vals = {
|
||||||
|
'sequence_number': item_line.sequence_number,
|
||||||
|
'program_name': item_line.program_name,
|
||||||
|
'cutting_tool_name': item_line.cutting_tool_name,
|
||||||
|
'cutting_tool_no': item_line.cutting_tool_no,
|
||||||
|
'processing_type': item_line.processing_type,
|
||||||
|
'margin_x_y': item_line.margin_x_y,
|
||||||
|
'margin_z': item_line.margin_z,
|
||||||
|
'depth_of_processing_z': item_line.depth_of_processing_z,
|
||||||
|
'cutting_tool_extension_length': item_line.cutting_tool_extension_length,
|
||||||
|
'estimated_processing_time': item_line.estimated_processing_time,
|
||||||
|
'cutting_tool_handle_type': item_line.cutting_tool_handle_type,
|
||||||
|
'ftp_path': item_line.program_path,
|
||||||
|
'processing_panel': item_line.workorder_id.processing_panel,
|
||||||
|
'program_create_date': datetime.strftime(item_line.program_create_date,
|
||||||
|
'%Y-%m-%d %H:%M:%S'),
|
||||||
|
'remark': item_line.remark
|
||||||
|
}
|
||||||
|
ret['programming_list'].append(vals)
|
||||||
|
for cmm_line in scrap_cmm:
|
||||||
|
vals = {
|
||||||
|
'sequence_number': cmm_line.sequence_number,
|
||||||
|
'program_name': cmm_line.program_name,
|
||||||
|
'ftp_path': cmm_line.program_path,
|
||||||
|
'processing_panel': item_line.workorder_id.processing_panel,
|
||||||
|
'program_create_date': datetime.strftime(
|
||||||
|
cmm_line.program_create_date,
|
||||||
|
'%Y-%m-%d %H:%M:%S')
|
||||||
|
}
|
||||||
|
ret['programming_list'].append(vals)
|
||||||
|
new_production = self.production_id.recreateManufacturing(ret)
|
||||||
|
if self.is_reprogramming is False:
|
||||||
|
for panel in new_production.product_id.model_processing_panel:
|
||||||
|
scrap_cnc_workorder = max(
|
||||||
|
self.production_id.workorder_ids.filtered(
|
||||||
|
lambda
|
||||||
|
scn: scn.processing_panel == panel.name and scn.cnc_worksheet and scn.routing_type == 'CNC加工'),
|
||||||
|
key=lambda w: w.create_date)
|
||||||
|
scrap_pre_workorder = max(self.production_id.workorder_ids.filtered(
|
||||||
|
lambda
|
||||||
|
pr: pr.processing_panel == panel.name and pr.processing_drawing and pr.routing_type == '装夹预调'),
|
||||||
|
key=lambda w1: w1.create_date)
|
||||||
|
new_cnc_workorder = new_production.workorder_ids.filtered(
|
||||||
|
lambda
|
||||||
|
nc: nc.processing_panel == panel and nc.routing_type == 'CNC加工')
|
||||||
|
new_cnc_workorder.write({'cnc_worksheet': scrap_cnc_workorder.cnc_worksheet})
|
||||||
|
new_pre_workorder = new_production.workorder_ids.filtered(lambda
|
||||||
|
p: p.routing_type == '装夹预调' and p.processing_panel == panel)
|
||||||
|
new_pre_workorder.write({'processing_drawing': scrap_pre_workorder.processing_drawing})
|
||||||
|
|
||||||
|
|
||||||
|
if new_pre_workorder:
|
||||||
self.production_id.action_cancel()
|
self.production_id.action_cancel()
|
||||||
self.production_id.detection_result_ids.write({'handle_result': '已处理'})
|
self.production_id.detection_result_ids.write({'handle_result': '已处理'})
|
||||||
self.production_id.write({'state': 'cancel', 'scrap_ids': [(0, 0, {
|
self.production_id.write({'state': 'cancel', 'scrap_ids': [(0, 0, {
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
<field name="production_id" invisible="1"/>
|
<field name="production_id" invisible="1"/>
|
||||||
<div>
|
<div>
|
||||||
重新生成制造订单
|
重新生成制造订单
|
||||||
<field name="is_remanufacture"/>
|
<field name="is_remanufacture" force_save="1"/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div attrs='{"invisible": [("is_remanufacture","=",False)]}'>
|
||||||
申请重新编程
|
申请重新编程
|
||||||
<field name="is_reprogramming" attrs='{"invisible": [("is_remanufacture","=",False)]}'/>
|
<field name="is_reprogramming" force_save="1"/>
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
<footer>
|
||||||
<button string="确认" name="confirm" type="object" class="oe_highlight" confirm="是否确认报废"/>
|
<button string="确认" name="confirm" type="object" class="oe_highlight" confirm="是否确认报废"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user