新增退回调整
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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(_("您不能创建周期性的依赖关系."))
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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,14 +339,11 @@
|
||||
<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">
|
||||
<field name="sequence" widget="handle" />
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="route_id" context="{'production_id': production_id}"
|
||||
attrs="{'readonly': [('is_auto', '=', True)]}" options="{'no_create': True}"/>
|
||||
<field name="process_parameters_id" attrs="{'readonly': [('is_auto', '=', True)]}"
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user