From ba955ca658526eb4d3a3b88f687039c47d281b1d Mon Sep 17 00:00:00 2001 From: guanhuan Date: Sat, 14 Sep 2024 08:46:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=AB=E9=80=9F=E8=AE=A2=E5=8D=95=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=A8=A1=E5=9E=8B=E6=96=87=E4=BB=B6=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8E=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_sale/models/quick_easy_order_old.py | 13 +++++++++++++ sf_sale/views/quick_easy_order_view.xml | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index 1d0487b8..4756a2c5 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -58,6 +58,15 @@ class QuickEasyOrder(models.Model): part_drawing_number = fields.Char('零件图号') machining_drawings = fields.Binary('2D加工图纸') + machining_drawings_name = fields.Char('2D加工图纸名') + + @api.onchange('machining_drawings_name') + def _onchange_machining_drawings_name(self): + for item in self: + if item.machining_drawings_name: + if not item.machining_drawings_name.lower().endswith( + '.pdf'): + raise ValidationError('文件格式上传有误,请检查文件后缀(不区分大小写)是否为pdf') @api.onchange('parameter_ids') def _compute_parameter_ids(self): @@ -128,6 +137,10 @@ class QuickEasyOrder(models.Model): if len(item.upload_model_file) > 1: raise ValidationError('只允许上传一个文件') if item.upload_model_file: + if not item.upload_model_file.name.lower().endswith( + '.step') and not item.upload_model_file.name.lower().endswith( + '.stp'): + raise ValidationError('文件格式上传有误,请检查文件后缀(不区分大小写)是否为step、stp') file_attachment_id = item.upload_model_file[0] # 附件路径 report_path = file_attachment_id._full_path(file_attachment_id.store_fname) diff --git a/sf_sale/views/quick_easy_order_view.xml b/sf_sale/views/quick_easy_order_view.xml index 7d6f6133..aebb4e97 100644 --- a/sf_sale/views/quick_easy_order_view.xml +++ b/sf_sale/views/quick_easy_order_view.xml @@ -80,7 +80,8 @@ - + +