修复bug和优化制造订单报废
This commit is contained in:
@@ -311,10 +311,7 @@ class MrpProduction(models.Model):
|
|||||||
# 新添加的状态逻辑
|
# 新添加的状态逻辑
|
||||||
if (
|
if (
|
||||||
production.state == 'to_close' or production.state == 'progress') and production.schedule_state == '未排':
|
production.state == 'to_close' or production.state == 'progress') and production.schedule_state == '未排':
|
||||||
if not production.workorder_ids:
|
if not production.workorder_ids or production.is_adjust is True:
|
||||||
production.state = 'technology_to_confirmed'
|
|
||||||
else:
|
|
||||||
if production.is_adjust == True:
|
|
||||||
production.state = 'technology_to_confirmed'
|
production.state = 'technology_to_confirmed'
|
||||||
else:
|
else:
|
||||||
production.state = 'confirmed'
|
production.state = 'confirmed'
|
||||||
@@ -683,6 +680,8 @@ class MrpProduction(models.Model):
|
|||||||
if production.product_id.categ_id.type == '成品':
|
if production.product_id.categ_id.type == '成品':
|
||||||
# # 根据工序设计生成工单
|
# # 根据工序设计生成工单
|
||||||
for route in production.technology_design_ids:
|
for route in production.technology_design_ids:
|
||||||
|
workorder_has = self.env['mrp.workorder'].search([('name', '=', route.route_id.name)])
|
||||||
|
if not workorder_has:
|
||||||
if route.route_id.routing_type not in ['表面工艺']:
|
if route.route_id.routing_type not in ['表面工艺']:
|
||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str(production, route))
|
self.env['mrp.workorder'].json_workorder_str(production, route))
|
||||||
@@ -699,6 +698,8 @@ class MrpProduction(models.Model):
|
|||||||
order='sequence asc'
|
order='sequence asc'
|
||||||
)
|
)
|
||||||
for route_embryo in embryo_routing_workcenter:
|
for route_embryo in embryo_routing_workcenter:
|
||||||
|
workorder_embryo_has = self.env['mrp.workorder'].search([('name', '=', route.route_id.name)])
|
||||||
|
if not workorder_embryo_has:
|
||||||
workorders_values.append(
|
workorders_values.append(
|
||||||
self.env['mrp.workorder'].json_workorder_str('', production, route_embryo))
|
self.env['mrp.workorder'].json_workorder_str('', production, route_embryo))
|
||||||
production.workorder_ids = workorders_values
|
production.workorder_ids = workorders_values
|
||||||
|
|||||||
@@ -782,7 +782,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
routing_types = ['切割', '装夹预调', 'CNC加工', '解除装夹']
|
routing_types = ['切割', '装夹预调', 'CNC加工', '解除装夹']
|
||||||
if route.route_id.routing_type in routing_types:
|
if route.route_id.routing_type in routing_types:
|
||||||
routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search(
|
routing_workcenter = self.env['mrp.routing.workcenter'].sudo().search(
|
||||||
[('name', '=', route.route_id.routing_type)])
|
[('name', '=', oute.routing_type if hasattr(route, 'routing_type') else route.route_id.routing_type)])
|
||||||
duration_expected = routing_workcenter.time_cycle
|
duration_expected = routing_workcenter.time_cycle
|
||||||
reserved_duration = routing_workcenter.reserved_duration
|
reserved_duration = routing_workcenter.reserved_duration
|
||||||
else:
|
else:
|
||||||
@@ -792,12 +792,13 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'product_uom_id': production.product_uom_id.id,
|
'product_uom_id': production.product_uom_id.id,
|
||||||
'qty_producing': 0,
|
'qty_producing': 0,
|
||||||
'operation_id': False,
|
'operation_id': False,
|
||||||
'name': route.route_id.name,
|
'name': route.name if hasattr(route, 'routing_type') else route.route_id.name,
|
||||||
'processing_panel': route.panel,
|
'processing_panel': False if hasattr(route, 'routing_type') else route.panel,
|
||||||
'sequence': route.sequence,
|
'sequence': 1 if hasattr(route, 'routing_type') else route.sequence,
|
||||||
'quality_point_ids': route.route_id.quality_point_ids,
|
'quality_point_ids': False if hasattr(route, 'routing_type') else route.route_id.quality_point_ids,
|
||||||
'routing_type': route.route_id.routing_type,
|
'routing_type': route.routing_type if hasattr(route, 'routing_type') else route.route_id.routing_type,
|
||||||
'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.route_id.workcenter_ids.ids,
|
'workcenter_id': False if hasattr(route, 'routing_type') else self.env[
|
||||||
|
'mrp.routing.workcenter'].get_workcenter(route.route_id.workcenter_ids.ids,
|
||||||
route.route_id.routing_type,
|
route.route_id.routing_type,
|
||||||
production.product_id),
|
production.product_id),
|
||||||
# 设定初始化值,避免出现变成bool问题
|
# 设定初始化值,避免出现变成bool问题
|
||||||
|
|||||||
@@ -84,6 +84,12 @@
|
|||||||
technology_to_confirmed,confirmed,pending_cam,progress,rework,scrap,done
|
technology_to_confirmed,confirmed,pending_cam,progress,rework,scrap,done
|
||||||
</attribute>
|
</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="//div[@class='d-flex flex-row align-items-start']//span[1]" position="attributes">
|
||||||
|
<attribute name="invisible">1</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//button[@name='action_product_forecast_report']" position="attributes">
|
||||||
|
<attribute name="invisible">1</attribute>
|
||||||
|
</xpath>
|
||||||
<xpath expr="//sheet//group//group[2]//label" position="before">
|
<xpath expr="//sheet//group//group[2]//label" position="before">
|
||||||
<!-- <field name="process_state"/> -->
|
<!-- <field name="process_state"/> -->
|
||||||
<field name="state" readonly="1"/>
|
<field name="state" readonly="1"/>
|
||||||
@@ -139,7 +145,7 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="(//header//button[@name='button_scrap'])" position="replace">
|
<xpath expr="(//header//button[@name='button_scrap'])" position="replace">
|
||||||
<button name="technology_confirm" string="工艺确认" type="object" class="oe_highlight"
|
<button name="technology_confirm" string="工艺确认" type="object" class="oe_highlight"
|
||||||
attrs="{'invisible': [('workorder_ids', '!=', [])]}"></button>
|
attrs="{'invisible': [('state', '!=', 'technology_to_confirmed')]}"></button>
|
||||||
<button name="technology_back_adjust" string="退回调整" type="object" class="oe_highlight"
|
<button name="technology_back_adjust" string="退回调整" type="object" class="oe_highlight"
|
||||||
attrs="{'invisible': [('state', '!=', 'confirmed')]}"></button>
|
attrs="{'invisible': [('state', '!=', 'confirmed')]}"></button>
|
||||||
<button name="button_scrap" invisible="1"/>
|
<button name="button_scrap" invisible="1"/>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.is_technology_re_adjust is True:
|
if self.is_technology_re_adjust is True:
|
||||||
domain = [('origin', '=', self.origin), ('state', '=', 'confirmed')]
|
domain = [('origin', '=', self.origin), ('state', '=', 'technology_to_confirmed')]
|
||||||
else:
|
else:
|
||||||
domain = [('id', '=', self.production_id.id)]
|
domain = [('id', '=', self.production_id.id)]
|
||||||
technology_designs = self.env['sf.technology.design'].sudo().search(
|
technology_designs = self.env['sf.technology.design'].sudo().search(
|
||||||
@@ -42,7 +42,8 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
'is_auto': td_main.is_auto})]})
|
'is_auto': td_main.is_auto})]})
|
||||||
else:
|
else:
|
||||||
for ro in route_other:
|
for ro in route_other:
|
||||||
domain = [('production_id', '=', self.production_id.id), ('active', 'in', [True, False]),
|
domain = [('production_id', '=', self.production_id.id),
|
||||||
|
('active', 'in', [True, False]),
|
||||||
('route_id', '=', ro.route_id.id)]
|
('route_id', '=', ro.route_id.id)]
|
||||||
if ro.route_id.routing_type == '表面工艺':
|
if ro.route_id.routing_type == '表面工艺':
|
||||||
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
|
||||||
@@ -109,4 +110,9 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
|
|||||||
for item in productions:
|
for item in productions:
|
||||||
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
workorders = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||||
key=lambda a: a.sequence)
|
key=lambda a: a.sequence)
|
||||||
|
if workorders[0].state in ['pending']:
|
||||||
|
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'
|
workorders[0].state = 'waiting'
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class ProductionTechnologyWizard(models.TransientModel):
|
|||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.is_technology_confirm is True:
|
if self.is_technology_confirm is True:
|
||||||
domain = [('origin', '=', self.origin)]
|
domain = [('origin', '=', self.origin), ('state', '=', 'technology_to_confirmed')]
|
||||||
else:
|
else:
|
||||||
domain = [('id', '=', self.production_id.id)]
|
domain = [('id', '=', self.production_id.id)]
|
||||||
technology_designs = self.production_id.technology_design_ids
|
technology_designs = self.production_id.technology_design_ids
|
||||||
@@ -62,4 +62,8 @@ class ProductionTechnologyWizard(models.TransientModel):
|
|||||||
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
workorder = item.workorder_ids.filtered(lambda wo: wo.state not in ('cancel')).sorted(
|
||||||
key=lambda a: a.sequence)
|
key=lambda a: a.sequence)
|
||||||
if workorder[0].state in ['pending']:
|
if workorder[0].state in ['pending']:
|
||||||
|
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'
|
workorder[0].state = 'waiting'
|
||||||
|
|||||||
@@ -46,58 +46,5 @@ class ProductionWizard(models.TransientModel):
|
|||||||
ret = {'programming_list': [], 'is_reprogramming': self.is_reprogramming}
|
ret = {'programming_list': [], 'is_reprogramming': self.is_reprogramming}
|
||||||
if self.is_reprogramming is True:
|
if self.is_reprogramming is True:
|
||||||
self.production_id.update_programming_state()
|
self.production_id.update_programming_state()
|
||||||
else:
|
|
||||||
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)
|
new_production = self.production_id.recreateManufacturing(ret)
|
||||||
self.production_id.write({'remanufacture_production_id': new_production.id})
|
self.production_id.write({'remanufacture_production_id': new_production.id})
|
||||||
if self.is_reprogramming is False:
|
|
||||||
for panel in new_production.product_id.model_processing_panel.split(','):
|
|
||||||
scrap_cnc_workorder = max(
|
|
||||||
self.production_id.workorder_ids.filtered(
|
|
||||||
lambda
|
|
||||||
scn: scn.processing_panel == panel 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 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})
|
|
||||||
|
|||||||
Reference in New Issue
Block a user