From 92037f3f04465a87560148f5b33a1bff79fbc2f3 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 18 Sep 2024 10:23:42 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=B3=A8=E9=87=8AOCC=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_maintenance/models/sf_maintenance.py | 29 ++--- sf_manufacturing/__manifest__.py | 2 +- sf_manufacturing/models/agv_scheduling.py | 4 +- sf_manufacturing/models/mrp_production.py | 4 + sf_manufacturing/models/mrp_workorder.py | 2 +- sf_manufacturing/models/product_template.py | 4 +- sf_manufacturing/models/stock.py | 2 +- sf_manufacturing/views/mrp_workorder_view.xml | 2 +- sf_message/models/sf_message_template.py | 49 ++++---- sf_message/views/sf_message_template_view.xml | 6 +- sf_mrs_connect/controllers/controllers.py | 112 +++++++++--------- sf_plan/models/custom_plan.py | 2 +- sf_sale/__manifest__.py | 3 +- sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- sf_sale/models/sale_order.py | 4 +- sf_tool_management/models/base.py | 6 +- 17 files changed, 116 insertions(+), 123 deletions(-) diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index 74da7742..dd7266cc 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -33,13 +33,12 @@ class SfMaintenanceEquipmentAGVLog(models.Model): class SfMaintenanceEquipment(models.Model): - _inherit = 'maintenance.equipment' + _inherit = ['maintenance.equipment', 'sf.message.template'] _description = '设备' crea_url = "/api/machine_tool/create" - - #AGV运行日志 + # AGV运行日志 agv_logs = fields.One2many('maintenance.equipment.agv.log', 'equipment_id', string='AGV运行日志') # 1212修改后的字段 number_of_axles = fields.Selection( @@ -117,7 +116,6 @@ class SfMaintenanceEquipment(models.Model): # num = "%04d" % m # return num - equipment_maintenance_standards_ids = fields.Many2many('equipment.maintenance.standards', 'sf_maintenance_equipment_ids', string='设备维保标准') eq_maintenance_id = fields.Many2one('equipment.maintenance.standards', string='设备保养标准', @@ -179,7 +177,8 @@ class SfMaintenanceEquipment(models.Model): type_id = fields.Many2one('sf.machine_tool.type', '型号') state = fields.Selection( - [("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"), ("空闲", "空闲"), ("封存(报废)", "封存(报废)")], + [("正常", "正常"), ("故障停机", "故障停机"), ("计划维保", "计划维保"), ("空闲", "空闲"), + ("封存(报废)", "封存(报废)")], default='正常', string="机床状态") run_time = fields.Char('总运行时长') # 0606新增字段 @@ -328,7 +327,7 @@ class SfMaintenanceEquipment(models.Model): item.tool_diameter_min = item.type_id.tool_diameter_min item.machine_tool_category = item.type_id.machine_tool_category.id item.brand_id = item.type_id.brand_id.id - #新增修改字段 + # 新增修改字段 item.taper_type_id = item.type_id.taper_type_id.id item.function_type = item.type_id.function_type item.a_axis = item.type_id.a_axis @@ -370,7 +369,6 @@ class SfMaintenanceEquipment(models.Model): item.image_id = item.type_id.jg_image_id.ids item.image_lq_id = item.type_id.lq_image_id.ids - # AGV小车设备参数 AGV_L = fields.Char('AGV尺寸(长)') AGV_W = fields.Char('AGV尺寸(宽)') @@ -461,18 +459,6 @@ class SfMaintenanceEquipment(models.Model): original_value = fields.Char('原值') incomplete_value = fields.Char('残值') - - - - - - - - - - - - # 注册同步机床 def enroll_machine_tool(self): sf_sync_config = self.env['res.config.settings'].get_values() @@ -763,7 +749,7 @@ class SfMaintenanceEquipment(models.Model): image_id = fields.Many2many('maintenance.equipment.image', 'equipment_id', domain="[('type', '=', '加工能力')]") image_lq_id = fields.Many2many('maintenance.equipment.image', 'equipment_lq_id', string='冷却方式', - domain="[('type', '=', '冷却方式')]") + domain="[('type', '=', '冷却方式')]") class SfRobotAxisNum(models.Model): @@ -777,4 +763,5 @@ class SfRobotAxisNum(models.Model): weight = fields.Char('最大负载(kg)') permissible_load_torque = fields.Char('允许负载扭矩(N-m)') permissible_inertial_torque = fields.Char('允许惯性扭矩(kg-m²)') - equipment_id = fields.Many2one('maintenance.equipment', string='机器人', domain="[('equipment_type', '=', '机器人')]") + equipment_id = fields.Many2one('maintenance.equipment', string='机器人', + domain="[('equipment_type', '=', '机器人')]") diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 8cf16106..b0556418 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -10,7 +10,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse'], + 'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse','sf_message'], 'data': [ 'data/stock_data.xml', 'data/empty_racks_data.xml', diff --git a/sf_manufacturing/models/agv_scheduling.py b/sf_manufacturing/models/agv_scheduling.py index f758abd9..35b6b76d 100644 --- a/sf_manufacturing/models/agv_scheduling.py +++ b/sf_manufacturing/models/agv_scheduling.py @@ -89,8 +89,8 @@ class AgvScheduling(models.Model): workorders: 工单 """ _logger.info('创建AGV调度任务\r\n起点为【%s】,任务类型为【%s】,工单为【%s】' % (agv_start_site_name, agv_route_type, workorders)) - if not workorders: - raise UserError(_('工单不能为空')) + # if not workorders: + # raise UserError(_('工单不能为空')) agv_start_site = self.env['sf.agv.site'].sudo().search([('name', '=', agv_start_site_name)], limit=1) if not agv_start_site: raise UserError(_('不存在名称为【%s】的接驳站,请先创建!' % agv_start_site_name)) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 405baf38..063a67d8 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -804,6 +804,10 @@ class MrpProduction(models.Model): backorders = backorders - productions_to_backorder productions_not_to_backorder._post_inventory(cancel_backorder=True) + if self.workorder_ids.filtered(lambda w: w.routing_type in ['表面工艺']): + move_finish = self.env['stock.move'].search([('created_production_id', '=', self.id)]) + if move_finish: + move_finish._action_assign() productions_to_backorder._post_inventory(cancel_backorder=True) # if completed products make other confirmed/partially_available moves available, assign them diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 2a492932..8b98e491 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -18,7 +18,7 @@ from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController class ResMrpWorkOrder(models.Model): - _inherit = 'mrp.workorder' + _inherit = ['mrp.workorder', 'sf.message.template'] _order = 'sequence asc' product_tmpl_name = fields.Char('坯料产品名称', related='production_bom_id.bom_line_ids.product_id.name') 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 9d4e3161..e0c66076 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -539,7 +539,7 @@ class ProductionLot(models.Model): class StockPicking(models.Model): - _inherit = 'stock.picking' + _inherit = ['stock.picking', 'sf.message.template'] surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数") diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 7cada1be..b8ea784e 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -221,7 +221,7 @@ - diff --git a/sf_message/models/sf_message_template.py b/sf_message/models/sf_message_template.py index 4d89cc2a..481497e0 100644 --- a/sf_message/models/sf_message_template.py +++ b/sf_message/models/sf_message_template.py @@ -7,30 +7,30 @@ class SfMessageTemplate(models.Model): _description = u'消息模板' name = fields.Char(string=u"名称", required=True) - type = fields.Selection([ - ('待接单', '待接单'), - ('待排程', '待排程'), - ('坯料采购', '坯料采购'), - ('坯料发料', '坯料发料'), - ('待编程', '待编程'), - ('调拨入库', '调拨入库'), - ('功能刀具组装', '功能刀具组装'), - ('功能刀具寿命到期', '功能刀具寿命到期'), - ('程序用刀计划异常', '程序用刀计划异常'), - ('工单无CNC程序', '工单无CNC程序'), - ('生产线无功能刀具', '生产线无功能刀具'), - ('工单无定位数据', '工单无定位数据'), - ('工单FTP无文件', '工单FTP无文件'), - ('工单加工失败', '工单加工失败'), - ('设备故障及异常', '设备故障及异常'), - ('工单逾期预警', '工单逾期预警'), - ('工单已逾期', '工单已逾期'), - ('销售订单逾期', '销售订单逾期'), - ('销售订单已逾期', '销售订单已逾期'), - ('待质量判定', '待质量判定'), - ('生产完工待入库', '生产完工待入库'), - ('订单发货', '订单发货') - ], string='类型', required=True) + # type = fields.Selection([ + # ('待接单', '待接单'), + # ('待排程', '待排程'), + # ('坯料采购', '坯料采购'), + # ('坯料发料', '坯料发料'), + # ('待编程', '待编程'), + # ('调拨入库', '调拨入库'), + # ('功能刀具组装', '功能刀具组装'), + # ('功能刀具寿命到期', '功能刀具寿命到期'), + # ('程序用刀计划异常', '程序用刀计划异常'), + # ('工单无CNC程序', '工单无CNC程序'), + # ('生产线无功能刀具', '生产线无功能刀具'), + # ('工单无定位数据', '工单无定位数据'), + # ('工单FTP无文件', '工单FTP无文件'), + # ('工单加工失败', '工单加工失败'), + # ('设备故障及异常', '设备故障及异常'), + # ('工单逾期预警', '工单逾期预警'), + # ('工单已逾期', '工单已逾期'), + # ('销售订单逾期', '销售订单逾期'), + # ('销售订单已逾期', '销售订单已逾期'), + # ('待质量判定', '待质量判定'), + # ('生产完工待入库', '生产完工待入库'), + # ('订单发货', '订单发货') + # ], string='类型', required=True) description = fields.Char(string=u"描述") content = fields.Html(string=u"内容", render_engine='qweb', translate=True, prefetch=True, sanitize=False) msgtype = fields.Selection( @@ -46,3 +46,4 @@ class SfMessageTemplate(models.Model): def _clear_employee_ids(self): if self.notification_department_id: self.notification_employee_ids = False + diff --git a/sf_message/views/sf_message_template_view.xml b/sf_message/views/sf_message_template_view.xml index ac412589..c057a8e4 100644 --- a/sf_message/views/sf_message_template_view.xml +++ b/sf_message/views/sf_message_template_view.xml @@ -18,7 +18,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -55,7 +55,7 @@ + filter_domain="['|','|',('name','like',self),('description','like',self)]"/> diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index c5d1cd10..7e51ca2c 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -31,67 +31,67 @@ class Sf_Mrs_Connect(http.Controller): 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'] production._create_workorder(ret) productions.process_range_time() - else: - for panel in ret['processing_panel'].split(','): - # 查询状态为进行中且工序类型为CNC加工的工单 - cnc_workorder_has = production.workorder_ids.filtered( - lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done', - 'rework', - 'cancel'] and ach.processing_panel == panel) - if cnc_workorder_has: - if cnc_workorder_has.cnc_ids: - cnc_workorder_has.cmm_ids.sudo().unlink() - cnc_workorder_has.cnc_ids.sudo().unlink() - request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( - production) - 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) - 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', 'rework' - 'cancel'] and ap.processing_panel == panel) - if pre_workorder: - pre_workorder.write( - {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) + # else: + # for panel in ret['processing_panel'].split(','): + # # 查询状态为进行中且工序类型为CNC加工的工单 + # cnc_workorder_has = production.workorder_ids.filtered( + # lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done', + # 'rework', + # 'cancel'] and ach.processing_panel == panel) + # if cnc_workorder_has: + # if cnc_workorder_has.cnc_ids: + # cnc_workorder_has.cmm_ids.sudo().unlink() + # cnc_workorder_has.cnc_ids.sudo().unlink() + # request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( + # production) + # 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) + # 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', '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': '已编程'}) return json.JSONEncoder().encode(res) else: diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index c4043d33..636f4573 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -11,7 +11,7 @@ from odoo.exceptions import UserError, ValidationError class sf_production_plan(models.Model): _name = 'sf.production.plan' _description = 'sf_production_plan' - _inherit = ['mail.thread'] + _inherit = ['mail.thread', 'sf.message.template'] # _order = 'state desc, write_date desc' state = fields.Selection([ diff --git a/sf_sale/__manifest__.py b/sf_sale/__manifest__.py index 45c95030..bed93637 100644 --- a/sf_sale/__manifest__.py +++ b/sf_sale/__manifest__.py @@ -10,7 +10,8 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['sale', 'sale_management', 'web_widget_model_viewer', 'sf_base', 'account', 'purchase', 'delivery'], + 'depends': ['sale', 'sale_management', 'web_widget_model_viewer', 'sf_base', 'account', 'purchase', 'delivery', + 'sf_message'], 'data': [ 'security/group_security.xml', 'security/ir.model.access.csv', 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 1d0487b8..7fda0540 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 d19a3b02..9e45a141 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -11,7 +11,7 @@ READONLY_FIELD_STATES = { class ReSaleOrder(models.Model): - _inherit = 'sale.order' + _inherit = ['sale.order', 'sf.message.template'] mrp_production_count = fields.Integer( "Count of MO generated", @@ -183,7 +183,7 @@ class ProductTemplate(models.Model): class RePurchaseOrder(models.Model): - _inherit = 'purchase.order' + _inherit = ['purchase.order','sf.message.template'] mrp_production_count = fields.Integer( "Count of MO Source", diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 2876bc8f..ba0e7edc 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -181,7 +181,7 @@ class MachineTableToolChangingApply(models.Model): class CAMWorkOrderProgramKnifePlan(models.Model): _name = 'sf.cam.work.order.program.knife.plan' - _inherit = ['mail.thread'] + _inherit = ['mail.thread', 'sf.message.template'] _description = 'CAM工单程序用刀计划' name = fields.Char('工单任务编号') @@ -349,7 +349,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model): class FunctionalToolAssembly(models.Model): _name = 'sf.functional.tool.assembly' - _inherit = ['mail.thread'] + _inherit = ['mail.thread', 'sf.message.template'] _description = '功能刀具组装' _order = 'assemble_status, use_tool_time asc' @@ -679,7 +679,7 @@ class FunctionalToolAssembly(models.Model): class FunctionalToolDismantle(models.Model): _name = 'sf.functional.tool.dismantle' - _inherit = ["barcodes.barcode_events_mixin", 'mail.thread'] + _inherit = ["barcodes.barcode_events_mixin", 'mail.thread', 'sf.message.template'] _description = '功能刀具拆解' def on_barcode_scanned(self, barcode): From ce6b36a77e85a5a9b3c5825e178593fa7607da84 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 18 Sep 2024 15:39:42 +0800 Subject: [PATCH 2/6] 12 --- sf_maintenance/__manifest__.py | 2 +- sf_message/views/sf_message_template_view.xml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/sf_maintenance/__manifest__.py b/sf_maintenance/__manifest__.py index 595a5d25..ce8f638e 100644 --- a/sf_maintenance/__manifest__.py +++ b/sf_maintenance/__manifest__.py @@ -6,7 +6,7 @@ 'category': '工厂设备', 'description': """ """, - 'depends': ['hr_maintenance', 'sf_base'], + 'depends': ['hr_maintenance', 'sf_base', 'sf_message'], 'data': [ 'security/group_security.xml', 'security/ir.model.access.csv', diff --git a/sf_message/views/sf_message_template_view.xml b/sf_message/views/sf_message_template_view.xml index c057a8e4..9680507a 100644 --- a/sf_message/views/sf_message_template_view.xml +++ b/sf_message/views/sf_message_template_view.xml @@ -23,7 +23,6 @@ options="{'style-inline': true, 'codeview': true, 'dynamic_placeholder': true}"/> - @@ -41,7 +40,6 @@ - From 43f53197c4d5e8125ef6867f155316e04e0272c4 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 18 Sep 2024 17:39:06 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=A8=A1=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_maintenance/__manifest__.py | 2 +- sf_maintenance/models/sf_maintenance.py | 2 +- sf_manufacturing/__manifest__.py | 2 +- sf_manufacturing/models/mrp_workorder.py | 2 +- sf_manufacturing/models/product_template.py | 4 ++-- sf_manufacturing/models/stock.py | 2 +- sf_message/__manifest__.py | 2 +- sf_message/models/__init__.py | 7 +++++++ sf_message/models/sf_message_cam_program.py | 6 ++++++ sf_message/models/sf_message_functional_tool_assembly.py | 6 ++++++ sf_message/models/sf_message_plan.py | 6 ++++++ sf_message/models/sf_message_purchase.py | 6 ++++++ sf_message/models/sf_message_sale.py | 6 ++++++ sf_message/models/sf_message_stock_picking.py | 6 ++++++ sf_message/models/sf_message_template.py | 6 ++++++ sf_message/models/sf_message_workorder.py | 6 ++++++ sf_plan/models/custom_plan.py | 2 +- sf_sale/models/quick_easy_order.py | 4 ++-- sf_sale/models/quick_easy_order_old.py | 4 ++-- sf_sale/models/sale_order.py | 4 ++-- sf_tool_management/models/base.py | 6 +++--- 21 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 sf_message/models/sf_message_cam_program.py create mode 100644 sf_message/models/sf_message_functional_tool_assembly.py create mode 100644 sf_message/models/sf_message_plan.py create mode 100644 sf_message/models/sf_message_purchase.py create mode 100644 sf_message/models/sf_message_sale.py create mode 100644 sf_message/models/sf_message_stock_picking.py create mode 100644 sf_message/models/sf_message_workorder.py diff --git a/sf_maintenance/__manifest__.py b/sf_maintenance/__manifest__.py index ce8f638e..595a5d25 100644 --- a/sf_maintenance/__manifest__.py +++ b/sf_maintenance/__manifest__.py @@ -6,7 +6,7 @@ 'category': '工厂设备', 'description': """ """, - 'depends': ['hr_maintenance', 'sf_base', 'sf_message'], + 'depends': ['hr_maintenance', 'sf_base'], 'data': [ 'security/group_security.xml', 'security/ir.model.access.csv', diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index dd7266cc..e20fd97c 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -33,7 +33,7 @@ class SfMaintenanceEquipmentAGVLog(models.Model): class SfMaintenanceEquipment(models.Model): - _inherit = ['maintenance.equipment', 'sf.message.template'] + _inherit = ['maintenance.equipment'] _description = '设备' crea_url = "/api/machine_tool/create" diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 10c949f5..35501367 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -10,7 +10,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse','sf_message'], + 'depends': ['sf_base', 'sf_maintenance', 'web_widget_model_viewer', 'sf_warehouse'], 'data': [ 'data/stock_data.xml', 'data/empty_racks_data.xml', diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index bc049c12..97d172c9 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -18,7 +18,7 @@ from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController class ResMrpWorkOrder(models.Model): - _inherit = ['mrp.workorder', 'sf.message.template'] + _inherit = ['mrp.workorder'] _order = 'sequence asc' product_tmpl_name = fields.Char('坯料产品名称', related='production_bom_id.bom_line_ids.product_id.name') 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 1690b632..3eab030e 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -545,7 +545,7 @@ class ProductionLot(models.Model): class StockPicking(models.Model): - _inherit = ['stock.picking', 'sf.message.template'] + _inherit = ['stock.picking'] surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数") diff --git a/sf_message/__manifest__.py b/sf_message/__manifest__.py index 3a0f37d8..492510d1 100644 --- a/sf_message/__manifest__.py +++ b/sf_message/__manifest__.py @@ -11,7 +11,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['base', 'sf_base'], + 'depends': ['base', 'sf_plan'], 'data': [ 'security/ir.model.access.csv', 'views/sf_message_template_view.xml', diff --git a/sf_message/models/__init__.py b/sf_message/models/__init__.py index ec5b1c2f..b0c058fc 100644 --- a/sf_message/models/__init__.py +++ b/sf_message/models/__init__.py @@ -1 +1,8 @@ from . import sf_message_template +from . import sf_message_sale +from . import sf_message_plan +from . import sf_message_stock_picking +from . import sf_message_cam_program +from . import sf_message_functional_tool_assembly +from . import sf_message_purchase +from . import sf_message_workorder diff --git a/sf_message/models/sf_message_cam_program.py b/sf_message/models/sf_message_cam_program.py new file mode 100644 index 00000000..5a6154e5 --- /dev/null +++ b/sf_message/models/sf_message_cam_program.py @@ -0,0 +1,6 @@ +from odoo import models, fields, api, _ + + +class SFMessageCamProgram(models.Model): + _name = 'sf.cam.work.order.program.knife.plan' + _inherit = ['sf.cam.work.order.program.knife.plan', 'sf.message.template'] diff --git a/sf_message/models/sf_message_functional_tool_assembly.py b/sf_message/models/sf_message_functional_tool_assembly.py new file mode 100644 index 00000000..6b5e4ebf --- /dev/null +++ b/sf_message/models/sf_message_functional_tool_assembly.py @@ -0,0 +1,6 @@ +from odoo import models, fields, api, _ + + +class SFMessagefunctionalToolAssembly(models.Model): + _name = 'sf.functional.tool.assembly' + _inherit = ['sf.functional.tool.assembly', 'sf.message.template'] diff --git a/sf_message/models/sf_message_plan.py b/sf_message/models/sf_message_plan.py new file mode 100644 index 00000000..913b61de --- /dev/null +++ b/sf_message/models/sf_message_plan.py @@ -0,0 +1,6 @@ +from odoo import models, fields, api, _ + + +class SFMessagePlan(models.Model): + _name = 'sf.production.plan' + _inherit = ['sf.production.plan', 'sf.message.template'] diff --git a/sf_message/models/sf_message_purchase.py b/sf_message/models/sf_message_purchase.py new file mode 100644 index 00000000..89836486 --- /dev/null +++ b/sf_message/models/sf_message_purchase.py @@ -0,0 +1,6 @@ +from odoo import models, fields, api, _ + + +class SFMessagePurchase(models.Model): + _name = 'purchase.order' + _inherit = ['purchase.order', 'sf.message.template'] diff --git a/sf_message/models/sf_message_sale.py b/sf_message/models/sf_message_sale.py new file mode 100644 index 00000000..2f9a9c01 --- /dev/null +++ b/sf_message/models/sf_message_sale.py @@ -0,0 +1,6 @@ +from odoo import models, fields, api, _ + + +class SFMessageSale(models.Model): + _name = 'sale.order' + _inherit = ['sale.order', 'sf.message.template'] diff --git a/sf_message/models/sf_message_stock_picking.py b/sf_message/models/sf_message_stock_picking.py new file mode 100644 index 00000000..894dce9d --- /dev/null +++ b/sf_message/models/sf_message_stock_picking.py @@ -0,0 +1,6 @@ +from odoo import models, fields, api, _ + + +class SFMessageStockPicking(models.Model): + _name = 'stock.picking' + _inherit = ['stock.picking', 'sf.message.template'] diff --git a/sf_message/models/sf_message_template.py b/sf_message/models/sf_message_template.py index 481497e0..5f695a52 100644 --- a/sf_message/models/sf_message_template.py +++ b/sf_message/models/sf_message_template.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from odoo import models, fields, api +from abc import ABC, abstractmethod class SfMessageTemplate(models.Model): @@ -47,3 +48,8 @@ class SfMessageTemplate(models.Model): if self.notification_department_id: self.notification_employee_ids = False + @abstractmethod + def dispatch(self, args): + """ + 强迫继承该类必走该抽象方法' + """ diff --git a/sf_message/models/sf_message_workorder.py b/sf_message/models/sf_message_workorder.py new file mode 100644 index 00000000..cab2408d --- /dev/null +++ b/sf_message/models/sf_message_workorder.py @@ -0,0 +1,6 @@ +from odoo import models, fields, api, _ + + +class SFMessageWork(models.Model): + _name = 'mrp.workorder' + _inherit = ['mrp.workorder', 'sf.message.template'] diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index cf4fa621..ddd3bcc5 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -11,7 +11,7 @@ from odoo.exceptions import UserError, ValidationError class sf_production_plan(models.Model): _name = 'sf.production.plan' _description = 'sf_production_plan' - _inherit = ['mail.thread', 'sf.message.template'] + _inherit = ['mail.thread'] # _order = 'state desc, write_date desc' state = fields.Selection([ 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 9bd61132..4756a2c5 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 9e45a141..d19a3b02 100644 --- a/sf_sale/models/sale_order.py +++ b/sf_sale/models/sale_order.py @@ -11,7 +11,7 @@ READONLY_FIELD_STATES = { class ReSaleOrder(models.Model): - _inherit = ['sale.order', 'sf.message.template'] + _inherit = 'sale.order' mrp_production_count = fields.Integer( "Count of MO generated", @@ -183,7 +183,7 @@ class ProductTemplate(models.Model): class RePurchaseOrder(models.Model): - _inherit = ['purchase.order','sf.message.template'] + _inherit = 'purchase.order' mrp_production_count = fields.Integer( "Count of MO Source", diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index da9c9850..d9ab1536 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -181,7 +181,7 @@ class MachineTableToolChangingApply(models.Model): class CAMWorkOrderProgramKnifePlan(models.Model): _name = 'sf.cam.work.order.program.knife.plan' - _inherit = ['mail.thread', 'sf.message.template'] + _inherit = ['mail.thread'] _description = 'CAM工单程序用刀计划' name = fields.Char('工单任务编号') @@ -349,7 +349,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model): class FunctionalToolAssembly(models.Model): _name = 'sf.functional.tool.assembly' - _inherit = ['mail.thread', 'barcodes.barcode_events_mixin', 'sf.message.template'] + _inherit = ['mail.thread', 'barcodes.barcode_events_mixin'] _description = '功能刀具组装' _order = 'tool_loading_time desc, use_tool_time asc' @@ -1143,7 +1143,7 @@ class FunctionalToolAssembly(models.Model): class FunctionalToolDismantle(models.Model): _name = 'sf.functional.tool.dismantle' - _inherit = ["barcodes.barcode_events_mixin", 'mail.thread', 'sf.message.template'] + _inherit = ["barcodes.barcode_events_mixin", 'mail.thread'] _description = '功能刀具拆解' def on_barcode_scanned(self, barcode): From 190d6da217a8a915198e51d91526c39251d03d25 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 18 Sep 2024 17:59:08 +0800 Subject: [PATCH 4/6] =?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_maintenance/models/sf_maintenance.py | 2 +- sf_manufacturing/models/agv_scheduling.py | 4 +- sf_manufacturing/models/mrp_production.py | 8 +- sf_manufacturing/models/mrp_workorder.py | 2 +- sf_mrs_connect/controllers/controllers.py | 110 +++++++++++----------- 5 files changed, 63 insertions(+), 63 deletions(-) diff --git a/sf_maintenance/models/sf_maintenance.py b/sf_maintenance/models/sf_maintenance.py index e20fd97c..46f26257 100644 --- a/sf_maintenance/models/sf_maintenance.py +++ b/sf_maintenance/models/sf_maintenance.py @@ -33,7 +33,7 @@ class SfMaintenanceEquipmentAGVLog(models.Model): class SfMaintenanceEquipment(models.Model): - _inherit = ['maintenance.equipment'] + _inherit = 'maintenance.equipment' _description = '设备' crea_url = "/api/machine_tool/create" diff --git a/sf_manufacturing/models/agv_scheduling.py b/sf_manufacturing/models/agv_scheduling.py index 9bd506d9..a18dc5ef 100644 --- a/sf_manufacturing/models/agv_scheduling.py +++ b/sf_manufacturing/models/agv_scheduling.py @@ -89,8 +89,8 @@ class AgvScheduling(models.Model): workorders: 工单 """ _logger.info('创建AGV调度任务\r\n起点为【%s】,任务类型为【%s】,工单为【%s】' % (agv_start_site_name, agv_route_type, workorders)) - # if not workorders: - # raise UserError(_('工单不能为空')) + if not workorders: + raise UserError(_('工单不能为空')) agv_start_site = self.env['sf.agv.site'].sudo().search([('name', '=', agv_start_site_name)], limit=1) if not agv_start_site: raise UserError(_('不存在名称为【%s】的接驳站,请先创建!' % agv_start_site_name)) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index c1cacb29..0b68852b 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -806,10 +806,10 @@ class MrpProduction(models.Model): backorders = backorders - productions_to_backorder productions_not_to_backorder._post_inventory(cancel_backorder=True) - if self.workorder_ids.filtered(lambda w: w.routing_type in ['表面工艺']): - move_finish = self.env['stock.move'].search([('created_production_id', '=', self.id)]) - if move_finish: - move_finish._action_assign() + # if self.workorder_ids.filtered(lambda w: w.routing_type in ['表面工艺']): + # move_finish = self.env['stock.move'].search([('created_production_id', '=', self.id)]) + # if move_finish: + # move_finish._action_assign() productions_to_backorder._post_inventory(cancel_backorder=True) # if completed products make other confirmed/partially_available moves available, assign them diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 97d172c9..23fd8c79 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -18,7 +18,7 @@ from odoo.addons.sf_mrs_connect.models.ftp_operate import FtpController class ResMrpWorkOrder(models.Model): - _inherit = ['mrp.workorder'] + _inherit = 'mrp.workorder' _order = 'sequence asc' product_tmpl_name = fields.Char('坯料产品名称', related='production_bom_id.bom_line_ids.product_id.name') diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index 7e51ca2c..a4725701 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -31,67 +31,67 @@ class Sf_Mrs_Connect(http.Controller): 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']) + 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'] production._create_workorder(ret) productions.process_range_time() - # else: - # for panel in ret['processing_panel'].split(','): - # # 查询状态为进行中且工序类型为CNC加工的工单 - # cnc_workorder_has = production.workorder_ids.filtered( - # lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done', - # 'rework', - # 'cancel'] and ach.processing_panel == panel) - # if cnc_workorder_has: - # if cnc_workorder_has.cnc_ids: - # cnc_workorder_has.cmm_ids.sudo().unlink() - # cnc_workorder_has.cnc_ids.sudo().unlink() - # request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( - # production) - # 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) - # 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', 'rework' - # 'cancel'] and ap.processing_panel == panel) - # if pre_workorder: - # pre_workorder.write( - # {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())}) + else: + for panel in ret['processing_panel'].split(','): + # 查询状态为进行中且工序类型为CNC加工的工单 + cnc_workorder_has = production.workorder_ids.filtered( + lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done', + 'rework', + 'cancel'] and ach.processing_panel == panel) + if cnc_workorder_has: + if cnc_workorder_has.cnc_ids: + cnc_workorder_has.cmm_ids.sudo().unlink() + cnc_workorder_has.cnc_ids.sudo().unlink() + request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan( + production) + 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) + 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', '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': '已编程'}) return json.JSONEncoder().encode(res) else: From 9dfe34ce9aaf2cc7f0a284e79ac64625497361a2 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 19 Sep 2024 08:45:50 +0800 Subject: [PATCH 5/6] =?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_manufacturing/models/stock.py | 2 +- sf_manufacturing/views/mrp_workorder_view.xml | 2 +- sf_mrs_connect/controllers/controllers.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 3eab030e..daf049eb 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -545,7 +545,7 @@ class ProductionLot(models.Model): class StockPicking(models.Model): - _inherit = ['stock.picking'] + _inherit = 'stock.picking' surface_technics_parameters_id = fields.Many2one('sf.production.process.parameter', string="表面工艺可选参数") diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index d7c22090..bb451f51 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -221,7 +221,7 @@ - diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index a4725701..c5d1cd10 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -45,7 +45,7 @@ class Sf_Mrs_Connect(http.Controller): if download_state is False: res['status'] = -2 res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no']) - # return json.JSONEncoder().encode(res) + return json.JSONEncoder().encode(res) for production in productions: if not production.workorder_ids: production.product_id.model_processing_panel = ret['processing_panel'] From 24f054734312a03312cbe434d9c82a9f77026125 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 19 Sep 2024 08:50:24 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=94=80=E5=94=AE=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_message/__manifest__.py | 2 +- sf_sale/__manifest__.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sf_message/__manifest__.py b/sf_message/__manifest__.py index 492510d1..713a4a5e 100644 --- a/sf_message/__manifest__.py +++ b/sf_message/__manifest__.py @@ -11,7 +11,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['base', 'sf_plan'], + 'depends': ['base', 'sf_plan', 'sf_sale'], 'data': [ 'security/ir.model.access.csv', 'views/sf_message_template_view.xml', diff --git a/sf_sale/__manifest__.py b/sf_sale/__manifest__.py index bed93637..45c95030 100644 --- a/sf_sale/__manifest__.py +++ b/sf_sale/__manifest__.py @@ -10,8 +10,7 @@ """, 'category': 'sf', 'website': 'https://www.sf.jikimo.com', - 'depends': ['sale', 'sale_management', 'web_widget_model_viewer', 'sf_base', 'account', 'purchase', 'delivery', - 'sf_message'], + 'depends': ['sale', 'sale_management', 'web_widget_model_viewer', 'sf_base', 'account', 'purchase', 'delivery'], 'data': [ 'security/group_security.xml', 'security/ir.model.access.csv',