From ccbe311c58972a237acd6580a6d127b1ca7e3bb0 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Fri, 13 Sep 2024 10:45:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=BF=AB=E9=80=9F=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=A1=AB=E5=86=99=E7=9A=84=E9=9B=B6=E4=BB=B6=E5=9B=BE=E5=8F=B7?= =?UTF-8?q?=E5=92=8C=E9=9B=B6=E4=BB=B6=E5=9B=BE=E7=BA=B8=E4=BC=A0=E7=BB=99?= =?UTF-8?q?=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/stock.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 9f6206cb..daf049eb 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -269,8 +269,9 @@ class StockRule(models.Model): sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)]) # 根据销售订单号查询快速订单 quick_easy_order = self.env['quick.easy.order'].sudo().search([('sale_order_id', '=', sale_order.id)]) - production.write({'part_number': quick_easy_order.part_drawing_number, - 'part_drawing': quick_easy_order.machining_drawings}) + if quick_easy_order: + production.write({'part_number': quick_easy_order.part_drawing_number, + 'part_drawing': quick_easy_order.machining_drawings}) if sale_order: # sale_order.write({'schedule_status': 'to schedule'}) self.env['sf.production.plan'].sudo().with_company(company_id).create({ From ba955ca658526eb4d3a3b88f687039c47d281b1d Mon Sep 17 00:00:00 2001 From: guanhuan Date: Sat, 14 Sep 2024 08:46:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=BF=AB=E9=80=9F=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=A8=A1=E5=9E=8B=E6=96=87=E4=BB=B6=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=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 @@ - + +