From 5a60eed5b19dd2c44c86007493a6dce2d3d5d24c Mon Sep 17 00:00:00 2001 From: hujiaying Date: Wed, 14 Aug 2024 12:48:40 +0800 Subject: [PATCH 01/25] =?UTF-8?q?=E8=81=94=E8=B0=83=E5=8A=A0=E5=B7=A5?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E4=BB=8E=E5=BE=85=E7=A1=AE=E8=AE=A4=E5=88=B0?= =?UTF-8?q?=E5=8A=A0=E5=B7=A5=E4=B8=AD=EF=BC=8C=E7=BB=8F=E8=BF=87=E7=9A=84?= =?UTF-8?q?=E5=86=85=E9=83=A8=E7=AE=A1=E7=90=86=E7=B3=BB=E7=BB=9F=EF=BC=8C?= =?UTF-8?q?bfm,sf=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E8=81=94=E8=B0=83?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=AF=B9=E5=BA=94=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0=E5=80=BC=E6=94=B9=E5=8F=98=E3=80=82?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A2=E5=8D=95=E5=8A=A0=E5=B7=A5=E4=B8=AD?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=88=B0=E5=86=85=E9=83=A8=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=A4=B1=E8=B4=A5=EF=BC=8C=E5=88=99=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=88=B0=E5=90=8C=E6=AD=A5=E8=A1=A8=EF=BC=8C=E7=94=B1?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=A1=A8=E5=AE=9A=E6=97=B6=E5=8F=91=E8=B5=B7?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=87=8D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_bf_connect/models/process_status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sf_bf_connect/models/process_status.py b/sf_bf_connect/models/process_status.py index 9c939edd..d0657a83 100644 --- a/sf_bf_connect/models/process_status.py +++ b/sf_bf_connect/models/process_status.py @@ -31,7 +31,7 @@ class StatusChange(models.Model): res = super(StatusChange, self).action_confirm() # 原有方法执行后,进行额外的操作(如调用外部API) - process_start_time = str(datetime.now()) + process_start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') config = self.env['res.config.settings'].get_values() json1 = { 'params': { From 7fee98cdee64f599f8a4d46c07135eeb782c8486 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 23 Aug 2024 16:13:03 +0800 Subject: [PATCH 02/25] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=A5=E5=BA=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 4 ++-- sf_manufacturing/models/stock.py | 25 +++++++++++---------- sf_sale/models/quick_easy_order.py | 4 ++-- sf_sale/models/quick_easy_order_old.py | 4 ++-- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 071f1167..37fa02bd 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 f53d7056..a6aa3e96 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -151,6 +151,8 @@ class StockRule(models.Model): list2.append(item) for procurement, rule in list2: + logging.info(rule) + logging.info(rule.procure_method) procure_method = rule.procure_method if rule.procure_method == 'mts_else_mto': qty_needed = procurement.product_uom._compute_quantity(procurement.product_qty, @@ -169,7 +171,6 @@ class StockRule(models.Model): else: forecasted_qties_by_loc[rule.location_src_id][procurement.product_id.id] -= qty_needed procure_method = 'make_to_stock' - move_values = rule._get_stock_move_values(*procurement) move_values['procure_method'] = procure_method moves_values_by_company[procurement.company_id.id].append(move_values) @@ -350,17 +351,17 @@ class StockRule(models.Model): product_id_to_production_names) # # 同一个产品多个制造订单对应一个编程单和模型库 # # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递 - if not production_item.programming_no: - production_programming = self.env['mrp.production'].search( - [('product_id.id', '=', production_item.product_id.id), - ('origin', '=', production_item.origin)], - limit=1, order='id asc') - if not production_programming.programming_no: - production_item.fetchCNC( - ', '.join(product_id_to_production_names[production_item.product_id.id])) - else: - production_item.write({'programming_no': production_programming.programming_no, - 'programming_state': '编程中'}) + # if not production_item.programming_no: + # production_programming = self.env['mrp.production'].search( + # [('product_id.id', '=', production_item.product_id.id), + # ('origin', '=', production_item.origin)], + # limit=1, order='id asc') + # if not production_programming.programming_no: + # production_item.fetchCNC( + # ', '.join(product_id_to_production_names[production_item.product_id.id])) + # else: + # production_item.write({'programming_no': production_programming.programming_no, + # 'programming_state': '编程中'}) return True 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 3ae65db3..92f6cda2 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -6,8 +6,8 @@ import os from datetime import datetime from stl import mesh # 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 9218633a5ef828d7a8cf0b9873f5e42274f39b4a Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 23 Aug 2024 17:32:35 +0800 Subject: [PATCH 03/25] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A1=A8=E9=9D=A2?= =?UTF-8?q?=E5=B7=A5=E8=89=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/__manifest__.py | 2 +- sf_base/models/common.py | 1 + sf_base/models/tool_base_new.py.rej | 10 --- sf_manufacturing/models/mrp_production.py | 17 ++-- sf_manufacturing/models/product_template.py | 4 +- sf_mrs_connect/controllers/controllers.py | 96 ++++++++++----------- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- sf_sale/models/sale_order.py | 1 + 9 files changed, 64 insertions(+), 75 deletions(-) delete mode 100644 sf_base/models/tool_base_new.py.rej diff --git a/sf_base/__manifest__.py b/sf_base/__manifest__.py index b10c2630..3c5175f0 100644 --- a/sf_base/__manifest__.py +++ b/sf_base/__manifest__.py @@ -23,7 +23,7 @@ 'views/tool_basic_param.xml', 'views/tool_menu.xml', 'views/menu_fixture_view.xml', - 'views/change_base_view.xml', + # 'views/change_base_view.xml', 'views/Printer.xml', ], diff --git a/sf_base/models/common.py b/sf_base/models/common.py index 65dfe13d..e8019d87 100644 --- a/sf_base/models/common.py +++ b/sf_base/models/common.py @@ -88,6 +88,7 @@ class MrsProductionProcess(models.Model): code = fields.Char("编码") name = fields.Char('名称') remark = fields.Text("备注") + sequence = fields.Integer('排序') # processing_order_ids = fields.One2many('sf.processing.order', 'production_process_id', string='工序') partner_process_ids = fields.Many2many('res.partner', 'process_ids', '加工工厂') active = fields.Boolean('有效', default=True) diff --git a/sf_base/models/tool_base_new.py.rej b/sf_base/models/tool_base_new.py.rej deleted file mode 100644 index 6db1f28a..00000000 --- a/sf_base/models/tool_base_new.py.rej +++ /dev/null @@ -1,10 +0,0 @@ -diff a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py (rejected hunks) -@@ -108,6 +108,4 @@ - cutting_speed_ids = fields.One2many('sf.cutting.speed', 'standard_library_id', string='切削速度Vc') -- feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz', -- domain=[('cutting_speed', '!=', False)]) -- feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz', -- domain=[('cutting_speed', '!=', False)]) -+ feed_per_tooth_ids = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz') -+ feed_per_tooth_ids_3 = fields.One2many('sf.feed.per.tooth', 'standard_library_id', '每齿走刀量fz') - diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 8e1f7199..a17c05b7 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -455,19 +455,16 @@ class MrpProduction(models.Model): 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_category = self.env['sf.production.process.category'].search( - [('production_process_ids.id', 'in', surface_technics_arr)], + production_process = self.env['sf.production.process'].search( + [('parameter_ids.id', 'in', surface_technics_arr)], order='sequence asc' ) - # 用filter刷选表面工艺id'是否存在工艺类别对象里 - if production_process_category: - for p in production_process_category: - logging.info('production_process_category:%s' % p.name) - production_process = p.production_process_ids.filtered( - lambda pp: pp.id in surface_technics_arr) + if production_process: + for p in production_process: + logging.info('production_process:%s' % p.name) if production_process: process_parameter = production.product_id.model_process_parameters_ids.filtered( - lambda pm: pm.process_id.id == production_process.id) + lambda pm: pm.process_id.id == p.id) if process_parameter: # 产品为表面工艺服务的供应商 product_production_process = self.env['product.template'].search( @@ -475,7 +472,7 @@ class MrpProduction(models.Model): if product_production_process: route_production_process = self.env[ 'mrp.routing.workcenter'].search( - [('surface_technics_id', '=', production_process.id), + [('surface_technics_id', '=', p.id), ('id', 'in', route_workcenter_arr)]) if route_production_process: workorders_values.append( diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 071f1167..37fa02bd 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_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index ce342d4a..5da16d95 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -9,7 +9,7 @@ from odoo.http import request class Sf_Mrs_Connect(http.Controller): - @http.route('/api/cnc_processing/create', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False, + @http.route('/api/cnc_processing/create', type='json', auth='none', methods=['GET', 'POST'], csrf=False, cors="*") def get_cnc_processing_create(self, **kw): """ @@ -29,21 +29,21 @@ class Sf_Mrs_Connect(http.Controller): [('programming_no', '=', ret['programming_no'])]) 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: if not production.workorder_ids: production.product_id.model_processing_panel = ret['processing_panel'] @@ -82,38 +82,38 @@ class Sf_Mrs_Connect(http.Controller): # 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', - '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) - logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) - files_panel = os.listdir(program_path_tmp_panel) - if files_panel: - for file in files_panel: - file_extension = os.path.splitext(file)[1] - logging.info('file_extension:%s' % file_extension) - 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', - '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': '已编程'}) - cnc_program_ids = [item.id for item in productions] - workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( - [('production_id', 'in', cnc_program_ids)]) - if workpiece_delivery: - workpiece_delivery.write( - {'is_cnc_program_down': True, 'production_line_id': productions.production_line_id.id}) + # 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', + # '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) + # logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) + # files_panel = os.listdir(program_path_tmp_panel) + # if files_panel: + # for file in files_panel: + # file_extension = os.path.splitext(file)[1] + # logging.info('file_extension:%s' % file_extension) + # 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', + # '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': '已编程'}) + # cnc_program_ids = [item.id for item in productions] + # workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( + # [('production_id', 'in', cnc_program_ids)]) + # if workpiece_delivery: + # workpiece_delivery.write( + # {'is_cnc_program_down': True, 'production_line_id': productions.production_line_id.id}) return json.JSONEncoder().encode(res) else: res = {'status': 0, 'message': '该制造订单暂未开始'} 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 3ae65db3..92f6cda2 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -6,8 +6,8 @@ import os from datetime import datetime from stl import mesh # 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 diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index 348d6c79..4f26a4a5 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -299,6 +299,7 @@ class ResPartnerToSale(models.Model): _inherit = 'res.partner' purchase_user_id = fields.Many2one('res.users', '采购员') + translated_display_name = fields.Char('2') @api.constrains('name') def _check_name(self): From 3e438a10ee7b1ebfe58839849e19866bc0fd437e Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Sun, 25 Aug 2024 14:58:40 +0800 Subject: [PATCH 04/25] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A1=A8=E9=9D=A2?= =?UTF-8?q?=E5=B7=A5=E8=89=BA=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 74 ++++++++-------- sf_manufacturing/models/product_template.py | 4 +- sf_manufacturing/models/stock.py | 4 +- sf_mrs_connect/controllers/controllers.py | 96 ++++++++++----------- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- 6 files changed, 93 insertions(+), 93 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index a17c05b7..afc65822 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -446,41 +446,45 @@ class MrpProduction(models.Model): # self.env['mrp.workorder'].json_workorder_str(k, production, route)) # 表面工艺工序 # 获取表面工艺id - if production.product_id.model_process_parameters_ids: - logging.info('model_process_parameters_ids:%s' % production.product_id.model_process_parameters_ids) - surface_technics_arr = [] - # 工序id - route_workcenter_arr = [] - for item in production.product_id.product_model_type_id.surface_technics_routing_tmpl_ids: - 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( - [('parameter_ids.id', 'in', surface_technics_arr)], - order='sequence asc' - ) - if production_process: - for p in production_process: - logging.info('production_process:%s' % p.name) - if production_process: - process_parameter = production.product_id.model_process_parameters_ids.filtered( - lambda pm: pm.process_id.id == p.id) - if process_parameter: - # 产品为表面工艺服务的供应商 - product_production_process = self.env['product.template'].search( - [('server_product_process_parameters_id', '=', process_parameter.id)]) - if product_production_process: - route_production_process = self.env[ - 'mrp.routing.workcenter'].search( - [('surface_technics_id', '=', p.id), - ('id', 'in', route_workcenter_arr)]) - if route_production_process: - workorders_values.append( - self.env[ - 'mrp.workorder']._json_workorder_surface_process_str( - production, route_production_process, - process_parameter, - product_production_process.seller_ids[0].partner_id.id)) + # 工序id + surface_technics_arr = [] + route_workcenter_arr = [] + for item in production.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.product_id.model_process_parameters_ids: + logging.info('process_param:%s%s' % (process_param.id, process_param.name)) + if item.route_workcenter_id.surface_technics_id == process_param.process_id: + logging.info( + 'surface_technics_id:%s%s' % (item.route_workcenter_id.surface_technics_id.id, + item.route_workcenter_id.surface_technics_id.name)) + 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) + # if production_process: + process_parameter = production.product_id.model_process_parameters_ids.filtered( + lambda pm: pm.process_id.id == p.id) + if process_parameter: + # 产品为表面工艺服务的供应商 + product_production_process = self.env['product.template'].search( + [('server_product_process_parameters_id', '=', process_parameter.id)]) + if product_production_process: + route_production_process = self.env[ + 'mrp.routing.workcenter'].search( + [('surface_technics_id', '=', p.id), + ('id', 'in', route_workcenter_arr)]) + if route_production_process: + workorders_values.append( + self.env[ + 'mrp.workorder']._json_workorder_surface_process_str( + production, route_production_process, + process_parameter, + product_production_process.seller_ids[0].partner_id.id)) elif production.product_id.categ_id.type == '坯料': embryo_routing_workcenter = self.env['sf.embryo.model.type.routing.sort'].search( [('embryo_model_type_id', '=', production.product_id.embryo_model_type_id.id)], diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 37fa02bd..071f1167 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 f53d7056..576e6d6f 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -177,10 +177,10 @@ class StockRule(models.Model): for company_id, moves_values in moves_values_by_company.items(): # create the move as SUPERUSER because the current user may not have the rights to do it (mto product # launched by a sale for example) - logging.info(moves_values) + # logging.info(moves_values) moves = self.env['stock.move'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create( moves_values) - logging.info(moves) + # logging.info(moves) # Since action_confirm launch following procurement_group we should activate it. moves._action_confirm() diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index 5da16d95..1ad67ab9 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -24,26 +24,28 @@ class Sf_Mrs_Connect(http.Controller): ret = json.loads(datas) ret = json.loads(ret['result']) logging.info('下发编程单:%s' % ret) + domain = [('programming_no', '=', ret['programming_no'])] + if ret['manufacturing_type'] == 'scrap': + domain += [('state', 'not in', ['done', 'scrap'])] productions = request.env['mrp.production'].with_user( - request.env.ref("base.user_admin")).search( - [('programming_no', '=', ret['programming_no'])]) + request.env.ref("base.user_admin")).search(domain) 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: if not production.workorder_ids: production.product_id.model_processing_panel = ret['processing_panel'] @@ -82,38 +84,32 @@ class Sf_Mrs_Connect(http.Controller): # 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', - # '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) - # logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) - # files_panel = os.listdir(program_path_tmp_panel) - # if files_panel: - # for file in files_panel: - # file_extension = os.path.splitext(file)[1] - # logging.info('file_extension:%s' % file_extension) - # 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', - # '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': '已编程'}) - # cnc_program_ids = [item.id for item in productions] - # workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( - # [('production_id', 'in', cnc_program_ids)]) - # if workpiece_delivery: - # workpiece_delivery.write( - # {'is_cnc_program_down': True, 'production_line_id': productions.production_line_id.id}) + 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', + '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) + logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel) + files_panel = os.listdir(program_path_tmp_panel) + if files_panel: + for file in files_panel: + file_extension = os.path.splitext(file)[1] + logging.info('file_extension:%s' % file_extension) + 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', + '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': '已编程'}) return json.JSONEncoder().encode(res) else: res = {'status': 0, 'message': '该制造订单暂未开始'} 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 92f6cda2..3ae65db3 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -6,8 +6,8 @@ import os from datetime import datetime from stl import mesh # 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 f5e36f601cd6c51aa83a7e0bfadadd24a50759b7 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Sun, 25 Aug 2024 15:01:11 +0800 Subject: [PATCH 05/25] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/__manifest__.py | 2 +- sf_sale/models/sale_order.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sf_base/__manifest__.py b/sf_base/__manifest__.py index 3c5175f0..b10c2630 100644 --- a/sf_base/__manifest__.py +++ b/sf_base/__manifest__.py @@ -23,7 +23,7 @@ 'views/tool_basic_param.xml', 'views/tool_menu.xml', 'views/menu_fixture_view.xml', - # 'views/change_base_view.xml', + 'views/change_base_view.xml', 'views/Printer.xml', ], diff --git a/sf_sale/models/sale_order.py b/sf_sale/models/sale_order.py index 4f26a4a5..348d6c79 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -299,7 +299,6 @@ class ResPartnerToSale(models.Model): _inherit = 'res.partner' purchase_user_id = fields.Many2one('res.users', '采购员') - translated_display_name = fields.Char('2') @api.constrains('name') def _check_name(self): From f1780181faf1d7fac121e79ec770b234b1f37b68 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Sun, 25 Aug 2024 17:36:07 +0800 Subject: [PATCH 06/25] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=A5=E5=BA=9F?= =?UTF-8?q?=E5=90=91=E5=AF=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 12 ++++++------ sf_manufacturing/models/mrp_production.py | 9 ++++++--- sf_manufacturing/wizard/production_wizard.py | 1 + sf_manufacturing/wizard/production_wizard_views.xml | 11 +++++++++++ sf_sale/models/sale_order.py | 6 +++--- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 23be7d38..376101c9 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -620,12 +620,12 @@ class Manufacturing_Connect(http.Controller): # if is_free is True: # delivery_workpiece._delivery_avg() # logging.info('agv下发下产线任务下发完成') - if ret['IsComplete'] is True: - # 向AGV任务调度下发下产线任务 - workorders = request.env['mrp.workorder'].browse(workorder_ids) - request.env['sf.agv.scheduling'].add_scheduling(ret['DeviceId'], '下产线', workorders) - else: - res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'} + # if ret['IsComplete'] is True: + # # 向AGV任务调度下发下产线任务 + # workorders = request.env['mrp.workorder'].browse(workorder_ids) + # request.env['sf.agv.scheduling'].add_scheduling(ret['DeviceId'], '下产线', workorders) + # else: + # res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'} except RepeatTaskException as e: logging.info('AGVToProduct error:%s' % e) except Exception as e: diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 8e1f7199..964f34fe 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -241,7 +241,10 @@ class MrpProduction(models.Model): res = {'programming_no': programming_no_str} logging.info('res=%s:' % res) configsettings = self.env['res.config.settings'].get_values() - config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key']) + configsettings['token'] = 'ba301c9b-2216-11ef-9d97-f8b54deb92c1' + # configsettings['sf_secret_key'] = 'rAalgsVOhDpxIWzR' + # configsettings['sf_url'] = 'http://localhost:7069' + # config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key']) url = '/api/intelligent_programming/get_state' config_url = configsettings['sf_url'] + url ret = requests.post(config_url, json=res, data=None, headers=config_header) @@ -808,8 +811,8 @@ class MrpProduction(models.Model): 'target': 'new', 'context': { 'default_production_id': self.id, - 'default_programming_state': '编程中' if cloud_programming[ - 'programming_state'] != '已下发' else '已下发', + 'default_reprogramming_num': cloud_programming['reprogramming_num'], + 'default_programming_state': cloud_programming['programming_state'], 'default_is_reprogramming': True if cloud_programming['programming_state'] in ['已下发'] else False } } diff --git a/sf_manufacturing/wizard/production_wizard.py b/sf_manufacturing/wizard/production_wizard.py index 5700ea68..323db518 100644 --- a/sf_manufacturing/wizard/production_wizard.py +++ b/sf_manufacturing/wizard/production_wizard.py @@ -13,6 +13,7 @@ class ProductionWizard(models.TransientModel): _description = '制造订单向导' production_id = fields.Many2one('mrp.production', string='制造订单号') + reprogramming_num = fields.Integer('重新编程次数', default=0) is_reprogramming = fields.Boolean(string='申请重新编程', default=False) is_remanufacture = fields.Boolean(string='重新生成制造订单', default=True) programming_state = fields.Selection( diff --git a/sf_manufacturing/wizard/production_wizard_views.xml b/sf_manufacturing/wizard/production_wizard_views.xml index 1efef116..b6619811 100644 --- a/sf_manufacturing/wizard/production_wizard_views.xml +++ b/sf_manufacturing/wizard/production_wizard_views.xml @@ -12,6 +12,17 @@ 重新生成制造订单 +
+ 注意: 该制造订单产品已申请重新编程次数为,且当前编程状态为 + +
申请重新编程 = 1: self.env['purchase.order'].sudo().create({ 'partner_id': server_product.seller_ids.partner_id.id, 'origin': ','.join(production_process), From deef246a6d6b9a4f49d576266e4b7fb8701da770 Mon Sep 17 00:00:00 2001 From: hujiaying Date: Mon, 26 Aug 2024 11:10:52 +0800 Subject: [PATCH 07/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A1=A8=E9=9D=A2?= =?UTF-8?q?=E5=B7=A5=E8=89=BA=E5=AD=97=E6=AE=B5=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/common.py | 3 ++- sf_mrs_connect/models/sync_common.py | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sf_base/models/common.py b/sf_base/models/common.py index 65dfe13d..9553c60c 100644 --- a/sf_base/models/common.py +++ b/sf_base/models/common.py @@ -96,7 +96,7 @@ class MrsProductionProcess(models.Model): # workcenter_ids = fields.Many2many('mrp.workcenter', 'rel_workcenter_process', required=True) processing_day = fields.Float('加工天数/d') travel_day = fields.Float('路途天数/d') - + sequence = fields.Integer('排序') # class MrsProcessingTechnology(models.Model): # _name = 'sf.processing.technology' @@ -148,6 +148,7 @@ class MrsProductionProcessParameter(models.Model): processing_day = fields.Float('加工天数/d') travel_day = fields.Float('路途天数/d') active = fields.Boolean('有效', default=True) + processing_mm = fields.Char('加工厚度/mm') def name_get(self): result = [] diff --git a/sf_mrs_connect/models/sync_common.py b/sf_mrs_connect/models/sync_common.py index e37d460a..e812bd03 100644 --- a/sf_mrs_connect/models/sync_common.py +++ b/sf_mrs_connect/models/sync_common.py @@ -329,6 +329,7 @@ class sfProductionProcess(models.Model): production_process.processing_day = item['processing_day'] production_process.travel_day = item['travel_day'] production_process.active = item['active'] + production_process.sequence = item['sequence'] else: self.create({ "name": item['name'], @@ -338,6 +339,7 @@ class sfProductionProcess(models.Model): "processing_day": item['processing_day'], "travel_day": item['travel_day'], "active": item['active'], + "sequence": item['sequence'] }) else: raise ValidationError("表面工艺认证未通过") @@ -365,6 +367,7 @@ class sfProductionProcess(models.Model): "processing_day": item['processing_day'], "travel_day": item['travel_day'], "active": item['active'], + "sequence": item['sequence'] }) else: production_process.name = item['name'] @@ -373,6 +376,7 @@ class sfProductionProcess(models.Model): production_process.processing_day = item['processing_day'] production_process.travel_day = item['travel_day'] production_process.active = item['active'] + production_process.sequence = item['sequence'] else: raise ValidationError("表面工艺认证未通过") @@ -1088,6 +1092,7 @@ class sfProductionProcessParameter(models.Model): production_process_parameter.process_id = process.id production_process_parameter.materials_model_ids = self.env['sf.materials.model'].search( [('materials_no', 'in', item['materials_model_ids_codes'])]) + production_process_parameter.processing_mm = item['processing_mm'] else: self.create({ "name": item['name'], @@ -1099,6 +1104,7 @@ class sfProductionProcessParameter(models.Model): "process_id": process.id, "materials_model_ids": self.env['sf.materials.model'].search( [('materials_no', 'in', item['materials_model_ids_codes'])]), + "processing_mm": item['processing_mm'] }) else: raise ValidationError("表面工艺可选参数认证未通过") # 定时同步表面工艺 @@ -1129,6 +1135,7 @@ class sfProductionProcessParameter(models.Model): "process_id": process.id, 'materials_model_ids': self.env['sf.materials.model'].search( [('materials_no', 'in', item['materials_model_ids_codes'])]), + 'processing_mm': item['processing_mm'] }) else: production_process_parameter.name = item['name'] @@ -1139,6 +1146,7 @@ class sfProductionProcessParameter(models.Model): production_process_parameter.materials_model_ids = self.env['sf.materials.model'].search( [('materials_no', 'in', item['materials_model_ids_codes'])]) production_process_parameter.active = item['active'] + production_process_parameter.processing_mm = item['processing_mm'] else: raise ValidationError("表面工艺可选参数认证未通过") From 89cb61f244ce9c145fa8d6ffc257e89ecf0c308d Mon Sep 17 00:00:00 2001 From: hujiaying Date: Mon, 26 Aug 2024 12:47:15 +0800 Subject: [PATCH 08/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E8=A1=A8=E9=9D=A2=E5=B7=A5=E8=89=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/views/common_view.xml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sf_base/views/common_view.xml b/sf_base/views/common_view.xml index 533a3e04..ed39f9a4 100644 --- a/sf_base/views/common_view.xml +++ b/sf_base/views/common_view.xml @@ -16,7 +16,7 @@ sf.production.process.parameter -
+

@@ -33,11 +33,12 @@ + - + @@ -163,7 +164,8 @@ sf.production.process - + + @@ -174,7 +176,7 @@ sf.production.process - +

@@ -192,11 +194,11 @@ - - - + + + - + From 78d00e9157214a6b0a19c3576867b7c0cbac9b3c Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 26 Aug 2024 13:23:44 +0800 Subject: [PATCH 09/25] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcoding=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=9C=BA=E5=BA=8A=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/controllers/controllers.py | 1 + sf_manufacturing/models/mrp_workorder.py | 7 ++--- sf_manufacturing/static/src/js/customRFID.js | 29 ++++++++++++++++--- sf_manufacturing/views/mrp_workorder_view.xml | 2 +- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 946bb78c..94c0fdcb 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -163,6 +163,7 @@ class Sf_Dashboard_Connect(http.Controller): # 停机时间:关机时间 - 运行时间 # 停机时长:关机时间 - 初次上线时间 'img': f'data:image/png;base64,{machine_data.machine_tool_picture.decode("utf-8")}', + 'equipment_type': machine_data.category_id.name, }) return json.dumps(res) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 066cb133..095c1ab1 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1154,7 +1154,7 @@ class ResMrpWorkOrder(models.Model): def button_finish(self): for record in self: if record.routing_type == '装夹预调': - if not record.material_center_point and record.X_deviation_angle > 0: + if not record.material_center_point or record.X_deviation_angle <= 0: raise UserError("请对前置三元检测定位参数进行计算定位") if not record.rfid_code and record.is_rework is False: raise UserError("请扫RFID码进行绑定") @@ -1257,15 +1257,14 @@ class ResMrpWorkOrder(models.Model): # 解绑托盘 def unbind_tray(self): - self.write({ + self.production_id.workorder_ids.write({ 'rfid_code': False, 'tray_serial_number': False, 'tray_product_id': False, 'tray_brand_id': False, 'tray_type_id': False, 'tray_model_id': False, - 'is_trayed': False - }) + 'is_trayed': False}) # 将FTP的检测报告文件下载到临时目录 def download_reportfile_tmp(self, workorder, reportpath): diff --git a/sf_manufacturing/static/src/js/customRFID.js b/sf_manufacturing/static/src/js/customRFID.js index eaa07d8a..cb58b3ea 100644 --- a/sf_manufacturing/static/src/js/customRFID.js +++ b/sf_manufacturing/static/src/js/customRFID.js @@ -3,13 +3,34 @@ $(document).off('keydown') $(document).on('keydown', 'body.o_web_client', function (e) { setTimeout(() => { RFID = '' - }, 200) + }, 200) if(e.key == 'Enter' && e.keyCode == 13 || e.key == 'Tab' && e.keyCode == 9){ + + let fieldValue1 = $('[name="routing_type"]'); + console.log('字段值:', fieldValue1.text()); console.log(RFID) - if(!RFID || RFID.length <= 3) return; - $('[name="button_start"]').trigger('click') - RFID = '' + let fieldValue2 = $('[name="rfid_code"]'); + console.log('字段值2:', fieldValue2.text()); + // if(!RFID || RFID.length <= 3) return; + // $('[name="button_start"]').trigger('click') + // setTimeout(() => { + // $('.o_dialog .modal-footer .btn-primary').trigger('click') + // }, 50) + // RFID = '' + // return; + + // fieldValue2.val() === '') + // 检查字段值是否等于“装夹预调” + if (fieldValue1.text() === '装夹预调') { + if (!RFID || RFID.length <= 3) return; + $('[name="button_start"]').trigger('click'); + setTimeout(() => { + $('.o_dialog .modal-footer .btn-primary').trigger('click'); + }, 100); + } + + RFID = ''; return; } RFID += e.key diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index eab42424..2c43a601 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -195,7 +195,7 @@ attrs="{'invisible': ['|','|',('routing_type','!=','装夹预调'),('state','!=','progress'),('is_rework','=',True)]}"/>

AGV参数配置

-
+
From b40a87df88032859b671905de7070fcbbbc7a949 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 27 Aug 2024 11:24:04 +0800 Subject: [PATCH 21/25] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=A5=E5=BA=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 12 +-- sf_manufacturing/models/mrp_production.py | 4 +- sf_manufacturing/models/mrp_workorder.py | 4 +- sf_manufacturing/models/product_template.py | 4 +- sf_manufacturing/models/stock.py | 4 - .../views/mrp_production_addional_change.xml | 26 +++--- sf_manufacturing/wizard/production_wizard.py | 9 +- sf_mrs_connect/controllers/controllers.py | 82 +++++++++---------- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- 10 files changed, 75 insertions(+), 78 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 376101c9..23be7d38 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -620,12 +620,12 @@ class Manufacturing_Connect(http.Controller): # if is_free is True: # delivery_workpiece._delivery_avg() # logging.info('agv下发下产线任务下发完成') - # if ret['IsComplete'] is True: - # # 向AGV任务调度下发下产线任务 - # workorders = request.env['mrp.workorder'].browse(workorder_ids) - # request.env['sf.agv.scheduling'].add_scheduling(ret['DeviceId'], '下产线', workorders) - # else: - # res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'} + if ret['IsComplete'] is True: + # 向AGV任务调度下发下产线任务 + workorders = request.env['mrp.workorder'].browse(workorder_ids) + request.env['sf.agv.scheduling'].add_scheduling(ret['DeviceId'], '下产线', workorders) + else: + res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'} except RepeatTaskException as e: logging.info('AGVToProduct error:%s' % e) except Exception as e: diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 0f26a6d7..1d011dd7 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -142,13 +142,13 @@ class MrpProduction(models.Model): def action_view_remanufacture_productions(self): self.ensure_one() - mrp_production_ids = self.env['mrp.production'].search( + mrp_production = self.env['mrp.production'].search( [('id', '=', self.remanufacture_production_id.id)]) action = { 'res_model': 'mrp.production', 'type': 'ir.actions.act_window', 'view_mode': 'form', - 'res_id': mrp_production_ids[0], + 'res_id': mrp_production.id, } return action diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 095c1ab1..1b315e46 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1154,8 +1154,8 @@ class ResMrpWorkOrder(models.Model): def button_finish(self): for record in self: if record.routing_type == '装夹预调': - if not record.material_center_point or record.X_deviation_angle <= 0: - raise UserError("请对前置三元检测定位参数进行计算定位") + # if not record.material_center_point or record.X_deviation_angle <= 0: + # raise UserError("请对前置三元检测定位参数进行计算定位") if not record.rfid_code and record.is_rework is False: raise UserError("请扫RFID码进行绑定") record.process_state = '待加工' diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 37fa02bd..071f1167 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 a0da7ba3..27ce925a 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -151,8 +151,6 @@ class StockRule(models.Model): list2.append(item) for procurement, rule in list2: - logging.info(rule) - logging.info(rule.procure_method) procure_method = rule.procure_method if rule.procure_method == 'mts_else_mto': qty_needed = procurement.product_uom._compute_quantity(procurement.product_qty, @@ -178,10 +176,8 @@ class StockRule(models.Model): for company_id, moves_values in moves_values_by_company.items(): # create the move as SUPERUSER because the current user may not have the rights to do it (mto product # launched by a sale for example) - logging.info(moves_values) moves = self.env['stock.move'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create( moves_values) - logging.info(moves) # Since action_confirm launch following procurement_group we should activate it. moves._action_confirm() return True diff --git a/sf_manufacturing/views/mrp_production_addional_change.xml b/sf_manufacturing/views/mrp_production_addional_change.xml index 8213f483..6fa14a6f 100644 --- a/sf_manufacturing/views/mrp_production_addional_change.xml +++ b/sf_manufacturing/views/mrp_production_addional_change.xml @@ -127,7 +127,7 @@ confirm="是否确认更新程序" attrs="{'invisible': ['|',('state', '!=', 'rework'),('programming_state', '!=', '已编程未下发')]}"/> +