30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
||
from odoo import models, fields, api
|
||
from odoo.exceptions import ValidationError
|
||
|
||
class SfQualityPoint(models.Model):
|
||
_inherit = 'quality.point'
|
||
_rec_name = 'title'
|
||
|
||
product_ids = fields.Many2many(
|
||
'product.product', string='适用产品',
|
||
domain="[('type', 'in', "
|
||
"('product', 'consu')), '|', ('company_id', '=', False), ('company_id', '=', company_id)]", help=
|
||
"Quality Point will apply to every selected Products.")
|
||
|
||
is_inspect = fields.Boolean('需送检', default=False)
|
||
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('出厂检验报告的测量对象必须为产品')
|
||
|