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):