1、优化工单子页签可全量配置处理方法;
This commit is contained in:
@@ -365,7 +365,7 @@ class MrpProduction(models.Model):
|
||||
and production.schedule_state == '已排' and production.is_rework is False):
|
||||
production.state = 'pending_cam'
|
||||
if any((wo.test_results == '返工' and wo.state == 'done' and
|
||||
(production.programming_state in ['已编程'] or 'PTD' in wo.individuation_page_list))
|
||||
(production.programming_state in ['已编程'] or(wo.individuation_page_list and 'PTD' in wo.individuation_page_list)))
|
||||
or (wo.is_rework is True and wo.state == 'done' and production.programming_state in ['编程中', '已编程'])
|
||||
for wo in production.workorder_ids) or production.is_rework is True:
|
||||
production.state = 'rework'
|
||||
|
||||
@@ -1442,7 +1442,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
record.production_id.process_state = '待加工'
|
||||
# 生成工件配送单
|
||||
record.workpiece_delivery_ids = record._json_workpiece_delivery_list()
|
||||
if record.routing_type == 'CNC加工' or 'PTD' in record.individuation_page_list:
|
||||
if (record.routing_type == 'CNC加工' or
|
||||
(record.individuation_page_list and 'PTD' in record.individuation_page_list)):
|
||||
if record.routing_type == 'CNC加工':
|
||||
record.process_state = '待解除装夹'
|
||||
# record.write({'process_state': '待加工'})
|
||||
@@ -1675,32 +1676,31 @@ class ResMrpWorkOrder(models.Model):
|
||||
move_subcontract_workorder_ids = fields.One2many('stock.move', 'subcontract_workorder_id', string='组件')
|
||||
|
||||
# ==============================配置化页签--个性化记录===================================
|
||||
routing_workcenter_id = fields.Many2one('mrp.routing.workcenter', compute='_compute_routing_workcenter_id',
|
||||
store=True, string='工序作业')
|
||||
individuation_page_ids = fields.Many2many('sf.work.individuation.page', string='个性化记录', store=True,
|
||||
compute='_compute_individuation_page_ids')
|
||||
individuation_page_list = fields.Char('个性化记录', default=None)
|
||||
routing_work_center_id = fields.Many2one('mrp.routing.workcenter', compute='_compute_routing_work_center_id',
|
||||
store=True, string='工序作业')
|
||||
individuation_page_ids = fields.Many2many('sf.work.individuation.page', string='个性化记录',
|
||||
related='routing_work_center_id.individuation_page_ids')
|
||||
individuation_page_list = fields.Char('个性化记录', default='', compute='_compute_individuation_page_ids', store=True)
|
||||
|
||||
@api.depends('name')
|
||||
def _compute_routing_workcenter_id(self):
|
||||
def _compute_routing_work_center_id(self):
|
||||
for mw in self:
|
||||
routing_workcenter_id = self.env['mrp.routing.workcenter'].sudo().search(
|
||||
[('name', '=', mw.name), ('routing_type', '=', mw.routing_type)])
|
||||
if routing_workcenter_id:
|
||||
mw.routing_workcenter_id = routing_workcenter_id.id
|
||||
if not mw.routing_work_center_id and mw.name:
|
||||
routing_work_center_id = self.env['mrp.routing.workcenter'].sudo().search(
|
||||
[('name', 'in', mw.name.split('-')), ('routing_type', '=', mw.routing_type)])
|
||||
if routing_work_center_id:
|
||||
mw.routing_work_center_id = routing_work_center_id.id
|
||||
|
||||
@api.depends('routing_workcenter_id.individuation_page_ids')
|
||||
@api.depends('individuation_page_ids')
|
||||
def _compute_individuation_page_ids(self):
|
||||
for mw in self:
|
||||
if mw.routing_workcenter_id:
|
||||
mw.individuation_page_ids = mw.routing_workcenter_id.individuation_page_ids.ids
|
||||
# 初始化页签配置
|
||||
mw.individuation_page_list = None
|
||||
# 根据工单对应的【作业_个性化记录】配置页签
|
||||
individuation_page_list = [item.code for item in mw.routing_workcenter_id.individuation_page_ids]
|
||||
if individuation_page_list:
|
||||
mw.individuation_page_list = list(set(individuation_page_list))
|
||||
|
||||
mw.individuation_page_list = '[]'
|
||||
if mw.routing_work_center_id:
|
||||
if mw.individuation_page_ids:
|
||||
# 根据工单对应的【作业_个性化记录】配置页签
|
||||
individuation_page_list = [item.code for item in mw.individuation_page_ids]
|
||||
if individuation_page_list:
|
||||
mw.individuation_page_list = list(set(individuation_page_list))
|
||||
# =============================================================================================
|
||||
|
||||
is_inspect = fields.Boolean('需送检', compute='_compute_is_inspect', store=True, default=False)
|
||||
@@ -2010,7 +2010,7 @@ class WorkPieceDelivery(models.Model):
|
||||
feeder_station_destination_id = fields.Many2one('sf.agv.site', '目的接驳站')
|
||||
task_delivery_time = fields.Datetime('任务下发时间')
|
||||
task_completion_time = fields.Datetime('任务完成时间')
|
||||
|
||||
|
||||
def _get_agv_route_type_selection(self):
|
||||
return self.env['sf.agv.task.route'].fields_get(['route_type'])['route_type']['selection']
|
||||
type = fields.Selection(selection=_get_agv_route_type_selection, string='类型')
|
||||
|
||||
@@ -503,14 +503,6 @@
|
||||
</group>
|
||||
</page>
|
||||
|
||||
<page string="2D加工图纸" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "2D_MD")]}'>
|
||||
<field name="machining_drawings" widget="adaptive_viewer"/>
|
||||
</page>
|
||||
|
||||
<page string="质检标准" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "QIS")]}'>
|
||||
<field name="quality_standard" widget="adaptive_viewer"/>
|
||||
</page>
|
||||
|
||||
<page string="工件配送" attrs='{"invisible": ["!", ("individuation_page_list", "ilike", "WD")]}'>
|
||||
<field name="workpiece_delivery_ids">
|
||||
<tree editable="bottom">
|
||||
|
||||
@@ -2,3 +2,4 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
||||
@@ -5,3 +5,4 @@ from . import custom_quality
|
||||
from . import quality
|
||||
from . import quality_cnc_test
|
||||
from . import mrp_workorder
|
||||
# from . import stock
|
||||
|
||||
@@ -93,7 +93,8 @@ class QualityCheck(models.Model):
|
||||
raise ValidationError('请填写【判定结果】里的信息')
|
||||
if self.test_results == '合格':
|
||||
raise ValidationError('请重新选择【判定结果】-【检测结果】')
|
||||
if self.workorder_id.routing_type != 'CNC加工' and 'PTD' not in self.workorder_id.individuation_page_list:
|
||||
if (self.workorder_id.routing_type != 'CNC加工' and self.workorder_id.individuation_page_list
|
||||
and 'PTD' not in self.workorder_id.individuation_page_list):
|
||||
self.workorder_id.production_id.write({'detection_result_ids': [(0, 0, {
|
||||
'rework_reason': self.reason,
|
||||
'detailed_reason': self.detailed_reason,
|
||||
|
||||
21
sf_quality/models/stock.py
Normal file
21
sf_quality/models/stock.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class StockPicking(models.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
def button_validate(self):
|
||||
"""
|
||||
调拨单若关联了质量检查单,验证调拨单时,应校验是否有不合格品,若存在,应弹窗提示:
|
||||
“警告:存在不合格产品XXXX n 件、YYYYY m件,继续调拨请点“确认”,否则请取消?”
|
||||
"""
|
||||
if self.quality_check_ids.filtered(lambda qc: qc.quality_state == 'fail'):
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': 'sf.functional.tool.assembly.order',
|
||||
'name': ' ',
|
||||
'view_mode': 'form',
|
||||
'target': 'new',
|
||||
'context': {'': True}
|
||||
}
|
||||
return super(StockPicking, self).button_validate()
|
||||
0
sf_quality/wizard/__init__.py
Normal file
0
sf_quality/wizard/__init__.py
Normal file
Reference in New Issue
Block a user