diff --git a/sf_base/models/common.py b/sf_base/models/common.py
index 257eb2d4..63b269ec 100644
--- a/sf_base/models/common.py
+++ b/sf_base/models/common.py
@@ -158,6 +158,8 @@ class MrsProductionProcessParameter(models.Model):
for parameter in self:
if parameter.process_id:
name = parameter.process_id.name + '-' + parameter.name
+ else:
+ name = parameter.name
result.append((parameter.id, name))
return result
diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py
index a5ff9eb7..ab78eaab 100644
--- a/sf_manufacturing/models/mrp_production.py
+++ b/sf_manufacturing/models/mrp_production.py
@@ -218,17 +218,17 @@ class MrpProduction(models.Model):
precision_rounding=move.product_uom.rounding or move.product_id.uom_id.rounding)
for move in production.move_raw_ids if move.product_id):
production.state = 'progress'
- elif not production.technology_design_ids:
- production.state = 'technology_to_confirmed'
# 新添加的状态逻辑
if (
production.state == 'to_close' or production.state == 'progress') and production.schedule_state == '未排':
- production.state = 'confirmed'
+ if not production.workorder_ids:
+ production.state = 'technology_to_confirmed'
+ else:
+ production.state = 'confirmed'
elif production.state == 'pending_cam' and production.schedule_state == '未排':
production.state = 'confirmed'
elif production.state == 'to_close' and production.schedule_state == '已排':
production.state = 'pending_cam'
-
if production.state == 'progress':
if all(wo_state not in ('progress', 'done', 'rework', 'scrap') for wo_state in
production.workorder_ids.mapped('state')):
@@ -259,11 +259,11 @@ class MrpProduction(models.Model):
def technology_back_adjust(self):
special_design = self.technology_design_ids.filtered(
- lambda a: a.routing_tag == 'special' and a.is_auto is False and a.active in [True,False])
+ lambda a: a.routing_tag == 'special' and a.is_auto is False and a.active in [True, False])
workorders_values = []
for item in special_design:
if item.active is False:
- domain = [('production_id','=',self.id)]
+ domain = [('production_id', '=', self.id)]
if item.surface_technics_parameters_id:
domain += [('surface_technics_parameters_id', '=', item.process_parameters_id)]
else:
@@ -274,15 +274,21 @@ class MrpProduction(models.Model):
else:
workorder = self.env['mrp.workorder'].search([('name', '=', item.route_id.name)])
if not workorder:
- workorders_values.append(
- self.env[
- 'mrp.workorder']._json_workorder_surface_process_str(
- production, route, product_production_process.seller_ids[0].partner_id.id))
- if workorders_values:
- self.workorders.write({})
-
-
+ if item.route_id.routing_type == '表面工艺':
+ product_production_process = self.env['product.template'].search(
+ [('server_product_process_parameters_id', '=', item.process_parameters_id.id)])
+ workorders_values.append(
+ self.env[
+ 'mrp.workorder']._json_workorder_surface_process_str(self, item,
+ product_production_process.seller_ids[
+ 0].partner_id.id))
+ else:
+ workorders_values.append(
+ self.env['mrp.workorder'].json_workorder_str(self, item))
+ if workorders_values:
+ self.write({'workorder_ids': workorders_values})
+ self._reset_work_order_sequence()
# 工艺确认
def technology_confirm(self):
@@ -1267,7 +1273,7 @@ class MrpProduction(models.Model):
'move_dest_ids': production.move_dest_ids.ids,
'user_id': production.user_id.id}
return production_values_str
-
+
# 增加制造订单类型
production_type = fields.Selection(
[('自动化产线加工', '自动化产线加工'), ('人工线下加工', '人工线下加工')],
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py
index 11232595..5c70712b 100644
--- a/sf_manufacturing/models/mrp_workorder.py
+++ b/sf_manufacturing/models/mrp_workorder.py
@@ -325,7 +325,8 @@ class ResMrpWorkOrder(models.Model):
@api.constrains('blocked_by_workorder_ids')
def _check_no_cyclic_dependencies(self):
- if self.production_id.state not in ['rework'] and self.state not in ['rework']:
+ if self.production_id.state not in ['rework', 'technology_to_confirmed', 'pending_cam'] and self.state not in [
+ 'rework']:
if not self._check_m2m_recursion('blocked_by_workorder_ids'):
raise ValidationError(_("您不能创建周期性的依赖关系."))
diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py
index a0787477..ff70a9d9 100644
--- a/sf_manufacturing/models/stock.py
+++ b/sf_manufacturing/models/stock.py
@@ -360,7 +360,12 @@ class StockRule(models.Model):
# 根据加工面板的面数及成品工序模板生成工序设计
i = 0
for k in (production.product_id.model_processing_panel.split(',')):
- product_routing_workcenter = self.env['sf.product.model.type.routing.sort'].search(
+ # 新增的成品工序模版暂未添加,后续添加
+ if production.production_type == '自动化产线加工':
+ model = 'sf.product.model.type.routing.sort'
+ else:
+ model = 'sf.product.model.type.routing.sort'
+ product_routing_workcenter = self.env[model].search(
[('product_model_type_id', '=', production.product_id.product_model_type_id.id)],
order='sequence asc'
)
@@ -368,55 +373,66 @@ class StockRule(models.Model):
i += 1
technology_design_values.append(
self.env['sf.technology.design'].json_technology_design_str(k, route, i))
- surface_technics_arr = []
- route_workcenter_arr = []
- for process_param in production.product_id.product_model_type_id.surface_technics_routing_tmpl_ids.filtered(
- lambda st: st.id in production.product_id.model_process_parameters_ids.ids):
- # if item.route_workcenter_id.surface_technics_id.id:
- # for process_param in production.product_id.model_process_parameters_ids:
- logging.info('process_param:%s%s' % (process_param.id, process_param.name))
- if item.route_workcenter_id.surface_technics_id == process_param.process_id:
- logging.info(
- 'surface_technics_id:%s%s' % (
- item.route_workcenter_id.surface_technics_id.id,
- item.route_workcenter_id.surface_technics_id.name))
- 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 = production.product_id.model_process_parameters_ids.filtered(
- lambda pm: pm.process_id.id == p.id)
- product_production_process = self.env['product.template'].search(
- [('server_product_process_parameters_id', '=',
- process_parameter.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(k,
- route_production_process,
- product_production_process,
- i))
+ elif production.product_id.categ_id.type == '坯料':
+ embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search(
+ [('embryo_model_type_id', '=', production.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('', route_embryo, i))
+ surface_technics_arr = []
+ route_workcenter_arr = []
+ aa = production.product_id.product_model_type_id.surface_technics_routing_tmpl_ids.filtered(
+ lambda st: st.id in production.product_id.model_process_parameters_ids.ids)
+ for process_param in production.product_id.product_model_type_id.surface_technics_routing_tmpl_ids.filtered(
+ lambda st: st.id in production.product_id.model_process_parameters_ids.ids):
+ # if item.route_workcenter_id.surface_technics_id.id:
+ # for process_param in production.product_id.model_process_parameters_ids:
+ logging.info('process_param:%s%s' % (process_param.id, process_param.name))
+ if item.route_workcenter_id.surface_technics_id == process_param.process_id:
+ logging.info(
+ 'surface_technics_id:%s%s' % (
+ item.route_workcenter_id.surface_technics_id.id,
+ item.route_workcenter_id.surface_technics_id.name))
+ 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 = production.product_id.model_process_parameters_ids.filtered(
+ lambda pm: pm.process_id.id == p.id)
+ product_production_process = self.env['product.template'].search(
+ [('server_product_process_parameters_id', '=',
+ process_parameter.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(k,
+ route_production_process,
+ product_production_process,
+ i))
productions.technology_design_ids = technology_design_values
- # # 同一个产品多个制造订单对应一个编程单和模型库
- # # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
- # if not production_item.programming_no:
- # if not production_programming.programming_no:
- # production_item.fetchCNC(
- # ', '.join(product_id_to_production_names[production_item.product_id.id]))
- # else:
- # production_item.write({'programming_no': production_programming.programming_no,
- # 'programming_state': '编程中'})
+ # 同一个产品多个制造订单对应一个编程单和模型库
+ # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递
+ if not production_item.programming_no and production.production_type == '自动化产线加工':
+ if not production_programming.programming_no:
+ production_item.fetchCNC(
+ ', '.join(product_id_to_production_names[production_item.product_id.id]))
+ else:
+ production_item.write({'programming_no': production_programming.programming_no,
+ 'programming_state': '编程中'})
return True
diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml
index b90d8c69..fc03ba6e 100644
--- a/sf_manufacturing/views/mrp_production_addional_change.xml
+++ b/sf_manufacturing/views/mrp_production_addional_change.xml
@@ -36,7 +36,8 @@
decoration-success="reservation_state == 'assigned'"/>
-
+
@@ -116,23 +117,18 @@
string="验证" type="object" class="oe_highlight"
confirm="There are no components to consume. Are you still sure you want to continue?"
data-hotkey="g" groups="sf_base.group_sf_mrp_user"/>
-
-
-
-
+
-
-
-
-
+
-
+
+
+
+
+
+
+