From 7ce2f6c7979d1e9974cab903f252ef0364a8d9bd Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Sat, 14 Sep 2024 17:40:45 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E5=8E=86=E5=8F=B2=E9=94=80=E5=94=AE?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E4=BB=B7=E6=A0=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_mrs_connect/__manifest__.py | 5 ++-- sf_mrs_connect/models/__init__.py | 1 + sf_mrs_connect/models/order_price.py | 29 +++++++++++++++++++++ sf_mrs_connect/models/res_config_setting.py | 5 +++- sf_mrs_connect/security/ir.model.access.csv | 2 +- sf_mrs_connect/views/order_price.xml | 26 ++++++++++++++++++ 6 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 sf_mrs_connect/models/order_price.py create mode 100644 sf_mrs_connect/views/order_price.xml diff --git a/sf_mrs_connect/__manifest__.py b/sf_mrs_connect/__manifest__.py index 3ccd3ac4..1ea4f693 100644 --- a/sf_mrs_connect/__manifest__.py +++ b/sf_mrs_connect/__manifest__.py @@ -10,11 +10,12 @@ """, 'category': 'sf', 'website': 'https://www.sf.cs.jikimo.com', - 'depends': ['sf_base', 'base_setup'], + 'depends': ['sf_base', 'base_setup','sf_bf_connect'], 'data': [ 'data/ir_cron_data.xml', 'security/ir.model.access.csv', - 'views/res_config_settings_views.xml' + 'views/res_config_settings_views.xml', + 'views/order_price.xml', ], 'demo': [ ], diff --git a/sf_mrs_connect/models/__init__.py b/sf_mrs_connect/models/__init__.py index 2f84348c..f01fb4fe 100644 --- a/sf_mrs_connect/models/__init__.py +++ b/sf_mrs_connect/models/__init__.py @@ -1,3 +1,4 @@ from . import ftp_operate from . import res_config_setting from . import sync_common +from . import order_price \ No newline at end of file diff --git a/sf_mrs_connect/models/order_price.py b/sf_mrs_connect/models/order_price.py new file mode 100644 index 00000000..d5841bf7 --- /dev/null +++ b/sf_mrs_connect/models/order_price.py @@ -0,0 +1,29 @@ +from odoo import fields, models, api + + +class OrderPrice(models.Model): + _name = 'order.price' + _description = '订单价格对比' + sale_order_id = fields.Many2one('sale.order', '销售订单') + bfm_order_name = fields.Char(related="sale_order_id.default_code", string='bfm订单号') + sale_order_name = fields.Char(related="sale_order_id.name", string='销售订单号') + currency_id = fields.Many2one( + related='sale_order_id.currency_id', string='货币', store=True) + sale_order_amount_total = fields.Monetary(related="sale_order_id.amount_total", tracking=4, string='销售订单金额') + bfm_amount_total = fields.Float(string='价格合计', compute='_compute_bfm_amount_total', store=True) + + def is_float(self,value): + try: + float(value) + return True + except ValueError: + return False + @api.depends('sale_order_id.remark') + def _compute_bfm_amount_total(self): + for record in self: + amount_total = 0 + for line in record.sale_order_id.order_line: + # 判断remark是否存在并且是否是数字 + if line.remark and self.is_float(line.remark): + amount_total += float(line.remark) + record.bfm_amount_total = amount_total \ No newline at end of file diff --git a/sf_mrs_connect/models/res_config_setting.py b/sf_mrs_connect/models/res_config_setting.py index 04693fa7..c6f19502 100644 --- a/sf_mrs_connect/models/res_config_setting.py +++ b/sf_mrs_connect/models/res_config_setting.py @@ -184,7 +184,10 @@ class ResConfigSettings(models.TransientModel): new_price = res_order_lines_map.get(str(index)) if order_line: # 修改单价 - order_line.write({'remark': new_price}) + order_line.write({'remark': new_price*order_line.product_uom_qty}) + order_price = self.env['order.price'].sudo().search([('sale_order_id', '=',need_change_sale_order.id )]) + if not order_price: + self.env['order.price'].sudo().create({'sale_order_id':need_change_sale_order.id}) else: logging.error('同步销售订单价格失败 {}'.format(response.text)) raise UserError('同步销售订单价格失败') diff --git a/sf_mrs_connect/security/ir.model.access.csv b/sf_mrs_connect/security/ir.model.access.csv index 0ed43a62..60d5cea5 100644 --- a/sf_mrs_connect/security/ir.model.access.csv +++ b/sf_mrs_connect/security/ir.model.access.csv @@ -1,7 +1,7 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_sf_static_resource_datasync,sf_static_resource_datasync,model_sf_static_resource_datasync,base.group_user,1,1,1,1 - +access_order_price,order.price,model_order_price,base.group_user,1,1,1,1 diff --git a/sf_mrs_connect/views/order_price.xml b/sf_mrs_connect/views/order_price.xml new file mode 100644 index 00000000..ea80b7b4 --- /dev/null +++ b/sf_mrs_connect/views/order_price.xml @@ -0,0 +1,26 @@ + + + + + bfm订单价格对比 + order.price + tree,form + + + order.price.list + order.price + + + + + + + + + + + \ No newline at end of file From 92037f3f04465a87560148f5b33a1bff79fbc2f3 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 18 Sep 2024 10:23:42 +0800 Subject: [PATCH 02/10] =?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 4acae010099e62a3dd19c14b1e221d7679e25644 Mon Sep 17 00:00:00 2001 From: hujiaying Date: Wed, 18 Sep 2024 15:34:04 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=8E=92=E7=A8=8B=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=8E=92=E7=A8=8B=E8=AE=A1=E5=88=92=E8=AE=A2=E5=8D=95=E4=BA=A4?= =?UTF-8?q?=E8=B4=A7=E6=97=B6=E9=97=B4=E4=B8=BAnull=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=A4=84=E7=90=86=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_plan/models/custom_plan.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sf_plan/models/custom_plan.py b/sf_plan/models/custom_plan.py index 6fef2a31..ce4f9adc 100644 --- a/sf_plan/models/custom_plan.py +++ b/sf_plan/models/custom_plan.py @@ -74,16 +74,21 @@ class sf_production_plan(models.Model): if self.date_planned_start: self.date_planned_finished = self.date_planned_start + timedelta(hours=1) - #处理计划状态非代排程,计划结束时间为空的数据处理 + #处理计划状态非待排程,计划结束时间为空的数据处理 def deal_no_date_planned_finished(self): plans = self.env['sf.production.plan'].search( [('date_planned_finished', '=', False), ('state', 'in', ['processing', 'done', 'finished'])]) for item in plans: if item.date_planned_start: item.date_planned_finished = item.date_planned_start + timedelta(hours=1) - if not item.order_deadline and item.date_planned_start: - item.order_deadline = item.date_planned_start + timedelta(days=7) + # 处理计划订单截止时间为空的数据 + def deal_no_order_deadline(self): + plans = self.env['sf.production.plan'].sudo().search( + [('order_deadline', '=', False)]) + for item in plans: + if item.date_planned_start: + item.order_deadline = item.date_planned_start + timedelta(days=7) @api.model def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None): From ce6b36a77e85a5a9b3c5825e178593fa7607da84 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 18 Sep 2024 15:39:42 +0800 Subject: [PATCH 04/10] 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 ac43be12623c3d622d0935135596d08f23604050 Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Wed, 18 Sep 2024 16:36:52 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E9=80=82=E7=94=A8=E5=88=80=E5=85=B7?= =?UTF-8?q?=E7=89=A9=E6=96=99=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5=20?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=8F=AA=E8=83=BD=E5=8E=BB=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E3=80=82=E5=8F=96=E6=B6=88=E5=BF=85=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/functional_cutting_tool_model.py | 2 +- sf_tool_management/views/tool_views.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sf_tool_management/models/functional_cutting_tool_model.py b/sf_tool_management/models/functional_cutting_tool_model.py index fe2c68c5..39048bfd 100644 --- a/sf_tool_management/models/functional_cutting_tool_model.py +++ b/sf_tool_management/models/functional_cutting_tool_model.py @@ -3,4 +3,4 @@ from odoo import models, fields class SyncFunctionalCuttingToolModel(models.Model): _inherit = 'sf.functional.cutting.tool.model' - cutting_tool_type_ids = fields.Many2many('sf.cutting.tool.type', string='适用刀具物料类型', required=True) \ No newline at end of file + cutting_tool_type_ids = fields.Many2many('sf.cutting.tool.type', string='适用刀具物料类型') \ No newline at end of file diff --git a/sf_tool_management/views/tool_views.xml b/sf_tool_management/views/tool_views.xml index 24379b9a..d483e1a3 100644 --- a/sf_tool_management/views/tool_views.xml +++ b/sf_tool_management/views/tool_views.xml @@ -8,7 +8,7 @@ - + From 43f53197c4d5e8125ef6867f155316e04e0272c4 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 18 Sep 2024 17:39:06 +0800 Subject: [PATCH 06/10] =?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 07/10] =?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 08/10] =?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 402a323673959d6081d5d5f2e74034feaf11ca04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Thu, 19 Sep 2024 08:49:23 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=AB=E7=A0=81?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E8=B5=B7=E7=82=B9=E6=8E=A5=E9=A9=B3=E7=AB=99?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wizard/workpiece_delivery_wizard.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sf_manufacturing/wizard/workpiece_delivery_wizard.py b/sf_manufacturing/wizard/workpiece_delivery_wizard.py index 4ee0928c..472910f9 100644 --- a/sf_manufacturing/wizard/workpiece_delivery_wizard.py +++ b/sf_manufacturing/wizard/workpiece_delivery_wizard.py @@ -179,18 +179,14 @@ class WorkpieceDeliveryWizard(models.TransientModel): self.feeder_station_destination_id = self.route_id.end_site_id.id def on_barcode_scanned(self, barcode): + delivery_type = self.env.context.get('default_delivery_type') # 判断barcode是否是数字 if not barcode.isdigit(): # 判断是否是AGV接驳站名称 agv_site = self.env['sf.agv.site'].search([('name', '=', barcode)]) - if agv_site: - if not self.feeder_station_start_id: - self.feeder_station_start_id = agv_site.id - else: - if self.feeder_station_start_id.id != agv_site.id: - raise UserError('起点接驳站不匹配!') + self.feeder_station_start_id = agv_site.id # 修正:移除 .id return - delivery_type = self.env.context.get('default_delivery_type') + if delivery_type == '上产线': workorder = self.env['mrp.workorder'].search( [('production_line_state', '=', '待上产线'), ('rfid_code', '=', barcode), @@ -214,7 +210,7 @@ class WorkpieceDeliveryWizard(models.TransientModel): self.production_ids |= workorder.production_id self.workorder_ids |= workorder - down_product_agv_scheduling = self.get_down_product_agv_scheduling() + down_product_agv_scheduling = workorder.get_down_product_agv_scheduling() if down_product_agv_scheduling: if not self.feeder_station_start_id: self.feeder_station_start_id = down_product_agv_scheduling.end_site_id.id @@ -226,4 +222,11 @@ class WorkpieceDeliveryWizard(models.TransientModel): raise UserError('该rfid码对应的工单不存在') return + @api.onchange('feeder_station_start_id') + def on_start_id_change(self): + if self.delivery_type == '运送空料架' and len(self.workorder_ids) > 0: + down_product_agv_scheduling = self.workorder_ids[0].get_down_product_agv_scheduling() + if down_product_agv_scheduling and self.feeder_station_start_id \ + and down_product_agv_scheduling.end_site_id.id != self.feeder_station_start_id.id: + raise UserError('当前接驳站不匹配!') From 24f054734312a03312cbe434d9c82a9f77026125 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 19 Sep 2024 08:50:24 +0800 Subject: [PATCH 10/10] =?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',