From 82c026976143bc927bb427c85b62f758d1d8ffa9 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 10 Jan 2024 15:24:31 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9D=90=E6=96=99=E5=9E=8B=E5=8F=B7=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F=E5=92=8C=E4=BE=9B?= =?UTF-8?q?=E5=BA=94=E5=95=86=E7=9A=84=E8=BE=93=E5=85=A5=E9=AA=8C=E8=AF=81?= =?UTF-8?q?2.=E6=AF=8F=E9=BD=BF=E8=B5=B0=E5=88=80=E9=87=8F=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E5=88=87=E5=89=8A=E9=80=9F=E5=BA=A6=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/common.py | 12 +++++++++++- sf_base/models/tool_other_features.py | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sf_base/models/common.py b/sf_base/models/common.py index f6e6771a..7450fff9 100644 --- a/sf_base/models/common.py +++ b/sf_base/models/common.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- import logging from urllib.parse import urlencode -from odoo import fields, models +from odoo import fields, models, api +from odoo.exceptions import UserError + _logger = logging.getLogger(__name__) @@ -59,6 +61,14 @@ class MrsMaterialModel(models.Model): supplier_ids = fields.One2many('sf.supplier.sort', 'materials_model_id', string='供应商') active = fields.Boolean('有效', default=True) + @api.constrains('gain_way', 'supplier_ids') + def _check_gain_way(self): + if not self.gain_way: + raise UserError("请输入获取方式") + if self.gain_way in ['外协', '采购']: + if not self.supplier_ids: + raise UserError("请添加供应商") + class MrsProductionProcessCategory(models.Model): _name = 'sf.production.process.category' diff --git a/sf_base/models/tool_other_features.py b/sf_base/models/tool_other_features.py index d1cf0404..7ad32bc2 100644 --- a/sf_base/models/tool_other_features.py +++ b/sf_base/models/tool_other_features.py @@ -162,7 +162,6 @@ class FeedPerTooth(models.Model): _order = 'blade_diameter,cutting_width_depth_id,materials_type_id' name = fields.Char('名称') - cutting_speed = fields.Char('切削速度', required=True) product_template_id = fields.Many2one('product.template') standard_library_id = fields.Many2one('sf.cutting_tool.standard.library', string='标准库') blade_diameter = fields.Integer('刃部直径(mm)', readonly=True)