新增退回调整

This commit is contained in:
jinling.yang
2024-11-12 11:43:40 +08:00
parent 026bf17a68
commit 8bbc65ef88
5 changed files with 102 additions and 79 deletions

View File

@@ -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

View File

@@ -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 == '未排':
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')):
@@ -274,15 +274,21 @@ class MrpProduction(models.Model):
else:
workorder = self.env['mrp.workorder'].search([('name', '=', item.route_id.name)])
if not workorder:
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(
production, route, product_production_process.seller_ids[0].partner_id.id))
'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.workorders.write({})
self.write({'workorder_ids': workorders_values})
self._reset_work_order_sequence()
# 工艺确认
def technology_confirm(self):

View File

@@ -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(_("您不能创建周期性的依赖关系."))

View File

@@ -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,8 +373,19 @@ class StockRule(models.Model):
i += 1
technology_design_values.append(
self.env['sf.technology.design'].json_technology_design_str(k, route, 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:
@@ -408,15 +424,15 @@ class StockRule(models.Model):
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

View File

@@ -36,7 +36,8 @@
decoration-success="reservation_state == 'assigned'"/>
</xpath>
<xpath expr="//field[@name='state']" position="before">
<field name="production_type" widget="badge" decoration-warning="production_type == '人工线下加工'" decoration-success="production_type == '自动化产线加工'" optional="show"/>
<field name="production_type" widget="badge" decoration-warning="production_type == '人工线下加工'"
decoration-success="production_type == '自动化产线加工'" optional="show"/>
</xpath>
<xpath expr="//field[@name='activity_ids']" position="replace">
<field name="activity_ids" string="下一个活动" widget="list_activity" optional="hide"/>
@@ -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"/>
<button name="technology_confirm" string="工艺确认" type="object" class="oe_highlight"
attrs="{'invisible': ['|', '|', ('state', 'in', ('draft', 'cancel', 'done', 'to_close')), ('qty_producing', '=', 0), ('move_raw_ids', '!=', [])]}"></button>
</xpath>
<xpath expr="(//header//button[@name='button_mark_done'])[2]" position="replace">
<button name="button_mark_done"
attrs="{'invisible': ['|', '|', ('state', 'in', ('draft', 'cancel', 'done', 'to_close')), ('qty_producing', '=', 0), ('move_raw_ids', '=', [])]}"
string="验证" type="object" data-hotkey="g"
groups="sf_base.group_sf_mrp_user"/>
<button name="technology_confirm" string="工艺确认" type="object" class="oe_highlight"
attrs="{'invisible': ['|', '|', ('state', 'in', ('draft', 'cancel', 'done', 'to_close')), ('qty_producing', '=', 0), ('move_raw_ids', '=', [])]}"
></button>
</xpath>
<xpath expr="(//header//button[@name='button_scrap'])" position="replace">
<button name="technology_confirm" string="工艺确认" type="object" class="oe_highlight"
attrs="{'invisible': [('workorder_ids', '!=', [])]}"></button>
<button name="technology_back_adjust" string="退回调整" type="object" class="oe_highlight"></button>
<button name="technology_back_adjust" string="退回调整" type="object" class="oe_highlight"
attrs="{'invisible': [('state', '!=', 'confirmed')]}"></button>
<button name="button_scrap" invisible="1"/>
<button name="do_update_program" string="更新程序" type="object" groups="sf_base.group_sf_mrp_user"
confirm="是否确认更新程序"
@@ -302,8 +298,7 @@
</xpath>
<xpath expr="//sheet//notebook//page[@name='operations']" position="attributes">
<attribute name="attrs">{'invisible': ['|',('schedule_state', '=', '未排'),('workorder_ids', '=',
[])]}
<attribute name="attrs">{'invisible': [('workorder_ids', '=', [])]}
</attribute>
</xpath>
@@ -344,10 +339,7 @@
<field name="part_drawing" widget="adaptive_viewer"/>
</page>
</xpath>
<xpath expr="//sheet//notebook" position="inside">
<page string="质检标准">
<field name="quality_standard" widget="adaptive_viewer"/>
</page>
<xpath expr="//sheet//notebook//page[@name='components']" position="before">
<page string="工艺设计">
<field name="technology_design_ids" widget="one2many">
<tree editable="bottom">
@@ -370,6 +362,12 @@
</field>
</page>
</xpath>
<xpath expr="//sheet//notebook" position="inside">
<page string="质检标准">
<field name="quality_standard" widget="adaptive_viewer"/>
</page>
</xpath>
</field>
</record>