From 0bea93ea4652060994e66eab48d12a394f00f78f Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Wed, 27 Nov 2024 17:54:59 +0800 Subject: [PATCH 01/16] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E8=BF=94?= =?UTF-8?q?=E5=B7=A5=E5=90=91=E5=AF=BC=E4=B8=AD=E9=80=89=E6=8B=A9=E8=BF=94?= =?UTF-8?q?=E5=B7=A5=E5=B7=A5=E5=8D=95=E9=99=90=E5=88=B6=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/wizard/rework_wizard.py | 45 ++++++++++++++++++------ 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/sf_manufacturing/wizard/rework_wizard.py b/sf_manufacturing/wizard/rework_wizard.py index bb787c11..eeae9ae9 100644 --- a/sf_manufacturing/wizard/rework_wizard.py +++ b/sf_manufacturing/wizard/rework_wizard.py @@ -4,6 +4,7 @@ import logging from odoo.exceptions import UserError, ValidationError from datetime import datetime from odoo import models, api, fields, _ +from odoo.tools import groupby class ReworkWizard(models.TransientModel): @@ -37,6 +38,30 @@ class ReworkWizard(models.TransientModel): tool_state = fields.Selection(string='功能刀具状态', related='production_id.tool_state') + @api.onchange('hidden_workorder_ids') + def _onchange_hidden_workorder_ids(self): + for item in self: + if item.hidden_workorder_ids not in ['', None, False]: + hidden_workorder_list = item.hidden_workorder_ids.split(',') + # 获取加工面对应需要返工的工单 + rw_ids = item.workorder_ids.filtered( + lambda w: str(w.ids[0]) in hidden_workorder_list and w.processing_panel not in ['', None, False]) + grouped_rw_ids = {key: list(group) for key, group in groupby(rw_ids, key=lambda w: w.processing_panel)} + for panel, panel_rw_ids in grouped_rw_ids.items(): + work_ids = item.workorder_ids.filtered(lambda w: w.state == 'done' and w.processing_panel == panel) + if len(work_ids) == 3 and len(panel_rw_ids) != 3: + for work_id in work_ids: + if work_id not in panel_rw_ids: + hidden_workorder_list.append(str(work_id.ids[0])) + elif len(work_ids) == 2 and len(panel_rw_ids) < 2 and panel_rw_ids[0].name == 'CNC加工': + if rw_ids.filtered(lambda w: (w.sequence < panel_rw_ids[0].sequence + and w.processing_panel != panel_rw_ids[0].processing_panel)): + hidden_workorder_list.append(str(work_ids.filtered( + lambda w: (w.processing_panel == panel_rw_ids[0].processing_panel + and w.name == '装夹预调')).ids[0])) + hidden_workorder_list.sort() + item.hidden_workorder_ids = ','.join(hidden_workorder_list) + def confirm(self): if self.routing_type in ['装夹预调', 'CNC加工']: self.is_clamp_measure = False @@ -58,16 +83,16 @@ class ReworkWizard(models.TransientModel): # 1、当制造订单内ZM面的工单都已完成时,返工勾选工序时只能勾选上ZM面的所有工序进行返工 # 2、当FM工单在CNC工单进行选择返工,并将已全部完成的ZM面工序全部勾选上时,FM工单上所有的已完成的工单(装夹预调工单)也必须进行勾选 # 获取已完成的标准工单 - done_normative_workorder_ids = self.workorder_ids.filtered( - lambda w: w.state == 'done' and w.processing_panel is not False) - # 获取需要返工的标准工单 - rework_normative_workorder_ids = rework_workorder_ids.filtered( - lambda w: w.processing_panel is not False) - if rework_normative_workorder_ids: - for rw in rework_normative_workorder_ids: - if len(done_normative_workorder_ids.filtered( - lambda w: w.processing_panel == rw.processing_panel)) == 3: - pass + # done_normative_workorder_ids = self.workorder_ids.filtered( + # lambda w: w.state == 'done' and w.processing_panel is not False) + # # 获取需要返工的标准工单 + # rework_normative_workorder_ids = rework_workorder_ids.filtered( + # lambda w: w.processing_panel is not False) + # if rework_normative_workorder_ids: + # for rw in rework_normative_workorder_ids: + # if len(done_normative_workorder_ids.filtered( + # lambda w: w.processing_panel == rw.processing_panel)) == 3: + # pass else: raise ValidationError('请选择返工工单!!!') if rework_workorder_ids: From f1e70d2c668f7f8026d067274a67a3c572ee059b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 28 Nov 2024 11:36:32 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=AF=A2=E4=BB=B7?= =?UTF-8?q?=E5=8D=95=E4=B8=AD=E8=87=AA=E5=8A=A8=E5=8C=96=E4=BA=A7=E7=BA=BF?= =?UTF-8?q?=E5=8A=A0=E5=B7=A5=E7=9A=84=E8=AE=A2=E5=8D=95=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=BC=96=E7=A8=8B=E5=8D=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 20e740f3..25819fe1 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -317,7 +317,7 @@ class StockRule(models.Model): if production_item.product_id.id in product_id_to_production_names: # 同一个产品多个制造订单对应一个编程单和模型库 # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递 - if not production_item.programming_no and production.production_type == '自动化产线加工': + if not production_item.programming_no and production_item.production_type == '自动化产线加工': if not production_programming.programming_no: production_item.fetchCNC( ', '.join(product_id_to_production_names[production_item.product_id.id])) From 8ff73d564779a02ed0bf28e24e6738e28e78a431 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 28 Nov 2024 15:09:11 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index d50b1df2..6858ccab 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1095,8 +1095,7 @@ class ResMrpWorkOrder(models.Model): # ================= 如果制造订单刀具状态为[无效刀、缺刀] 或者 制造订单状态为[返工]========================== if (workorder.production_id.tool_state in ['1', '2'] or workorder.production_id.state == 'rework' or workorder.production_id.schedule_state != '已排' - or len( - workorder.production_id.picking_ids.filtered(lambda w: w.state not in ['done', 'cancel'])) != 0 + or workorder.production_id.reservation_state not in ['assigned'] or workorder.production_id.workorder_ids.filtered( lambda wk: wk.sequence == workorder.sequence - 1).test_results in ['报废', '返工']): if workorder.state != 'waiting': From 96171013d61c9b6542651291877cddbdc05b8eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 28 Nov 2024 15:10:45 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=92=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan/models/custom_plan.py | 73 +++++++++++++++-------------------- 1 file changed, 31 insertions(+), 42 deletions(-) diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index e7785ad4..7fcec54e 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -232,41 +232,37 @@ class sf_production_plan(models.Model): raise ValidationError("未选择生产线") else: # 自动化产线加工 - if record.production_id.production_type == '自动化产线加工': - if record.production_id.workorder_ids: - last_cnc_start = record.date_planned_start if record.date_planned_start else datetime.now() - for item in record.production_id.workorder_ids: - if item.name == 'CNC加工': - # 将同一个面的所有工单筛选出来 - workorder_list = record.production_id.workorder_ids.filtered(lambda x: x.processing_panel == item.processing_panel) - routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search( - [('name', '=', 'CNC加工')], limit=1) - # 设置一个小的开始时间 - item.date_planned_start = datetime.now() - timedelta(days=100) - item.date_planned_finished = last_cnc_start + timedelta( - minutes=routing_workcenter.time_cycle) - item.date_planned_start = last_cnc_start - record.sudo().production_id.plan_start_processing_time = item.date_planned_start - item.duration_expected = routing_workcenter.time_cycle - pre_duration , next_duration = record.calculate_plan_time(item, workorder_list) - record.date_planned_finished = item.date_planned_finished - # 计算下一个cnc工单的开始时间 - last_cnc_start = workorder_list[-1].date_planned_finished + timedelta(minutes=pre_duration) - # 没有工单也能排程 - else: - # 人工线下加工只排第一张工单 - if record.production_id.workorder_ids: - item = record.production_id.workorder_ids[0] - last_wo_start = record.date_planned_start if record.date_planned_start else datetime.now() - routing_workcenter = record.env['mrp.routing.workcenter'].sudo().search( - [('name', '=', item.routing_type)], limit=1) - item.date_planned_start = datetime.now() - timedelta(days=100) - item.date_planned_finished = last_wo_start + timedelta( + if record.production_id.workorder_ids: + # 自动化产线加工 + if record.production_id.production_type == '自动化产线加工': + # 找到第一张CNC加工工单 + first_cnc_workorder = record.production_id.workorder_ids.filtered(lambda x: x.name == 'CNC加工')[0] + date_start = record.date_planned_start if record.date_planned_start else datetime.now() + routing_workcenter = first_cnc_workorder.technology_design_id.route_id + # 设置一个小的开始时间 + first_cnc_workorder.date_planned_start = datetime.now() - timedelta(days=100) + first_cnc_workorder.date_planned_finished = date_start + timedelta( minutes=routing_workcenter.time_cycle) - item.date_planned_start = last_wo_start + first_cnc_workorder.date_planned_start = date_start + record.sudo().production_id.plan_start_processing_time = first_cnc_workorder.date_planned_start + first_cnc_workorder.duration_expected = routing_workcenter.time_cycle + record.calculate_plan_time(first_cnc_workorder, record.production_id.workorder_ids) + # 找到最后一张CNC加工工单 + last_cnc_workorder = record.production_id.workorder_ids.filtered(lambda x: x.name == 'CNC加工')[-1] + record.date_planned_finished = last_cnc_workorder.date_planned_finished + else: + # 人工线下加工只排第一张工单 + item = record.production_id.workorder_ids[0] + wo_start = record.date_planned_start if record.date_planned_start else datetime.now() + item.date_planned_start = datetime.now() - timedelta(days=100) + item.date_planned_finished = wo_start + timedelta( + minutes=routing_workcenter.time_cycle) + item.date_planned_start = wo_start record.sudo().production_id.plan_start_processing_time = item.date_planned_start item.duration_expected = routing_workcenter.time_cycle - record.calculate_plan_time(item, item) + record.calculate_plan_time(item, record.production_id.workorder_ids) + last_cnc_workorder = record.production_id.workorder_ids[-1] + record.date_planned_finished = last_cnc_workorder.date_planned_finished record.state = 'done' # record.production_id.schedule_state = '已排' record.sudo().production_id.schedule_state = '已排' @@ -328,38 +324,31 @@ class sf_production_plan(models.Model): if workorder.id == item.id: item_position = index break - routing_workcenters = self.env['mrp.routing.workcenter'].sudo().search([]) - # 记录所有前序工序时长 - previous_workorder_duration = 0 for i in range(item_position, -1, -1): if i < 1: break current_workorder = workorder_list[i] next_workorder = workorder_list[i - 1] - routing_workcenter = routing_workcenters.filtered(lambda x: x.name == next_workorder.name)[0] + routing_workcenter = next_workorder.technology_design_id.route_id # 设置一个小的开始时间 next_workorder.date_planned_start = datetime.now() - timedelta(days=100) next_workorder.date_planned_finished = current_workorder.date_planned_start next_workorder.date_planned_start = next_workorder.date_planned_finished - timedelta( minutes=routing_workcenter.time_cycle) next_workorder.duration_expected = routing_workcenter.time_cycle - previous_workorder_duration += routing_workcenter.time_cycle - # 记录所有后续工序时长 - next_workorder_duration = 0 + for i in range(item_position, len(workorder_list) - 1): if i > len(workorder_list) - 1: break current_workorder = workorder_list[i] next_workorder = workorder_list[i + 1] - routing_workcenter = routing_workcenters.filtered(lambda x: x.name == next_workorder.name)[0] + routing_workcenter = next_workorder.technology_design_id.route_id # 设置一个小的开始时间 next_workorder.date_planned_start = datetime.now() - timedelta(days=100) next_workorder.date_planned_finished = current_workorder.date_planned_finished + timedelta( minutes=routing_workcenter.time_cycle) next_workorder.date_planned_start = current_workorder.date_planned_finished next_workorder.duration_expected = routing_workcenter.time_cycle - next_workorder_duration += routing_workcenter.time_cycle - return previous_workorder_duration, next_workorder_duration def calculate_plan_time_after(self, item, workorder_id_list): """ From d57cc591159a69e1269eac3471edf9339ce11d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 28 Nov 2024 15:20:56 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=92=E7=A8=8B?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan/models/custom_plan.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index 7fcec54e..4c4e4b30 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -254,6 +254,7 @@ class sf_production_plan(models.Model): # 人工线下加工只排第一张工单 item = record.production_id.workorder_ids[0] wo_start = record.date_planned_start if record.date_planned_start else datetime.now() + routing_workcenter = item.technology_design_id.route_id item.date_planned_start = datetime.now() - timedelta(days=100) item.date_planned_finished = wo_start + timedelta( minutes=routing_workcenter.time_cycle) From 942aa469e3e167cc7ec574274b4cbee126bdcedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 28 Nov 2024 15:21:54 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=92=E7=A8=8B?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan/models/custom_plan.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index 4c4e4b30..147caa96 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -319,6 +319,9 @@ class sf_production_plan(models.Model): def calculate_plan_time(self, item, workorder_list): """ 根据CNC工单的时间去计算之前的其他工单的开始结束时间 + param: + item: 基准工单(根据该工单的开始结束时间去计算其他工单的开始结束时间) + workorder_list: 需排程的工单列表 """ item_position = 0 for index, workorder in enumerate(workorder_list): From 7362f0cd301d1b53bcfc0df461296d6b8ce4a0bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 28 Nov 2024 15:41:39 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9D=AF=E6=96=99?= =?UTF-8?q?=E5=86=97=E4=BD=99=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/views/model_type_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_manufacturing/views/model_type_view.xml b/sf_manufacturing/views/model_type_view.xml index f0ffd81a..0f8b3085 100644 --- a/sf_manufacturing/views/model_type_view.xml +++ b/sf_manufacturing/views/model_type_view.xml @@ -31,7 +31,7 @@
- + From 2c37dbf5c40afb045c801e5d049f41e73027e5b9 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 28 Nov 2024 15:51:54 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 232b4907..65be98c7 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -331,6 +331,9 @@ class MrpProduction(models.Model): production.state = 'pending_cam' if production.is_rework is True: production.state = 'rework' + if (production.state == 'rework' and production.tool_state == '0' + and production.schedule_state == '已排' and production.is_rework is False): + production.state = 'pending_cam' # if production.state == 'pending_cam': # if all(wo_state in 'done' for wo_state in production.workorder_ids.mapped('state')): # production.state = 'done' @@ -353,6 +356,7 @@ class MrpProduction(models.Model): if production.tool_state == '2': production.state = 'rework' + # 退回调整 def technology_back_adjust(self): process_parameters = [] From c42c053d664d1699d58469eac6cd89d93acb294e Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 28 Nov 2024 15:59:17 +0800 Subject: [PATCH 09/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E9=9D=A2?= =?UTF-8?q?=E5=B7=A5=E8=89=BA=E5=A4=96=E5=8D=8F=E5=8F=8A=E5=B7=A5=E8=89=BA?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 52 +++--- sf_manufacturing/models/product_template.py | 4 +- sf_manufacturing/models/stock.py | 162 ++++++++---------- .../production_technology_re_adjust_wizard.py | 2 +- .../wizard/production_technology_wizard.py | 2 +- sf_mrs_connect/controllers/controllers.py | 76 ++++---- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- 8 files changed, 147 insertions(+), 159 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index ab4166ea..a0bc0bb6 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1204,21 +1204,21 @@ class ResMrpWorkOrder(models.Model): if self.sequence == 1: # 判断工单状态是否为等待组件 - if self.state == 'waiting': - raise UserError('制造订单【%s】缺少组件信息!' % self.production_id.name) - # 判断是否有坯料的序列号信息 - boolean = False - if self.production_id.move_raw_ids: - if self.production_id.move_raw_ids[0].product_id.categ_type == '坯料': - if self.production_id.move_raw_ids[0].move_line_ids: - if self.production_id.move_raw_ids[0].move_line_ids: - if self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name: - boolean = True - else: - boolean = True - if not boolean: - raise UserError('制造订单【%s】缺少组件的序列号信息!' % self.production_id.name) - self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name + # if self.state == 'waiting': + # raise UserError('制造订单【%s】缺少组件信息!' % self.production_id.name) + # # 判断是否有坯料的序列号信息 + # boolean = False + # if self.production_id.move_raw_ids: + # if self.production_id.move_raw_ids[0].product_id.categ_type == '坯料': + # if self.production_id.move_raw_ids[0].move_line_ids: + # if self.production_id.move_raw_ids[0].move_line_ids: + # if self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name: + # boolean = True + # else: + # boolean = True + # if not boolean: + # raise UserError('制造订单【%s】缺少组件的序列号信息!' % self.production_id.name) + # self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name # cnc校验 if self.production_id.production_type == '自动化产线加工': cnc_workorder = self.search( @@ -1247,10 +1247,14 @@ class ResMrpWorkOrder(models.Model): [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id), ('location_dest_id', '=', self.env['stock.location'].search( [('barcode', 'ilike', 'VL-SPOC')]).id), - ('origin', '=', self.production_id.name)]) - if move_out.state != 'done': - move_out.write({'state': 'assigned', 'production_id': False}) - self.env['stock.move.line'].create(move_out.get_move_line(self.production_id, self)) + ('origin', '=', self.production_id.name), ('state', 'not in', ['cancel', 'done'])]) + for mo in move_out: + pick = self.env['stock.picking'].search([('id', '=', mo.picking_id.id), ('name', 'ilike', 'OCOUT'), + ('partner_id', '=', self.supplier_id.id)]) + if pick: + if mo.state != 'done': + mo.write({'state': 'assigned', 'production_id': False}) + self.env['stock.move.line'].create(mo.get_move_line(self.production_id, self)) # move_out._action_assign() if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress': @@ -1315,11 +1319,11 @@ class ResMrpWorkOrder(models.Model): def button_finish(self): for record in self: if record.routing_type == '装夹预调': - if not record.rfid_code and record.is_rework is False: - raise UserError("请扫RFID码进行绑定") - if record.is_rework is False: - if not record.material_center_point: - raise UserError("坯料中心点为空,请检查") + # if not record.rfid_code and record.is_rework is False: + # raise UserError("请扫RFID码进行绑定") + # if record.is_rework is False: + # if not record.material_center_point: + # raise UserError("坯料中心点为空,请检查") # if record.X_deviation_angle <= 0: # raise UserError("X偏差角度小于等于0,请检查!本次计算的X偏差角度为:%s" % record.X_deviation_angle) record.process_state = '待加工' diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 6e211f09..fd0168fb 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError from odoo.modules import get_resource_path -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 853634f7..1f540131 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -290,7 +290,7 @@ class StockRule(models.Model): else: mrp_production = production # if sale_order: - # sale_order.write({'schedule_status': 'to schedule'}) + # sale_order.write({'schedule_status': 'to schedule'}) self.env['sf.production.plan'].sudo().with_company(company_id).create({ 'name': production.name, 'order_deadline': sale_order.deadline_of_delivery, @@ -301,7 +301,6 @@ class StockRule(models.Model): 'product_id': production.product_id.id, 'state': 'draft', }) - technology_design_values = [] all_production = productions grouped_product_ids = {k: list(g) for k, g in groupby(all_production, key=lambda x: x.product_id.id)} # 初始化一个字典来存储每个product_id对应的生产订单名称列表 @@ -311,6 +310,7 @@ class StockRule(models.Model): # 为同一个product_id创建一个生产订单名称列表 product_id_to_production_names[product_id] = [production.name for production in all_production] for production_item in productions: + technology_design_values = [] production_programming = self.env['mrp.production'].search( [('product_id.id', '=', production_item.product_id.id), ('origin', '=', production_item.origin)], @@ -325,70 +325,69 @@ class StockRule(models.Model): else: production_item.write({'programming_no': production_programming.programming_no, 'programming_state': '编程中'}) - if not technology_design_values: - i = 0 - if production_item.product_id.categ_id.type == '成品': - # 根据加工面板的面数及成品工序模板生成工序设计 - if production_item.production_type == '自动化产线加工': - model = 'sf.product.model.type.routing.sort' - domain = [ - ('product_model_type_id', '=', production_item.product_id.product_model_type_id.id)] - else: - model = 'sf.manual.product.model.type.routing.sort' - domain = [('manual_product_model_type_id', '=', - production_item.product_id.product_model_type_id.id)] - product_routing_workcenter = self.env[model].search(domain, order='sequence asc') - if production_item.production_type == '自动化产线加工': - for k in (production_item.product_id.model_processing_panel.split(',')): - for route in product_routing_workcenter: - i += 1 - technology_design_values.append( - self.env['sf.technology.design'].json_technology_design_str(k, route, i, False)) - else: + i = 0 + if production_item.product_id.categ_id.type == '成品': + # 根据加工面板的面数及成品工序模板生成工序设计 + if production_item.production_type == '自动化产线加工': + model = 'sf.product.model.type.routing.sort' + domain = [ + ('product_model_type_id', '=', production_item.product_id.product_model_type_id.id)] + else: + model = 'sf.manual.product.model.type.routing.sort' + domain = [('manual_product_model_type_id', '=', + production_item.product_id.product_model_type_id.id)] + product_routing_workcenter = self.env[model].search(domain, order='sequence asc') + if production_item.production_type == '自动化产线加工': + for k in (production_item.product_id.model_processing_panel.split(',')): for route in product_routing_workcenter: i += 1 technology_design_values.append( - self.env['sf.technology.design'].json_technology_design_str(False, route, i, False)) - elif production_item.product_id.categ_id.type == '坯料': - embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search( - [('embryo_model_type_id', '=', production_item.product_id.embryo_model_type_id.id)], - order='sequence asc' - ) - for route_embryo in embryo_routing_workcenter: + self.env['sf.technology.design'].json_technology_design_str(k, route, i, False)) + else: + for route in product_routing_workcenter: i += 1 technology_design_values.append( - self.env['sf.technology.design'].json_technology_design_str(False, route_embryo, i, - False)) - surface_technics_arr = [] - route_workcenter_arr = [] - for item in production_item.product_id.product_model_type_id.surface_technics_routing_tmpl_ids: - if item.route_workcenter_id.surface_technics_id.id: - for process_param in production_item.product_id.model_process_parameters_ids: - if item.route_workcenter_id.surface_technics_id == process_param.process_id: - surface_technics_arr.append( - item.route_workcenter_id.surface_technics_id.id) - route_workcenter_arr.append(item.route_workcenter_id.id) - if surface_technics_arr: - production_process = self.env['sf.production.process'].search( - [('id', 'in', surface_technics_arr)], - order='sequence asc' - ) - for p in production_process: - logging.info('production_process:%s' % p.name) - process_parameter = production_item.product_id.model_process_parameters_ids.filtered( - lambda pm: pm.process_id.id == p.id) - if process_parameter: - i += 1 - route_production_process = self.env[ - 'mrp.routing.workcenter'].search( - [('surface_technics_id', '=', p.id), - ('id', 'in', route_workcenter_arr)]) - technology_design_values.append( - self.env['sf.technology.design'].json_technology_design_str(False, - route_production_process, - i, - process_parameter)) - productions.technology_design_ids = technology_design_values + self.env['sf.technology.design'].json_technology_design_str(False, route, i, False)) + elif production_item.product_id.categ_id.type == '坯料': + embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search( + [('embryo_model_type_id', '=', production_item.product_id.embryo_model_type_id.id)], + order='sequence asc' + ) + for route_embryo in embryo_routing_workcenter: + i += 1 + technology_design_values.append( + self.env['sf.technology.design'].json_technology_design_str(False, route_embryo, i, + False)) + surface_technics_arr = [] + route_workcenter_arr = [] + for item in production_item.product_id.product_model_type_id.surface_technics_routing_tmpl_ids: + if item.route_workcenter_id.surface_technics_id.id: + for process_param in production_item.product_id.model_process_parameters_ids: + if item.route_workcenter_id.surface_technics_id == process_param.process_id: + surface_technics_arr.append( + item.route_workcenter_id.surface_technics_id.id) + route_workcenter_arr.append(item.route_workcenter_id.id) + if surface_technics_arr: + production_process = self.env['sf.production.process'].search( + [('id', 'in', surface_technics_arr)], + order='sequence asc' + ) + for p in production_process: + logging.info('production_process:%s' % p.name) + process_parameter = production_item.product_id.model_process_parameters_ids.filtered( + lambda pm: pm.process_id.id == p.id) + if process_parameter: + i += 1 + route_production_process = self.env[ + 'mrp.routing.workcenter'].search( + [('surface_technics_id', '=', p.id), + ('id', 'in', route_workcenter_arr)]) + technology_design_values.append( + self.env['sf.technology.design'].json_technology_design_str(False, + route_production_process, + i, + process_parameter)) + production_item.technology_design_ids = technology_design_values productions.write({'state': 'technology_to_confirmed'}) return True @@ -634,39 +633,24 @@ class StockPicking(models.Model): return '%s%s' % (rescode, num) def button_validate(self): - if self.picking_type_id.barcode == 'OCOUT': - move_out = self.env['stock.move'].search( - [('location_id', '=', self.env['stock.location'].search( - [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id), - ('location_dest_id', '=', self.env['stock.location'].search( - [('barcode', 'ilike', 'VL-SPOC')]).id), - ('origin', '=', self.origin)]) + res = super().button_validate() + if res is True and self.picking_type_id.sequence_code == 'OCOUT': + # if self.id == move_out.picking_id.id: + # if move_out.move_line_ids.workorder_id.state == 'progress': move_in = self.env['stock.move'].search( [('location_dest_id', '=', self.env['stock.location'].search( [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id), ('location_id', '=', self.env['stock.location'].search( [('barcode', 'ilike', 'VL-SPOC')]).id), - ('origin', '=', self.origin), ('picking_id', '=', self.id)]) - if self.location_id == move_in.location_id and self.location_dest_id == move_in.location_dest_id: - if move_out.origin == move_in.origin: - move_in.write({'production_id': False}) - if move_out.picking_id.state != 'done': - raise UserError( - _('该入库单对应的单号为%s的出库单还未完成,不能进行验证操作!' % move_out.picking_id.name)) - res = super().button_validate() - if res is True and self.picking_type_id.barcode == 'OCIN': - if self.id == move_out.picking_id.id: - # if move_out.move_line_ids.workorder_id.state == 'progress': - move_in = self.env['stock.move'].search( - [('location_dest_id', '=', self.env['stock.location'].search( - [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id), - ('location_id', '=', self.env['stock.location'].search( - [('barcode', 'ilike', 'VL-SPOC')]).id), - ('origin', '=', self.origin)]) - production = self.env['mrp.production'].search([('name', '=', self.origin)]) - if move_in.state != 'done': - move_in.write({'state': 'assigned'}) - self.env['stock.move.line'].create(move_in.get_move_line(production, None)) + ('origin', '=', self.origin), ('state', 'not in', ['cancel', 'done'])]) + production = self.env['mrp.production'].search([('name', '=', self.origin)]) + for mi in move_in: + pick = self.env['stock.picking'].search([('id', '=', mi.picking_id.id), ('name', 'ilike', 'OCIN'), + ('partner_id', '=', self.partner_id.id)]) + if pick: + if mi.state != 'done': + mi.write({'state': 'assigned'}) + self.env['stock.move.line'].create(mi.get_move_line(production, None)) return res diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py index 89ba95d0..6d7e438f 100644 --- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py +++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py @@ -83,7 +83,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): workorder.picking_ids.write({'state': 'cancel'}) workorder.picking_ids.move_ids.write({'state': 'cancel'}) purchase_order = self.env['purchase.order'].search( - [('origin', '=', workorder.production_id.origin)]) + [('origin', '=', workorder.production_id.name)]) for line in purchase_order.order_line: if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id: purchase_order.write({'state': 'cancel'}) diff --git a/sf_manufacturing/wizard/production_technology_wizard.py b/sf_manufacturing/wizard/production_technology_wizard.py index d81a89a0..a02bb8f6 100644 --- a/sf_manufacturing/wizard/production_technology_wizard.py +++ b/sf_manufacturing/wizard/production_technology_wizard.py @@ -80,7 +80,7 @@ class ProductionTechnologyWizard(models.TransientModel): workorder.picking_ids.write({'state': 'cancel'}) workorder.picking_ids.move_ids.write({'state': 'cancel'}) purchase_order = self.env['purchase.order'].search( - [('origin', '=', workorder.production_id.origin)]) + [('origin', '=', workorder.production_id.name)]) for line in purchase_order.order_line: if line.product_id.server_product_process_parameters_id == workorder.surface_technics_parameters_id: purchase_order.write({'state': 'cancel'}) diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index 87aee0dd..a5f76710 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -40,21 +40,21 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController): return json.JSONEncoder().encode(res) if productions: # 拉取所有加工面的程序文件 - for r in ret['processing_panel'].split(','): - program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) - if os.path.exists(program_path_tmp_r): - files_r = os.listdir(program_path_tmp_r) - if files_r: - for file_name in files_r: - file_path = os.path.join(program_path_tmp_r, file_name) - os.remove(file_path) - download_state = request.env['sf.cnc.processing'].with_user( - request.env.ref("base.user_admin")).download_file_tmp( - ret['folder_name'], r) - if download_state is False: - res['status'] = -2 - res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) - return json.JSONEncoder().encode(res) + # for r in ret['processing_panel'].split(','): + # program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) + # if os.path.exists(program_path_tmp_r): + # files_r = os.listdir(program_path_tmp_r) + # if files_r: + # for file_name in files_r: + # file_path = os.path.join(program_path_tmp_r, file_name) + # os.remove(file_path) + # download_state = request.env['sf.cnc.processing'].with_user( + # request.env.ref("base.user_admin")).download_file_tmp( + # ret['folder_name'], r) + # if download_state is False: + # res['status'] = -2 + # res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) + # return json.JSONEncoder().encode(res) for production in productions: production.write({'programming_state': '已编程', 'work_state': '已编程'}) for panel in ret['processing_panel'].split(','): @@ -72,29 +72,29 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController): cnc_workorder_has.write( {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret), 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)}) - for panel in ret['processing_panel'].split(','): - # 查询状态为进行中且工序类型为CNC加工的工单 - cnc_workorder = productions.workorder_ids.filtered( - lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework' - 'cancel'] and ac.processing_panel == panel) - if cnc_workorder: - # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', - # panel) - program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) - files_panel = os.listdir(program_path_tmp_panel) - if files_panel: - for file in files_panel: - file_extension = os.path.splitext(file)[1] - if file_extension.lower() == '.pdf': - panel_file_path = os.path.join(program_path_tmp_panel, file) - logging.info('panel_file_path:%s' % panel_file_path) - cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) - pre_workorder = productions.workorder_ids.filtered( - lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework' - 'cancel'] and ap.processing_panel == panel) - if pre_workorder: - pre_workorder.write( - {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) + # for panel in ret['processing_panel'].split(','): + # # 查询状态为进行中且工序类型为CNC加工的工单 + # cnc_workorder = productions.workorder_ids.filtered( + # lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework' + # 'cancel'] and ac.processing_panel == panel) + # if cnc_workorder: + # # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', + # # panel) + # program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) + # files_panel = os.listdir(program_path_tmp_panel) + # if files_panel: + # for file in files_panel: + # file_extension = os.path.splitext(file)[1] + # if file_extension.lower() == '.pdf': + # panel_file_path = os.path.join(program_path_tmp_panel, file) + # logging.info('panel_file_path:%s' % panel_file_path) + # cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) + # pre_workorder = productions.workorder_ids.filtered( + # lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework' + # 'cancel'] and ap.processing_panel == panel) + # if pre_workorder: + # pre_workorder.write( + # {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) productions.write({'programming_state': '已编程', 'work_state': '已编程'}) logging.info('已更新制造订单编程状态:%s' % productions.ids) res.update({ diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index 081807a4..cb1886a1 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -8,8 +8,8 @@ from datetime import datetime import requests from odoo import http from odoo.http import request -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file from odoo import models, fields, api from odoo.modules import get_resource_path from odoo.exceptions import ValidationError, UserError diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index 87848e3a..d963d021 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -5,8 +5,8 @@ import requests import os from datetime import datetime # from OCC.Core.GProp import GProp_GProps -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file from odoo.addons.sf_base.commons.common import Common from odoo import models, fields, api from odoo.modules import get_resource_path From 20cfbf7230fb5abeb7018ea71a5f0787095c1688 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 28 Nov 2024 17:50:12 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E5=A4=84=E7=90=86=20=20=E5=9D=AF?= =?UTF-8?q?=E6=96=99=E7=9A=84=E5=88=B6=E9=80=A0=E8=AE=A2=E5=8D=95=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=9A=84=E6=89=B9=E6=AC=A1=E5=BA=8F=E5=88=97=E5=8F=B7?= =?UTF-8?q?=E4=B8=8D=E5=AF=B9=20=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/stock.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 4162ed68..b8cb237a 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -424,6 +424,8 @@ class ProductionLot(models.Model): """Generate `lot_names` from a string.""" if first_lot.__contains__(display_name): first_lot = first_lot[(len(display_name) + 1):] + else: + first_lot = first_lot[-3:] # We look if the first lot contains at least one digit. caught_initial_number = regex_findall(r"\d+", first_lot) From deb2f6ca6464f32ee13a335ab6b0415295bc6768 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 28 Nov 2024 18:01:29 +0800 Subject: [PATCH 11/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=87=E8=B4=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 29 +++++++++++++---------- sf_sale/models/sale_order.py | 9 ++++--- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 65be98c7..9156dc38 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -309,7 +309,8 @@ class MrpProduction(models.Model): for move in production.move_raw_ids if move.product_id): production.state = 'progress' # 新添加的状态逻辑 - if production.state in ['to_close', 'progress', 'technology_to_confirmed'] and production.schedule_state == '未排': + if production.state in ['to_close', 'progress', + 'technology_to_confirmed'] and production.schedule_state == '未排': if not production.workorder_ids or production.is_adjust is True: production.state = 'technology_to_confirmed' else: @@ -356,7 +357,6 @@ class MrpProduction(models.Model): if production.tool_state == '2': production.state = 'rework' - # 退回调整 def technology_back_adjust(self): process_parameters = [] @@ -849,15 +849,20 @@ class MrpProduction(models.Model): purchase_order = self.env['purchase.order'].search( [('state', '=', 'draft'), ('origin', '=', item.name), ('purchase_type', '=', 'consignment')]) - for line in purchase_order.order_line: - server_template = self.env['product.template'].search( - [('server_product_process_parameters_id', '=', workorder.surface_technics_parameters_id.id), - ('detailed_type', '=', 'service')]) - purchase_order_line = self.env['purchase.order.line'].search( - [('product_id', '=', server_template.product_variant_id.id), ('id', '=', line.id), - ('product_qty', '=', 1)], limit=1, order='id desc') - if purchase_order_line: - line.unlink() + server_template = self.env['product.template'].search( + [('server_product_process_parameters_id', '=', + workorder.surface_technics_parameters_id.id), + ('detailed_type', '=', 'service')]) + for po in purchase_order: + for line in po.order_line: + if line.product_id == server_template.product_variant_id: + continue + if server_template.server_product_process_parameters_id != line.product_id.server_product_process_parameters_id: + purchase_order_line = self.env['purchase.order.line'].search( + [('product_id', '=', server_template.product_variant_id.id), ('id', '=', line.id), + ('product_qty', '=', 1)], limit=1, order='id desc') + if purchase_order_line: + line.unlink() def _reset_work_order_sequence(self): """ @@ -898,8 +903,6 @@ class MrpProduction(models.Model): for cw in cancel_work_ids: cw.sequence = sequence + 1 - - def _reset_work_order_sequence_1(self): """ 工单工序排序方法(旧) diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index 9c0e0b09..e225c274 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -265,17 +265,20 @@ class RePurchaseOrder(models.Model): })) for purchase in purchase_order: for po in purchase.order_line: - if server_template.server_product_process_parameters_id == pp.surface_technics_parameters_id: + if po.product_id == server_template.product_variant_id: + continue + if server_template.server_product_process_parameters_id != po.product_id.server_product_process_parameters_id: purchase_order_line = self.env['purchase.order.line'].search( [('product_id', '=', server_template.product_variant_id.id), - ('product_qty', '=', 1.0), ('id', '=', po.id)], limit=1, + ('product_qty', '=', 1.0), ('id', '=', purchase.id)], limit=1, order='id desc') - if not purchase_order_line and purchase not in purchase_order: + if not purchase_order_line: server_product_process.append((0, 0, { 'product_id': server_template.product_variant_id.id, 'product_qty': 1, 'product_uom': server_template.uom_id.id })) + if server_product_process: self.env['purchase.order'].sudo().create({ 'partner_id': server_template.seller_ids[0].partner_id.id, From 9a9e47b4ff6bd3fad1d06a19ec25ee322bf7c444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Fri, 29 Nov 2024 08:59:52 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=B2=BE=E5=9D=AF?= =?UTF-8?q?=E6=96=99=E8=AE=A1=E7=AE=97=E7=B2=BE=E5=BA=A6=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=8C=E6=8E=92=E7=A8=8B=E5=8A=A0=E4=B8=8A=E9=A2=84=E7=95=99?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 24 ++++++++++++++++----- sf_plan/models/custom_plan.py | 16 +++++++------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 6e211f09..fb6f92ce 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -859,12 +859,12 @@ class ResProductMo(models.Model): raise UserError('请先配置模型类型内的坯料冗余') vals = { 'name': '%s-%s-%s' % ('P', order_id.name, i), - 'model_long': item['model_long'] + embryo_redundancy_id.long, - 'model_width': item['model_width'] + embryo_redundancy_id.width, - 'model_height': item['model_height'] + embryo_redundancy_id.height, - 'model_volume': (item['model_long'] + embryo_redundancy_id.long) * ( + 'model_long': self.format_float(item['model_long'] + embryo_redundancy_id.long), + 'model_width': self.format_float(item['model_width'] + embryo_redundancy_id.width), + 'model_height': self.format_float(item['model_height'] + embryo_redundancy_id.height), + 'model_volume': self.format_float((item['model_long'] + embryo_redundancy_id.long) * ( item['model_width'] + embryo_redundancy_id.width) * ( - item['model_height'] + embryo_redundancy_id.height), + item['model_height'] + embryo_redundancy_id.height)), 'product_model_type_id': model_type.id, 'model_processing_panel': item['processing_panel_detail'], 'model_machining_precision': item['model_machining_precision'], @@ -907,6 +907,20 @@ class ResProductMo(models.Model): self.attachment_update(item['quality_standard_name'], copy_product_id.product_tmpl_id.id, 'quality_standard', item['quality_standard_mimetype']) return copy_product_id + + def format_float(self, value): + # 将浮点数转换为字符串 + value_str = str(value) + # 检查小数点的位置 + if '.' in value_str: + # 获取小数部分 + decimal_part = value_str.split('.')[1] + # 判断小数位数是否超过2位 + if len(decimal_part) > 2: + # 超过2位则保留2位小数 + return "{:.2f}".format(value) + # 否则保持原来的位数 + return float(value_str) def _get_ids(self, param): type_ids = [] diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index 147caa96..6ee1d3ee 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -242,10 +242,10 @@ class sf_production_plan(models.Model): # 设置一个小的开始时间 first_cnc_workorder.date_planned_start = datetime.now() - timedelta(days=100) first_cnc_workorder.date_planned_finished = date_start + timedelta( - minutes=routing_workcenter.time_cycle) + minutes=routing_workcenter.time_cycle + routing_workcenter.reserved_duration) first_cnc_workorder.date_planned_start = date_start record.sudo().production_id.plan_start_processing_time = first_cnc_workorder.date_planned_start - first_cnc_workorder.duration_expected = routing_workcenter.time_cycle + first_cnc_workorder.duration_expected = routing_workcenter.time_cycle + routing_workcenter.reserved_duration record.calculate_plan_time(first_cnc_workorder, record.production_id.workorder_ids) # 找到最后一张CNC加工工单 last_cnc_workorder = record.production_id.workorder_ids.filtered(lambda x: x.name == 'CNC加工')[-1] @@ -257,10 +257,10 @@ class sf_production_plan(models.Model): routing_workcenter = item.technology_design_id.route_id item.date_planned_start = datetime.now() - timedelta(days=100) item.date_planned_finished = wo_start + timedelta( - minutes=routing_workcenter.time_cycle) + minutes=routing_workcenter.time_cycle + routing_workcenter.reserved_duration) item.date_planned_start = wo_start record.sudo().production_id.plan_start_processing_time = item.date_planned_start - item.duration_expected = routing_workcenter.time_cycle + item.duration_expected = routing_workcenter.time_cycle + routing_workcenter.reserved_duration record.calculate_plan_time(item, record.production_id.workorder_ids) last_cnc_workorder = record.production_id.workorder_ids[-1] record.date_planned_finished = last_cnc_workorder.date_planned_finished @@ -338,8 +338,8 @@ class sf_production_plan(models.Model): next_workorder.date_planned_start = datetime.now() - timedelta(days=100) next_workorder.date_planned_finished = current_workorder.date_planned_start next_workorder.date_planned_start = next_workorder.date_planned_finished - timedelta( - minutes=routing_workcenter.time_cycle) - next_workorder.duration_expected = routing_workcenter.time_cycle + minutes=routing_workcenter.time_cycle + routing_workcenter.reserved_duration) + next_workorder.duration_expected = routing_workcenter.time_cycle + routing_workcenter.reserved_duration for i in range(item_position, len(workorder_list) - 1): if i > len(workorder_list) - 1: @@ -350,9 +350,9 @@ class sf_production_plan(models.Model): # 设置一个小的开始时间 next_workorder.date_planned_start = datetime.now() - timedelta(days=100) next_workorder.date_planned_finished = current_workorder.date_planned_finished + timedelta( - minutes=routing_workcenter.time_cycle) + minutes=routing_workcenter.time_cycle + routing_workcenter.reserved_duration) next_workorder.date_planned_start = current_workorder.date_planned_finished - next_workorder.duration_expected = routing_workcenter.time_cycle + next_workorder.duration_expected = routing_workcenter.time_cycle + routing_workcenter.reserved_duration def calculate_plan_time_after(self, item, workorder_id_list): """ From db8bd659c3762e341657871fbe5ae4ca23dc2a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Fri, 29 Nov 2024 09:45:06 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=B7=A5=E8=89=BA=E5=A4=96=E5=8D=8F=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=82=B9=E5=87=BB=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/views/stock_picking_view.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sf_manufacturing/views/stock_picking_view.xml b/sf_manufacturing/views/stock_picking_view.xml index 2fae1fac..30264f89 100644 --- a/sf_manufacturing/views/stock_picking_view.xml +++ b/sf_manufacturing/views/stock_picking_view.xml @@ -51,5 +51,10 @@ + + + + \ No newline at end of file From a7dc3a122700e854cf155a4226f065a4ddb6fee7 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 29 Nov 2024 10:03:44 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E9=9D=A2?= =?UTF-8?q?=E5=A4=96=E5=8D=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 4 ++-- .../wizard/production_technology_re_adjust_wizard.py | 1 + sf_sale/models/quick_easy_order.py | 4 ++-- sf_sale/models/quick_easy_order_old.py | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index fd0168fb..6e211f09 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError, UserError from odoo.modules import get_resource_path -# from OCC.Extend.DataExchange import read_step_file -# from OCC.Extend.DataExchange import write_stl_file +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): diff --git a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py index 6d7e438f..80a02b2b 100644 --- a/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py +++ b/sf_manufacturing/wizard/production_technology_re_adjust_wizard.py @@ -104,6 +104,7 @@ class ProductionTechnologyReAdjustWizard(models.TransientModel): self.env['mrp.workorder'].json_workorder_str(special.production_id, special)) special.production_id.write({'workorder_ids': workorders_values}) else: + logging.info(workorder.blocked_by_workorder_ids) if len(workorder.blocked_by_workorder_ids) > 1: if workorder.sequence == 1: workorder.blocked_by_workorder_ids = None diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index cb1886a1..081807a4 100644 --- a/sf_sale/models/quick_easy_order.py +++ b/sf_sale/models/quick_easy_order.py @@ -8,8 +8,8 @@ from datetime import datetime import requests from odoo import http from odoo.http import request -# from OCC.Extend.DataExchange import read_step_file -# from OCC.Extend.DataExchange import write_stl_file +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file from odoo import models, fields, api from odoo.modules import get_resource_path from odoo.exceptions import ValidationError, UserError diff --git a/sf_sale/models/quick_easy_order_old.py b/sf_sale/models/quick_easy_order_old.py index d963d021..87848e3a 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -5,8 +5,8 @@ import requests import os from datetime import datetime # from OCC.Core.GProp import GProp_GProps -# from OCC.Extend.DataExchange import read_step_file -# from OCC.Extend.DataExchange import write_stl_file +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file from odoo.addons.sf_base.commons.common import Common from odoo import models, fields, api from odoo.modules import get_resource_path From 9955157dd3dbdf016d6d72cbea82914fdee79c6e Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 29 Nov 2024 10:07:17 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 40 ++++++------ sf_mrs_connect/controllers/controllers.py | 76 +++++++++++------------ 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index d4d97a2e..7bd9d1c8 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1203,21 +1203,21 @@ class ResMrpWorkOrder(models.Model): if self.sequence == 1: # 判断工单状态是否为等待组件 - # if self.state == 'waiting': - # raise UserError('制造订单【%s】缺少组件信息!' % self.production_id.name) - # # 判断是否有坯料的序列号信息 - # boolean = False - # if self.production_id.move_raw_ids: - # if self.production_id.move_raw_ids[0].product_id.categ_type == '坯料': - # if self.production_id.move_raw_ids[0].move_line_ids: - # if self.production_id.move_raw_ids[0].move_line_ids: - # if self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name: - # boolean = True - # else: - # boolean = True - # if not boolean: - # raise UserError('制造订单【%s】缺少组件的序列号信息!' % self.production_id.name) - # self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name + if self.state == 'waiting': + raise UserError('制造订单【%s】缺少组件信息!' % self.production_id.name) + # 判断是否有坯料的序列号信息 + boolean = False + if self.production_id.move_raw_ids: + if self.production_id.move_raw_ids[0].product_id.categ_type == '坯料': + if self.production_id.move_raw_ids[0].move_line_ids: + if self.production_id.move_raw_ids[0].move_line_ids: + if self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name: + boolean = True + else: + boolean = True + if not boolean: + raise UserError('制造订单【%s】缺少组件的序列号信息!' % self.production_id.name) + self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name # cnc校验 if self.production_id.production_type == '自动化产线加工': cnc_workorder = self.search( @@ -1318,11 +1318,11 @@ class ResMrpWorkOrder(models.Model): def button_finish(self): for record in self: if record.routing_type == '装夹预调': - # if not record.rfid_code and record.is_rework is False: - # raise UserError("请扫RFID码进行绑定") - # if record.is_rework is False: - # if not record.material_center_point: - # raise UserError("坯料中心点为空,请检查") + if not record.rfid_code and record.is_rework is False: + raise UserError("请扫RFID码进行绑定") + if record.is_rework is False: + if not record.material_center_point: + raise UserError("坯料中心点为空,请检查") # if record.X_deviation_angle <= 0: # raise UserError("X偏差角度小于等于0,请检查!本次计算的X偏差角度为:%s" % record.X_deviation_angle) record.process_state = '待加工' diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index a5f76710..87aee0dd 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -40,21 +40,21 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController): return json.JSONEncoder().encode(res) if productions: # 拉取所有加工面的程序文件 - # for r in ret['processing_panel'].split(','): - # program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) - # if os.path.exists(program_path_tmp_r): - # files_r = os.listdir(program_path_tmp_r) - # if files_r: - # for file_name in files_r: - # file_path = os.path.join(program_path_tmp_r, file_name) - # os.remove(file_path) - # download_state = request.env['sf.cnc.processing'].with_user( - # request.env.ref("base.user_admin")).download_file_tmp( - # ret['folder_name'], r) - # if download_state is False: - # res['status'] = -2 - # res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) - # return json.JSONEncoder().encode(res) + for r in ret['processing_panel'].split(','): + program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) + if os.path.exists(program_path_tmp_r): + files_r = os.listdir(program_path_tmp_r) + if files_r: + for file_name in files_r: + file_path = os.path.join(program_path_tmp_r, file_name) + os.remove(file_path) + download_state = request.env['sf.cnc.processing'].with_user( + request.env.ref("base.user_admin")).download_file_tmp( + ret['folder_name'], r) + if download_state is False: + res['status'] = -2 + res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) + return json.JSONEncoder().encode(res) for production in productions: production.write({'programming_state': '已编程', 'work_state': '已编程'}) for panel in ret['processing_panel'].split(','): @@ -72,29 +72,29 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController): cnc_workorder_has.write( {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret), 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)}) - # for panel in ret['processing_panel'].split(','): - # # 查询状态为进行中且工序类型为CNC加工的工单 - # cnc_workorder = productions.workorder_ids.filtered( - # lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework' - # 'cancel'] and ac.processing_panel == panel) - # if cnc_workorder: - # # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', - # # panel) - # program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) - # files_panel = os.listdir(program_path_tmp_panel) - # if files_panel: - # for file in files_panel: - # file_extension = os.path.splitext(file)[1] - # if file_extension.lower() == '.pdf': - # panel_file_path = os.path.join(program_path_tmp_panel, file) - # logging.info('panel_file_path:%s' % panel_file_path) - # cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) - # pre_workorder = productions.workorder_ids.filtered( - # lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework' - # 'cancel'] and ap.processing_panel == panel) - # if pre_workorder: - # pre_workorder.write( - # {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) + for panel in ret['processing_panel'].split(','): + # 查询状态为进行中且工序类型为CNC加工的工单 + cnc_workorder = productions.workorder_ids.filtered( + lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework' + 'cancel'] and ac.processing_panel == panel) + if cnc_workorder: + # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test', + # panel) + program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel) + files_panel = os.listdir(program_path_tmp_panel) + if files_panel: + for file in files_panel: + file_extension = os.path.splitext(file)[1] + if file_extension.lower() == '.pdf': + panel_file_path = os.path.join(program_path_tmp_panel, file) + logging.info('panel_file_path:%s' % panel_file_path) + cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())}) + pre_workorder = productions.workorder_ids.filtered( + lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework' + 'cancel'] and ap.processing_panel == panel) + if pre_workorder: + pre_workorder.write( + {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) productions.write({'programming_state': '已编程', 'work_state': '已编程'}) logging.info('已更新制造订单编程状态:%s' % productions.ids) res.update({ From a927d0e9cbbd8eb0aba82323465f760de71a92f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Fri, 29 Nov 2024 10:44:48 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8D=95=E4=B8=AA?= =?UTF-8?q?=E5=88=B6=E9=80=A0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_sale_multiple_supply_methods/models/sale_order.py | 2 ++ sf_manufacturing/models/product_template.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/jikimo_sale_multiple_supply_methods/models/sale_order.py b/jikimo_sale_multiple_supply_methods/models/sale_order.py index b7e25835..a56721a2 100644 --- a/jikimo_sale_multiple_supply_methods/models/sale_order.py +++ b/jikimo_sale_multiple_supply_methods/models/sale_order.py @@ -43,6 +43,8 @@ class SaleOrder(models.Model): # 复制成品模板上的属性 line.product_id.product_tmpl_id.copy_template(product_template_id) + # 将模板上的single_manufacturing属性复制到成品上 + line.product_id.single_manufacturing = product_template_id.single_manufacturing order_id = self product = line.product_id diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index fb6f92ce..460fd994 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -884,7 +884,7 @@ class ResProductMo(models.Model): 'model_process_parameters_ids': [(6, 0, [])] if not item.get( 'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']), 'model_remark': item['remark'], - 'single_manufacturing': False, + 'single_manufacturing': True, 'default_code': '%s-%s' % (order_number, i), 'manual_quotation': item['manual_quotation'] or False, 'part_number': item.get('part_number') or '',