控制字段、page显隐逻辑

This commit is contained in:
mgw
2025-03-12 12:43:13 +08:00
parent de1bdbe18b
commit 5e51ee8db3
5 changed files with 55 additions and 37 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from odoo import models, fields
from odoo import models, fields, api
from odoo.exceptions import ValidationError
class SfQualityPoint(models.Model):
_inherit = 'quality.point'
@@ -16,4 +16,14 @@ class SfQualityPoint(models.Model):
operation_id = fields.Many2one(
'mrp.routing.workcenter', 'Step', check_company=True,
domain="[('is_outsource', '=', False),('company_id', 'in', (company_id, False))]")
@api.onchange('test_type_id')
def _onchange_test_type_id(self):
"""
如果类型选择了出厂检验报告检查measure_on的值是否为product如果为product则类型的值不变如果
不是,则提示错误
"""
if self.test_type_id.name == '出厂检验报告':
if self.measure_on != 'product':
raise ValidationError('出厂检验报告的测量对象必须为产品')