From c658027dccaf9d70ccfa0fb5fea179b9e56f0e29 Mon Sep 17 00:00:00 2001 From: guanhuan Date: Thu, 9 Jan 2025 10:45:06 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=9B=B6=E4=BB=B6?= =?UTF-8?q?=E5=9B=BE=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 8 +++++++- sf_manufacturing/models/product_template.py | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index fd136048..8b290312 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -652,7 +652,13 @@ class MrpProduction(models.Model): 'user': cnc.env.user.name, 'programme_way': programme_way, 'model_file': '' if not cnc.product_id.model_file else base64.b64encode( - cnc.product_id.model_file).decode('utf-8') + cnc.product_id.model_file).decode('utf-8'), + 'part_name': cnc.product_id.part_name, + 'part_number': cnc.product_id.part_number, + 'machining_drawings': base64.b64encode(cnc.product_id.machining_drawings).decode( + 'utf-8') if cnc.product_id.machining_drawings else '', + 'machining_drawings_name': cnc.product_id.machining_drawings_name, + 'machining_drawings_mimetype': cnc.product_id.machining_drawings_mimetype, } # 打印出除了 model_file 之外的所有键值对 for key, value in res.items(): diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 4b927596..307fbbc2 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -778,6 +778,8 @@ class ResProductMo(models.Model): quality_standard = fields.Binary('质检标准', readonly=True) part_name = fields.Char(string='零件名称', readonly=True) part_number = fields.Char(string='零件图号', readonly=True) + machining_drawings_name = fields.Char(string='零件图号名称', readonly=True) + machining_drawings_mimetype = fields.Char(string='零件图号类型', readonly=True) @api.constrains('tool_length') def _check_tool_length_size(self): if self.tool_length > 1000000: @@ -892,6 +894,8 @@ class ResProductMo(models.Model): item['machining_drawings']), 'quality_standard': '' if not item['quality_standard'] else base64.b64decode(item['quality_standard']), 'part_name': item.get('part_name') or '', + 'machining_drawings_name': item.get('machining_drawings_name') or '', + 'machining_drawings_mimetype': item.get('machining_drawings_mimetype') or '', } tax_id = self.env['account.tax'].sudo().search( [('type_tax_use', '=', 'sale'), ('amount', '=', item.get('tax')), ('price_include', '=', 'True')]) From 1084f4db12e2825d346898867ccad3b87f54ace3 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Thu, 9 Jan 2025 16:12:56 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 8a1c9072..2d5bec30 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -459,7 +459,7 @@ class MrpProduction(models.Model): process_parameters.append(special.process_parameters_id.display_name) if account_moves: - raise UserError(_("请联系工厂生产经理对会计凭证为%s生成的账单进行取消", ", ".join([move.name for move in account_moves]))) + raise UserError(_("请联系工厂生产经理对采购订单为%s生成的账单进行取消", ", ".join(account_moves))) if parameters_not: raise UserError(_("【工艺设计】-【工序】为%s未选择参数,请选择", ", ".join(parameters_not))) if process_parameters: From e27506fb07a044f7414456a59541fea5d0fddd46 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Thu, 9 Jan 2025 17:22:03 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8E=E5=A7=94=E5=A4=96=E5=8A=A0=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=E6=8A=A5=E9=94=99=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 2d5bec30..89b2678c 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -433,6 +433,7 @@ class MrpProduction(models.Model): def technology_confirm(self): process_parameters = [] account_moves = [] + purchase_orders = [] parameters_not = [] # 获取原有的工单对应的工序 origin_designs = self.workorder_ids.technology_design_id @@ -444,8 +445,10 @@ class MrpProduction(models.Model): purchase = workorder._get_surface_technics_purchase_ids() account = self.env['account.move'].search([('id', 'in', purchase.invoice_ids.ids)]) if account.state not in ['cancel', False]: - if purchase.name not in account_moves: - account_moves.append(purchase.name) + if account.name not in account_moves: + account_moves.append(account.name) + if purchase.state not in ['cancel','draft', False]: + purchase_orders.append(purchase.name) special_design = self.technology_design_ids.filtered( lambda a: a.routing_tag == 'special' and a.is_auto is False) for special in special_design: @@ -459,7 +462,9 @@ class MrpProduction(models.Model): process_parameters.append(special.process_parameters_id.display_name) if account_moves: - raise UserError(_("请联系工厂生产经理对采购订单为%s生成的账单进行取消", ", ".join(account_moves))) + raise UserError(_("请联系工厂生产经理对该(%s)账单进行取消", ", ".join(account_moves))) + if purchase_orders: + raise UserError(_("请联系工厂生产经理对该(%s)采购订单进行取消", ", ".join(purchase_orders))) if parameters_not: raise UserError(_("【工艺设计】-【工序】为%s未选择参数,请选择", ", ".join(parameters_not))) if process_parameters: @@ -799,7 +804,7 @@ class MrpProduction(models.Model): if process_parameter_workorder: # 将这些特殊表面工艺工单的采购单与调拨单置为失效 for workorder in process_parameter_workorder: - workorder._get_surface_technics_purchase_ids().write({'state': 'cancel'}) + # workorder._get_surface_technics_purchase_ids().write({'state': 'cancel'}) workorder.move_subcontract_workorder_ids.write({'state': 'cancel'}) workorder.move_subcontract_workorder_ids.picking_id.write({'state': 'cancel'}) sorted_workorders = sorted(process_parameter_workorder, key=lambda w: w.sequence) @@ -1480,7 +1485,10 @@ class MrpProduction(models.Model): """ 重载创建制造订单的方法,单个制造订单,同一成品只创建一个采购组,用于后续单据的创建 """ - group_id = self.env["procurement.group"].create({'name':vals_list[0].get('origin')}).id + group_id = False + first_origin = next((obj['origin'] for obj in vals_list if 'origin' in obj), None) + if first_origin: + group_id = self.env["procurement.group"].create({'name':first_origin}).id for vals in vals_list: if not vals.get('name', False) or vals['name'] == _('New'): picking_type_id = vals.get('picking_type_id') @@ -1488,7 +1496,7 @@ class MrpProduction(models.Model): picking_type_id = self._get_default_picking_type_id(vals.get('company_id', self.env.company.id)) vals['picking_type_id'] = picking_type_id vals['name'] = self.env['stock.picking.type'].browse(picking_type_id).sequence_id.next_by_id() - if not vals.get('procurement_group_id'): + if not vals.get('procurement_group_id') and group_id: vals['procurement_group_id'] = group_id return super(MrpProduction, self).create(vals_list) From 7e9e6d07380847c349d821f8a925da176b40a125 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Thu, 9 Jan 2025 17:22:40 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=B7=A5=E8=89=BA=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=87=E8=B4=AD=E5=8D=95=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=8F=98=E5=8A=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_sale/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index 621ddfc7..95ab1ac7 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -346,7 +346,7 @@ class RePurchaseOrder(models.Model): server_product_process = [] purchase_order = pp._get_surface_technics_purchase_ids() if purchase_order: - purchase_order.write({'state': 'draft'}) + # purchase_order.write({'state': 'draft'}) pp.purchase_id = [(6, 0, [purchase_order.id])] else: server_template = self.env['product.template'].search( From 22bac48a98ea456f7957a74a1485b0db92b331e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Fri, 10 Jan 2025 09:57:06 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=9B=E5=BB=BA=E4=BA=BA=EF=BC=8C=E6=97=B6?= =?UTF-8?q?=E9=97=B4=EF=BC=8C=E5=A4=84=E7=90=86=E4=BA=BA=EF=BC=8C=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 9 +++++++++ .../views/mrp_production_addional_change.xml | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 8a1c9072..f9e7c77b 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -1577,6 +1577,7 @@ class MrpProduction(models.Model): class sf_detection_result(models.Model): _name = 'sf.detection.result' _description = "检测结果" + _order = 'handle_result_date desc, id asc' production_id = fields.Many2one('mrp.production') processing_panel = fields.Char('加工面') @@ -1594,6 +1595,8 @@ class sf_detection_result(models.Model): test_report = fields.Binary('检测报告', readonly=True) handle_result = fields.Selection([("待处理", "待处理"), ("已处理", "已处理")], default='', string="处理结果", tracking=True) + handle_result_date = fields.Datetime('处理时间') + handle_result_user = fields.Many2one('res.users', '处理人') # 查看检测报告 def button_look_test_report(self): @@ -1604,6 +1607,12 @@ class sf_detection_result(models.Model): 'views': [(self.env.ref('sf_manufacturing.sf_test_report_form').id, 'form')], 'target': 'new' } + + def write(self, vals): + if vals.get('handle_result') and vals.get('handle_result') == '已处理': + vals['handle_result_date'] = fields.Datetime.now() + vals['handle_result_user'] = self.env.user.id + return super(sf_detection_result, self).write(vals) class sf_processing_panel(models.Model): diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index 8a44b621..4c284fee 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -335,6 +335,10 @@ + + + +