+ attrs="{'invisible': [('surface_technics_purchase_count', '=', 0)]}">
diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py
index 746c953e..89ba95d0 100644
--- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py
+++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py
@@ -49,8 +49,8 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
if ro.route_id.routing_type == '表面工艺':
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
- display_name = ro.route_id.display_name
- domain += [('name', 'ilike', display_name)]
+ # display_name = ro.route_id.display_name
+ domain += [('id', '=', ro.id)]
elif ro.panel is not False:
domain += [('panel', '=', ro.panel)]
td_upd = self.env['sf.technology.design'].sudo().search(domain)
@@ -62,14 +62,23 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
for special in special_design:
workorders_values = []
if special.active is False:
+ is_cancel = False
# 工单采购单外协出入库单皆需取消
domain = [('production_id', '=', special.production_id.id)]
if special.process_parameters_id:
domain += [('surface_technics_parameters_id', '=', special.process_parameters_id.id)]
else:
- domain += [('name', '=', special.route_id.name)]
+ domain += [('technology_design_id', '=', special.id)]
workorder = self.env['mrp.workorder'].search(domain)
- if workorder.state != 'cancel':
+ previous_workorder = self.env['mrp.workorder'].search(
+ [('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
+ ('production_id', '=', workorder.production_id.id)])
+ if previous_workorder:
+ if previous_workorder.supplier_id != workorder.supplier_id:
+ is_cancel = True
+ else:
+ is_cancel = True
+ if workorder.state != 'cancel' and is_cancel is True:
workorder.write({'state': 'cancel'})
workorder.picking_ids.write({'state': 'cancel'})
workorder.picking_ids.move_ids.write({'state': 'cancel'})
@@ -79,12 +88,8 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id:
purchase_order.write({'state': 'cancel'})
else:
- if special.route_id.routing_type == '表面工艺':
- display_name = special.process_parameters_id.display_name
- else:
- display_name = special.route_id.display_name
workorder = self.env['mrp.workorder'].search(
- [('name', '=', display_name), ('production_id', '=', special.production_id.id)])
+ [('technology_design_id', '=', special.id), ('production_id', '=', special.production_id.id)])
if not workorder:
if special.route_id.routing_type == '表面工艺':
product_production_process = self.env['product.template'].search(
@@ -103,7 +108,8 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel):
if workorder.sequence == 1:
workorder.blocked_by_workorder_ids = None
else:
- workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
+ if workorder.blocked_by_workorder_ids:
+ workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
productions._reset_work_order_sequence()
if self.production_id.product_id.categ_id.type == '成品':
productions._reset_subcontract_pick_purchase()
@@ -113,5 +119,6 @@ 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 == '成品' and item.programming_state != '已编程':
+ if workorders[
+ 0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
workorders[0].state = 'waiting'
diff --git a/sf_manufacturing/wizard/production_technology_wizard.py b/sf_manufacturing/wizard/production_technology_wizard.py
index 04f8f12a..d81a89a0 100644
--- a/sf_manufacturing/wizard/production_technology_wizard.py
+++ b/sf_manufacturing/wizard/production_technology_wizard.py
@@ -46,16 +46,68 @@ class ProductionTechnologyWizard(models.TransientModel):
if ro.route_id.routing_type == '表面工艺':
domain += [('process_parameters_id', '=', ro.process_parameters_id.id)]
elif ro.route_id.routing_tag == 'special' and ro.is_auto is False:
- display_name = ro.route_id.display_name
- domain += [('name', 'ilike', display_name)]
+ # display_name = ro.route_id.display_name
+ domain += [('id', '=', ro.id)]
elif ro.panel is not False:
domain += [('panel', '=', ro.panel)]
td_upd = self.env['sf.technology.design'].sudo().search(domain)
if td_upd:
ro.write({'sequence': td_upd.sequence, 'active': td_upd.active})
- # special = production.technology_design_ids.filtered(
- # lambda td: td.is_auto is False and td.process_parameters_id is not False)
- # # if special:
+ special_design = self.env['sf.technology.design'].sudo().search(
+ [('routing_tag', '=', 'special'), ('production_id', '=', production.id),
+ ('is_auto', '=', False), ('active', 'in', [True, False])])
+ for special in special_design:
+ workorders_values = []
+ if special.active is False:
+ is_cancel = False
+ # 工单采购单外协出入库单皆需取消
+ domain = [('production_id', '=', special.production_id.id)]
+ if special.process_parameters_id:
+ domain += [('surface_technics_parameters_id', '=', special.process_parameters_id.id)]
+ else:
+ domain += [('technology_design_id', '=', special.id)]
+ workorder = self.env['mrp.workorder'].search(domain)
+ previous_workorder = self.env['mrp.workorder'].search(
+ [('sequence', '=', workorder.sequence - 1), ('routing_type', '=', '表面工艺'),
+ ('production_id', '=', workorder.production_id.id)])
+ if previous_workorder:
+ if previous_workorder.supplier_id != workorder.supplier_id:
+ is_cancel = True
+ else:
+ is_cancel = True
+ if workorder.state != 'cancel' and is_cancel is True:
+ workorder.write({'state': 'cancel'})
+ 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)])
+ 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'})
+ else:
+ if special.production_id.workorder_ids:
+ workorder = self.env['mrp.workorder'].search(
+ [('technology_design_id', '=', special.id), ('production_id', '=', special.production_id.id)])
+ if not workorder:
+ if special.route_id.routing_type == '表面工艺':
+ product_production_process = self.env['product.template'].search(
+ [('server_product_process_parameters_id', '=', special.process_parameters_id.id)])
+ workorders_values.append(
+ self.env[
+ 'mrp.workorder']._json_workorder_surface_process_str(special.production_id, special,
+ product_production_process.seller_ids[
+ 0].partner_id.id))
+ else:
+ workorders_values.append(
+ self.env['mrp.workorder'].json_workorder_str(special.production_id, special))
+ special.production_id.write({'workorder_ids': workorders_values})
+ else:
+ if len(workorder.blocked_by_workorder_ids) > 1:
+ if workorder.sequence == 1:
+ workorder.blocked_by_workorder_ids = None
+ else:
+ if workorder.blocked_by_workorder_ids:
+ workorder.blocked_by_workorder_ids = blocked_by_workorder_ids[0]
productions._create_workorder(False)
if self.production_id.product_id.categ_id.type == '成品':
productions.get_subcontract_pick_purchase()
@@ -65,4 +117,4 @@ class ProductionTechnologyWizard(models.TransientModel):
key=lambda a: a.sequence)
if workorder[0].state in ['pending']:
if workorder[0].production_id.product_id.categ_id.type == '成品' and item.programming_state != '已编程':
- workorders[0].state = 'waiting'
+ workorder[0].state = 'waiting'
diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py
index 8a73ec57..bb787c11 100644
--- a/sf_manufacturing/wizard/rework_wizard.py
+++ b/sf_manufacturing/wizard/rework_wizard.py
@@ -15,8 +15,7 @@ class ReworkWizard(models.TransientModel):
production_id = fields.Many2one('mrp.production', string='制造订单号')
workorder_ids = fields.Many2many('mrp.workorder', 'rework_wizard_to_work_order', string='所有工单',
domain="[('production_id', '=', production_id),('state','=','done')]")
- hidden_workorder_ids = fields.Many2many('mrp.workorder', 'rework_wizard_to_work_order_hidden',
- string='所有工单(hidden)')
+ hidden_workorder_ids = fields.Char('')
rework_reason = fields.Selection(
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"),
("operate computer", "操机"),
@@ -52,9 +51,26 @@ class ReworkWizard(models.TransientModel):
'test_report': self.workorder_id.detection_report})]})
self.workorder_id.button_finish()
else:
- if self.workorder_ids:
- rework_workorder_ids = self.production_id.workorder_ids.filtered(
- lambda ap: ap.id in self.workorder_ids.ids)
+ if self.hidden_workorder_ids:
+ hidden_workorder_list = self.hidden_workorder_ids.split(',')
+ rework_workorder_ids = self.workorder_ids.filtered(lambda w: str(w.id) in hidden_workorder_list)
+ # 限制判断
+ # 1、当制造订单内ZM面的工单都已完成时,返工勾选工序时只能勾选上ZM面的所有工序进行返工
+ # 2、当FM工单在CNC工单进行选择返工,并将已全部完成的ZM面工序全部勾选上时,FM工单上所有的已完成的工单(装夹预调工单)也必须进行勾选
+ # 获取已完成的标准工单
+ done_normative_workorder_ids = self.workorder_ids.filtered(
+ lambda w: w.state == 'done' and w.processing_panel is not False)
+ # 获取需要返工的标准工单
+ rework_normative_workorder_ids = rework_workorder_ids.filtered(
+ lambda w: w.processing_panel is not False)
+ if rework_normative_workorder_ids:
+ for rw in rework_normative_workorder_ids:
+ if len(done_normative_workorder_ids.filtered(
+ lambda w: w.processing_panel == rw.processing_panel)) == 3:
+ pass
+ else:
+ raise ValidationError('请选择返工工单!!!')
+ if rework_workorder_ids:
clamp_workorder_ids = None
if rework_workorder_ids:
# 限制
diff --git a/sf_manufacturing/wizard/rework_wizard_views.xml b/sf_manufacturing/wizard/rework_wizard_views.xml
index 4482fda7..05d1cc04 100644
--- a/sf_manufacturing/wizard/rework_wizard_views.xml
+++ b/sf_manufacturing/wizard/rework_wizard_views.xml
@@ -12,10 +12,15 @@
-
+
-
+
+
+
diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py
index ac79ff8b..87aee0dd 100644
--- a/sf_mrs_connect/controllers/controllers.py
+++ b/sf_mrs_connect/controllers/controllers.py
@@ -32,6 +32,12 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
domain += [('state', 'in', ['confirmed', 'pending_cam'])]
productions = request.env['mrp.production'].with_user(
request.env.ref("base.user_admin")).search(domain)
+ productions_technology_to_confirmed = request.env['mrp.production'].with_user(
+ request.env.ref("base.user_admin")).search(
+ [('programming_no', '=', ret['programming_no']), ('state', 'in', ['technology_to_confirmed'])])
+ if productions_technology_to_confirmed:
+ res = {'status': -2, 'message': '查询到待工艺确认的制造订单'}
+ return json.JSONEncoder().encode(res)
if productions:
# 拉取所有加工面的程序文件
for r in ret['processing_panel'].split(','):
diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py
index f0214c9a..e7785ad4 100644
--- a/sf_plan/models/custom_plan.py
+++ b/sf_plan/models/custom_plan.py
@@ -231,26 +231,42 @@ class sf_production_plan(models.Model):
if not record.production_line_id:
raise ValidationError("未选择生产线")
else:
- if record.production_id.workorder_ids:
- last_cnc_start = record.date_planned_start if record.date_planned_start else datetime.now()
- for item in record.production_id.workorder_ids:
- if item.name == 'CNC加工':
- # 将同一个面的所有工单筛选出来
- workorder_list = record.production_id.workorder_ids.filtered(lambda x: x.processing_panel == item.processing_panel)
- routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search(
- [('name', '=', 'CNC加工')], limit=1)
- # 设置一个小的开始时间
- item.date_planned_start = datetime.now() - timedelta(days=100)
- item.date_planned_finished = last_cnc_start + timedelta(
- minutes=routing_workcenter.time_cycle)
- item.date_planned_start = last_cnc_start
- record.sudo().production_id.plan_start_processing_time = item.date_planned_start
- item.duration_expected = routing_workcenter.time_cycle
- pre_duration , next_duration = record.calculate_plan_time(item, workorder_list)
- record.date_planned_finished = item.date_planned_finished
- # 计算下一个cnc工单的开始时间
- last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration)
- # 没有工单也能排程
+ # 自动化产线加工
+ if record.production_id.production_type == '自动化产线加工':
+ if record.production_id.workorder_ids:
+ last_cnc_start = record.date_planned_start if record.date_planned_start else datetime.now()
+ for item in record.production_id.workorder_ids:
+ if item.name == 'CNC加工':
+ # 将同一个面的所有工单筛选出来
+ workorder_list = record.production_id.workorder_ids.filtered(lambda x: x.processing_panel == item.processing_panel)
+ routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search(
+ [('name', '=', 'CNC加工')], limit=1)
+ # 设置一个小的开始时间
+ item.date_planned_start = datetime.now() - timedelta(days=100)
+ item.date_planned_finished = last_cnc_start + timedelta(
+ minutes=routing_workcenter.time_cycle)
+ item.date_planned_start = last_cnc_start
+ record.sudo().production_id.plan_start_processing_time = item.date_planned_start
+ item.duration_expected = routing_workcenter.time_cycle
+ pre_duration , next_duration = record.calculate_plan_time(item, workorder_list)
+ record.date_planned_finished = item.date_planned_finished
+ # 计算下一个cnc工单的开始时间
+ last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration)
+ # 没有工单也能排程
+ else:
+ # 人工线下加工只排第一张工单
+ if record.production_id.workorder_ids:
+ item = record.production_id.workorder_ids[0]
+ last_wo_start = record.date_planned_start if record.date_planned_start else datetime.now()
+ routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search(
+ [('name', '=', item.routing_type)], limit=1)
+ item.date_planned_start = datetime.now() - timedelta(days=100)
+ item.date_planned_finished = last_wo_start + timedelta(
+ minutes=routing_workcenter.time_cycle)
+ item.date_planned_start = last_wo_start
+ record.sudo().production_id.plan_start_processing_time = item.date_planned_start
+ item.duration_expected = routing_workcenter.time_cycle
+ record.calculate_plan_time(item, item)
record.state = 'done'
# record.production_id.schedule_state = '已排'
record.sudo().production_id.schedule_state = '已排'
diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py
index a73b0a35..9c0e0b09 100644
--- a/sf_sale/models/sale_order.py
+++ b/sf_sale/models/sale_order.py
@@ -250,35 +250,36 @@ class RePurchaseOrder(models.Model):
server_product_process = []
production_process = product_id_to_production_names.get(
production.product_id.id)
+ purchase_order = self.env['purchase.order'].search(
+ [('state', '=', 'draft'), ('origin', '=', production.name),
+ ('purchase_type', '=', 'consignment')], order='name asc')
for pp in consecutive_process_parameters:
server_template = self.env['product.template'].search(
[('server_product_process_parameters_id', '=', pp.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),
- ('product_qty', '=', len(production_process))], limit=1, order='id desc')
- if not purchase_order_line:
+ if not purchase_order:
server_product_process.append((0, 0, {
'product_id': server_template.product_variant_id.id,
- 'product_qty': len(production_process),
+ 'product_qty': 1,
'product_uom': server_template.uom_id.id
}))
- else:
- if production.name in production_process:
- purchase_order = self.env['purchase.order'].search(
- [('state', '=', 'draft'), ('origin', '=', ','.join(production_process)),
- ('purchase_type', '=', 'consignment')])
- if not purchase_order:
- server_product_process.append((0, 0, {
- 'product_id': server_template.product_variant_id.id,
- 'product_qty': len(production_process),
- 'product_uom': server_template.uom_id.id
- }))
-
+ for purchase in purchase_order:
+ for po in purchase.order_line:
+ if server_template.server_product_process_parameters_id == pp.surface_technics_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,
+ order='id desc')
+ if not purchase_order_line and purchase not in purchase_order:
+ 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,
- 'origin': ','.join(production_process),
+ 'origin': production.name,
'state': 'draft',
'purchase_type': 'consignment',
'order_line': server_product_process})
diff --git a/sf_tool_management/models/mrp_workorder.py b/sf_tool_management/models/mrp_workorder.py
index 8fe9748e..25ccc460 100644
--- a/sf_tool_management/models/mrp_workorder.py
+++ b/sf_tool_management/models/mrp_workorder.py
@@ -221,5 +221,6 @@ class MrpProduction(models.Model):
logging.info('调用CAM工单程序用刀计划创建方法!!!')
self.env['sf.cam.work.order.program.knife.plan'].sudo().create_cam_work_plan(cnc_ids)
if not invalid_tool and not missing_tool_1:
+ self.sudo().write({'tool_state': '0'})
logging.info('校验cnc用刀正常!!!')
logging.info('工单cnc程序用刀校验完成!!!')