1、质检单有关后置三元检测的字段和页签添加工单没有后置三元检测时隐藏的条件;2、工单添加质检单跳转按钮
This commit is contained in:
@@ -4,3 +4,4 @@
|
||||
from . import custom_quality
|
||||
from . import quality
|
||||
from . import quality_cnc_test
|
||||
from . import mrp_workorder
|
||||
|
||||
25
sf_quality/models/mrp_workorder.py
Normal file
25
sf_quality/models/mrp_workorder.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ResMrpWorkOrder(models.Model):
|
||||
_inherit = 'mrp.workorder'
|
||||
|
||||
check_ids_state = fields.Selection([('none', '待处理'), ('pass', '通过的'), ('fail', '失败的')], store=True,
|
||||
compute='_compute_check_ids_state')
|
||||
|
||||
@api.depends('check_ids.quality_state')
|
||||
def _compute_check_ids_state(self):
|
||||
for mw in self:
|
||||
if mw.check_ids:
|
||||
if all(check_id.quality_state == 'pass' for check_id in mw.check_ids):
|
||||
mw.check_ids_state = 'pass'
|
||||
elif any(check_id.quality_state == 'fail' for check_id in mw.check_ids):
|
||||
mw.check_ids_state = 'fail'
|
||||
else:
|
||||
mw.check_ids_state = 'none'
|
||||
|
||||
def action_open_quality_check_work_sf(self):
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("quality_control.quality_check_action_picking")
|
||||
action['context'] = self.env.context.copy()
|
||||
action['domain'] = [('workorder_id', '=', self.id)]
|
||||
return action
|
||||
@@ -17,6 +17,7 @@ class QualityCheck(models.Model):
|
||||
('fail', '失败的')], string='状态', tracking=True, store=True,
|
||||
default='none', copy=False, compute='_compute_quality_state')
|
||||
|
||||
individuation_page_PTD = fields.Boolean('个性化记录(是否显示后置三元检测[PTD]页签)', related='workorder_id.individuation_page_PTD')
|
||||
work_state = fields.Selection(related='workorder_id.state', string='工单状态')
|
||||
processing_panel = fields.Char(related='workorder_id.processing_panel', string='加工面')
|
||||
|
||||
@@ -26,7 +27,7 @@ class QualityCheck(models.Model):
|
||||
model_file = fields.Binary(related='workorder_id.glb_file', string='加工模型')
|
||||
|
||||
detection_report = fields.Binary(related='workorder_id.detection_report', readonly=True, string='检测报告')
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], string="检测结果",
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工")], string="检测结果",
|
||||
default='合格')
|
||||
reason = fields.Selection(
|
||||
[("programming", "编程"), ("cutter", "刀具"), ("clamping", "装夹"), ("operate computer", "操机"),
|
||||
@@ -61,7 +62,7 @@ class QualityCheck(models.Model):
|
||||
def do_pass(self):
|
||||
self.ensure_one()
|
||||
super().do_pass()
|
||||
if self.workorder_id:
|
||||
if self.workorder_id and self.individuation_page_PTD is True:
|
||||
# 1)将页签“判定结果”的检测结果值同步到【工单_后置三元检测_检测结果】
|
||||
if self.test_results in ['返工', '报废']:
|
||||
raise ValidationError('请重新选择【判定结果】-【检测结果】')
|
||||
@@ -73,7 +74,7 @@ class QualityCheck(models.Model):
|
||||
def do_fail(self):
|
||||
self.ensure_one()
|
||||
super().do_fail()
|
||||
if self.workorder_id:
|
||||
if self.workorder_id and self.individuation_page_PTD is True:
|
||||
# 1)将页签“判定结果”的检测结果值同步到【工单_后置三元检测_检测结果】
|
||||
if not self.test_results:
|
||||
raise ValidationError('请填写【判定结果】里的信息')
|
||||
|
||||
Reference in New Issue
Block a user