From 934b59d213e0d2c5fa9c40e873d330ed6733e8f9 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 14 May 2024 10:51:38 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=9D=AF=E6=96=99=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=B7=AF=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_bf_connect/controllers/controllers.py | 7 +++--- sf_manufacturing/data/stock_data.xml | 23 +++++++++++++----- sf_manufacturing/models/mrp_production.py | 26 ++++++++++----------- sf_manufacturing/models/mrp_workorder.py | 1 + sf_manufacturing/models/product_template.py | 10 +++++--- sf_mrs_connect/controllers/controllers.py | 16 ++++++------- sf_sale/models/quick_easy_order.py | 4 ++-- sf_sale/models/quick_easy_order_old.py | 4 ++-- sf_sale/views/sale_order_view.xml | 4 ++-- 9 files changed, 56 insertions(+), 39 deletions(-) diff --git a/sf_bf_connect/controllers/controllers.py b/sf_bf_connect/controllers/controllers.py index 4689345c..90c7e6c5 100644 --- a/sf_bf_connect/controllers/controllers.py +++ b/sf_bf_connect/controllers/controllers.py @@ -52,7 +52,7 @@ class Sf_Bf_Connect(http.Controller): self_machining_embryo = request.env['product.template'].sudo().no_bom_product_create( self_machining_id, item, - order_id, 'self_machining', i) + order_id, 'self_machining', i, product) # 创建坯料的bom self_machining_bom = request.env['mrp.bom'].with_user( request.env.ref("base.user_admin")).bom_create( @@ -78,7 +78,7 @@ class Sf_Bf_Connect(http.Controller): item, order_id, 'subcontract', - i) + i, product) if outsource_embryo == -3: res['status'] = -3 res['message'] = '该订单模型的材料型号在您分配的工厂里暂未设置获取方式和供应商,请先配置再进行分配' @@ -105,7 +105,8 @@ class Sf_Bf_Connect(http.Controller): purchase_embryo = request.env['product.template'].sudo().no_bom_product_create(purchase_id, item, order_id, - 'purchase', i) + 'purchase', i, + product) if purchase_embryo == -3: res['status'] = -3 res['message'] = '该订单模型的材料型号在您分配的工厂里暂未设置获取方式和供应商,请先配置再进行分配' diff --git a/sf_manufacturing/data/stock_data.xml b/sf_manufacturing/data/stock_data.xml index 72559691..3558e892 100644 --- a/sf_manufacturing/data/stock_data.xml +++ b/sf_manufacturing/data/stock_data.xml @@ -1,7 +1,7 @@ - + 工序编码规则 mrp.routing.workcenter 4 @@ -74,12 +74,23 @@ True 11 - + - - - - + + + + + + + + + + + + + + + diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index e3b83f21..354b47e1 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -304,21 +304,21 @@ class MrpProduction(models.Model): 'state': 'pending', }] if production.product_id.categ_id.type == '成品': - if production.product_id.id in product_id_to_production_names: + # if production.product_id.id in product_id_to_production_names: # 同一个产品多个制造订单对应一个编程单和模型库 # 只调用一次fetchCNC,并将所有生产订单的名称作为字符串传递 - if not production.programming_no: - production_programming = self.search( - [('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)], - limit=1, order='id asc') - logging.info('production_programming1:%s' % production_programming.programming_no) - if not production_programming.programming_no: - production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id])) - else: - logging.info('production_programming2:%s' % production_programming.programming_no) - production.write({'programming_no': production_programming.programming_no, - 'programming_state': '编程中'}) - # 根据加工面板的面数及对应的工序模板生成工单 + # if not production.programming_no: + # production_programming = self.search( + # [('product_id.id', '=', production.product_id.id), ('origin', '=', production.origin)], + # limit=1, order='id asc') + # logging.info('production_programming1:%s' % production_programming.programming_no) + # if not production_programming.programming_no: + # production.fetchCNC(', '.join(product_id_to_production_names[production.product_id.id])) + # else: + # logging.info('production_programming2:%s' % production_programming.programming_no) + # production.write({'programming_no': production_programming.programming_no, + # 'programming_state': '编程中'}) + # # 根据加工面板的面数及对应的工序模板生成工单 i = 0 processing_panel_len = len(production.product_id.model_processing_panel.split(',')) for k in (production.product_id.model_processing_panel.split(',')): diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 87a5a87f..2214696c 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -1040,6 +1040,7 @@ class CNCprocessing(models.Model): # 将FTP的nc文件下载到临时目录 def download_file_tmp(self, production_no, processing_panel): remotepath = os.path.join('/NC', production_no, 'return', processing_panel) + serverdir = os.path.join('/tmp', production_no, 'return', processing_panel) ftp_resconfig = self.env['res.config.settings'].get_values() ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'], ftp_resconfig['ftp_password']) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index 3e91e6a3..8ab69366 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -9,8 +9,8 @@ from odoo.exceptions import ValidationError 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): @@ -660,8 +660,12 @@ class ResProductMo(models.Model): return attachment # 创建坯料 - def no_bom_product_create(self, product_id, item, order_id, route_type, i): + def no_bom_product_create(self, product_id, item, order_id, route_type, i, finish_product): no_bom_copy_product_id = product_id.with_user(self.env.ref("base.user_admin")).copy() + if finish_product.model_process_parameters_ids: + surface_technology = self.env['stock.rule'].sudo().search([('name', '=', '表面工艺外协')]) + if surface_technology: + no_bom_copy_product_id.route_ids |= surface_technology no_bom_copy_product_id.product_tmpl_id.active = True materials_id = self.env['sf.production.materials'].search( [('materials_no', '=', item['texture_code'])]) diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index 4b45014a..12e22d01 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -37,14 +37,14 @@ class Sf_Mrs_Connect(http.Controller): # if ret['glb_file']: # cnc_production.glb_file = base64.b64encode(ret['glb_file']) # 拉取所有加工面的程序文件 - for r in ret['processing_panel']: - 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 == 0: - res['status'] = -2 - res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name) - return json.JSONEncoder().encode(res) + # for r in ret['processing_panel']: + # 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 == 0: + # res['status'] = -2 + # res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name) + # return json.JSONEncoder().encode(res) logging.info('创建cnc工单') program_path_tmp = os.path.join('/tmp', ret['folder_name'], 'return', r) # program_path_tmp = "C://Users//43484//Desktop//机企猫工作文档//其他//model_analysis" diff --git a/sf_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index 259655ee..775b901a 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 768c483c..241170a1 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/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml index 8350c761..ba7543b7 100644 --- a/sf_sale/views/sale_order_view.xml +++ b/sf_sale/views/sale_order_view.xml @@ -198,7 +198,7 @@ - check_status desc,create_date asc + create_date desc False @@ -223,7 +223,7 @@ - date_order asc + create_date desc False From 1c441d388f24bf2d496311f77798738c86a330c6 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 16 May 2024 09:41:57 +0800 Subject: [PATCH 2/6] =?UTF-8?q?1=E3=80=81=E5=BA=8F=E5=88=97=E5=8F=B7?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=B7=BB=E5=8A=A0Rfid=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=9A=84=E9=87=8D=E5=A4=8D=E6=A0=A1=E9=AA=8C=EF=BC=9B=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E6=A8=A1=E5=9E=8B=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E8=A7=86=E5=9B=BE=E7=9A=84=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=9B=E4=BC=98=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=BB=84?= =?UTF-8?q?=E8=A3=85=E6=B5=81=E7=A8=8B=E7=9A=84=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/models/tool_base_new.py | 2 +- sf_manufacturing/models/stock.py | 12 ++++++++++ .../views/functional_tool_views.xml | 19 +--------------- sf_tool_management/wizard/wizard.py | 22 +++++++++---------- 4 files changed, 25 insertions(+), 30 deletions(-) diff --git a/sf_base/models/tool_base_new.py b/sf_base/models/tool_base_new.py index 3aa85ceb..7977ed80 100644 --- a/sf_base/models/tool_base_new.py +++ b/sf_base/models/tool_base_new.py @@ -329,7 +329,7 @@ class ToolInventory(models.Model): blade_number = fields.Integer('刃数(个)') extension = fields.Float('伸出长度(mm)') work_material = fields.Selection([('钢', '钢'), ('铝', '铝')], string='加工材料') - life_span = fields.Float('寿命(h)') + life_span = fields.Float('寿命(min)') tool_groups_id = fields.Many2one('sf.tool.groups', string='刀具组') diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 4f4f35a5..a83065bd 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -425,6 +425,18 @@ class ProductionLot(models.Model): # 'target': 'self', # } + @api.model_create_multi + def create(self, vals_list): + for vals in vals_list: + if vals.get('rfid'): + lots = self.env['stock.lot'].search([('rfid', '=', vals['rfid'])]) + if lots: + for lot in lots: + raise ValidationError('Rfid【%s】已被序列号为【%s】的【%s】产品占用!' % ( + lot.rfid, lot.name, lot.product_id.name)) + records = super(ProductionLot, self).create(vals_list) + return records + class StockPicking(models.Model): _inherit = 'stock.picking' diff --git a/sf_tool_management/views/functional_tool_views.xml b/sf_tool_management/views/functional_tool_views.xml index 53e050d9..abad7539 100644 --- a/sf_tool_management/views/functional_tool_views.xml +++ b/sf_tool_management/views/functional_tool_views.xml @@ -184,27 +184,10 @@ sf.functional.cutting.tool.entity - - - + - - - - - - - - - - - - - - - diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index d6981922..c867d708 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -615,17 +615,17 @@ class FunctionalToolAssemblyOrder(models.TransientModel): self.env['stock.picking'].create_stocking_picking(stock_lot, functional_tool_assembly, self) # 刀具物料出库 if self.handle_code_id: - product_id.tool_material_stock_moves(self.handle_code_id) + product_id.tool_material_stock_moves(self.handle_code_id, self.assembly_order_code) if self.integral_product_id: - self.integral_product_id.material_stock_moves(self.integral_freight_barcode) + self.integral_product_id.material_stock_moves(self.integral_freight_barcode,self.assembly_order_code) if self.blade_product_id: - self.blade_product_id.material_stock_moves(self.blade_freight_barcode) + self.blade_product_id.material_stock_moves(self.blade_freight_barcode,self.assembly_order_code) if self.bar_product_id: - self.bar_product_id.material_stock_moves(self.bar_freight_barcode) + self.bar_product_id.material_stock_moves(self.bar_freight_barcode,self.assembly_order_code) if self.pad_product_id: - self.pad_product_id.material_stock_moves(self.pad_freight_barcode) + self.pad_product_id.material_stock_moves(self.pad_freight_barcode,self.assembly_order_code) if self.chuck_product_id: - self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode) + self.chuck_product_id.material_stock_moves(self.chuck_freight_barcode,self.assembly_order_code) # ============================创建功能刀具列表、安全库存记录=============================== # 封装功能刀具数据 @@ -820,7 +820,7 @@ class ProductProduct(models.Model): stock_location_id = self.env['stock.location'].search([('name', '=', '组装后')]) # 创建功能刀具该批次/序列号 库存移动和移动历史 stock_lot.create_stock_quant(location_inventory_id, stock_location_id, functional_tool_assembly.id, - '功能刀具组装', obj, obj.after_tool_groups_id) + self.assembly_order_code, obj, obj.after_tool_groups_id) return stock_lot @@ -846,7 +846,7 @@ class ProductProduct(models.Model): num = "%03d" % m return code + str(num) - def tool_material_stock_moves(self, tool_material): + def tool_material_stock_moves(self, tool_material, assembly_order_code): """ 对刀具物料进行库存移动到 刀具组装位置 """ @@ -854,12 +854,12 @@ class ProductProduct(models.Model): location_inventory_id = tool_material.quant_ids.location_id[-1] stock_location_id = self.env['stock.location'].search([('name', '=', '刀具组装位置')]) # 创建功能刀具该批次/序列号 库存移动和移动历史 - tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, '功能刀具组装', False, False) + tool_material.create_stock_quant(location_inventory_id, stock_location_id, None, assembly_order_code, False, False) - def material_stock_moves(self, shelf_location_barcode): + def material_stock_moves(self, shelf_location_barcode, assembly_order_code): # 创建库存移动记录 stock_move_id = self.env['stock.move'].sudo().create({ - 'name': '功能刀具组装', + 'name': assembly_order_code, 'product_id': self.id, 'location_id': self.env['stock.location'].search([('name', '=', '刀具房')]).id, 'location_dest_id': self.env['stock.location'].search([('name', '=', '刀具组装位置')]).id, From 37cf4ca435a349a62c6859351eb663ee0a3a1475 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 16 May 2024 09:42:35 +0800 Subject: [PATCH 3/6] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9Esf=5Foca?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_oca/__init__.py | 1 + sf_oca/__manifest__.py | 23 ++++ sf_oca/models/__init__.py | 1 + sf_oca/models/tier_validation.py | 18 +++ sf_oca/security/ir.model.access.csv | 1 + .../templates/tier_validation_templates.xml | 122 ++++++++++++++++++ 6 files changed, 166 insertions(+) create mode 100644 sf_oca/__init__.py create mode 100644 sf_oca/__manifest__.py create mode 100644 sf_oca/models/__init__.py create mode 100644 sf_oca/models/tier_validation.py create mode 100644 sf_oca/security/ir.model.access.csv create mode 100644 sf_oca/templates/tier_validation_templates.xml diff --git a/sf_oca/__init__.py b/sf_oca/__init__.py new file mode 100644 index 00000000..9a7e03ed --- /dev/null +++ b/sf_oca/__init__.py @@ -0,0 +1 @@ +from . import models \ No newline at end of file diff --git a/sf_oca/__manifest__.py b/sf_oca/__manifest__.py new file mode 100644 index 00000000..ee03cbaa --- /dev/null +++ b/sf_oca/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2017-19 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "sf_oca", + "version": "1.0", + 'summary': '智能工厂oca模块', + 'sequence': 1, + 'description': """ +在本模块,进行流程的审核 + """, + 'category': 'sf', + 'website': 'https://www.sf.jikimo.com', + "depends": ["base_tier_validation_forward"], + "data": [ + "security/ir.model.access.csv", + "templates/tier_validation_templates.xml", + ], + "assets": {}, + 'license': 'LGPL-3', + 'installable': True, + 'application': False, + 'auto_install': False, +} diff --git a/sf_oca/models/__init__.py b/sf_oca/models/__init__.py new file mode 100644 index 00000000..1b2d1ace --- /dev/null +++ b/sf_oca/models/__init__.py @@ -0,0 +1 @@ +from . import tier_validation \ No newline at end of file diff --git a/sf_oca/models/tier_validation.py b/sf_oca/models/tier_validation.py new file mode 100644 index 00000000..1ca4c29c --- /dev/null +++ b/sf_oca/models/tier_validation.py @@ -0,0 +1,18 @@ +# Copyright 2017-19 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from ast import literal_eval + +from lxml import etree + +from odoo import _, api, fields, models +from odoo.exceptions import ValidationError +from odoo.tools.misc import frozendict + + +class TierValidation(models.AbstractModel): + _inherit = "tier.validation" + + def _notify_restarted_review_body(self): + return _("%s 取消审批请求.") % (self.env.user.name) + diff --git a/sf_oca/security/ir.model.access.csv b/sf_oca/security/ir.model.access.csv new file mode 100644 index 00000000..97dd8b91 --- /dev/null +++ b/sf_oca/security/ir.model.access.csv @@ -0,0 +1 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink diff --git a/sf_oca/templates/tier_validation_templates.xml b/sf_oca/templates/tier_validation_templates.xml new file mode 100644 index 00000000..24108bcc --- /dev/null +++ b/sf_oca/templates/tier_validation_templates.xml @@ -0,0 +1,122 @@ + + + + + + + + + From 20ecd9d949477c036e940bfc7245d4c575055cb1 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 16 May 2024 14:04:35 +0800 Subject: [PATCH 4/6] =?UTF-8?q?1=E3=80=81=E5=B0=86=E5=92=8C=E5=88=80?= =?UTF-8?q?=E5=85=B7=E7=9B=B8=E5=85=B3=E7=9A=84=E6=A8=A1=E5=9E=8B=E7=9A=84?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=9B=B4=E5=BE=84=E5=AD=97=E6=AE=B5=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=BB=8Eint=E6=94=B9=E4=B8=BAfloat=EF=BC=9B2=E3=80=81?= =?UTF-8?q?=E6=A0=87=E5=87=86=E5=88=80=E5=BA=93tree=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0Rfid=E5=AD=97=E6=AE=B5=EF=BC=9B=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BB=8E=E4=B8=AD=E6=8E=A7=E8=8E=B7=E5=8F=96=E6=A0=87?= =?UTF-8?q?=E5=87=86=E5=88=80=E5=BA=93=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_base/security/ir.model.access.csv | 1 + sf_tool_management/models/base.py | 10 +++--- sf_tool_management/models/functional_tool.py | 8 ++--- .../models/maintenance_equipment.py | 33 +++++++++++++------ .../views/sf_maintenance_equipment.xml | 1 + sf_tool_management/wizard/wizard.py | 10 +++--- 6 files changed, 39 insertions(+), 24 deletions(-) diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index f3e156f8..4e610165 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -49,6 +49,7 @@ access_sf_functional_cutting_tool_admin,sf_functional_cutting_tool_admin,model_s access_sf_functional_cutting_tool_model,sf_functional_cutting_tool_model,model_sf_functional_cutting_tool_model,base.group_user,1,1,1,0 access_sf_functional_cutting_tool_model_admin,sf_functional_cutting_tool_model_admin,model_sf_functional_cutting_tool_model,base.group_system,1,1,1,0 access_sf_fixture_material,sf_fixture_material,model_sf_fixture_material,base.group_user,1,1,1,0 +access_sf_fixture_material_group_sf_stock_user,sf_fixture_material_group_sf_stock_user,model_sf_fixture_material,sf_warehouse.group_sf_stock_user,1,1,1,0 access_sf_fixture_material_admin,sf_fixture_material_admin,model_sf_fixture_material,base.group_system,1,1,1,0 access_sf_fixture_materials_basic_parameters,sf_fixture_materials_basic_parameters,model_sf_fixture_materials_basic_parameters,base.group_user,1,1,1,0 access_sf_fixture_materials_basic_parameters_admin,sf_fixture_materials_basic_parameters_admin,model_sf_fixture_materials_basic_parameters,base.group_system,1,1,1,0 diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index b00ab209..533df3a6 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -41,7 +41,7 @@ class MachineTableToolChangingApply(models.Model): [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), ('直装固定式', '直装固定式')], string='刀位接口型号') - diameter = fields.Integer(string='刀具直径(mm)') + diameter = fields.Float(string='刀具直径(mm)') knife_tip_r_angle = fields.Float(string='刀尖R角(mm)') max_lifetime_value = fields.Integer(string='最大寿命值(min)') alarm_value = fields.Integer(string='报警值(min)') @@ -209,7 +209,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model): functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', compute='_compute_tool_number', store=True) tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_tool_number', store=True) - diameter = fields.Integer(string='刀具直径(mm)', compute='_compute_tool_number', store=True) + diameter = fields.Float(string='刀具直径(mm)', compute='_compute_tool_number', store=True) tool_included_angle = fields.Float(string='刀尖R角(mm)', compute='_compute_tool_number', store=True) tool_loading_length = fields.Float(string='总长度(mm)', compute='_compute_tool_number', store=True) extension_length = fields.Float(string='伸出长(mm)') @@ -368,7 +368,7 @@ class FunctionalToolAssembly(models.Model): functional_tool_name = fields.Char(string='功能刀具名称', readonly=True) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, group_expand='_read_group_functional_tool_type_ids') - functional_tool_diameter = fields.Integer(string='功能刀具直径(mm)', readonly=True) + functional_tool_diameter = fields.Float(string='功能刀具直径(mm)', readonly=True) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True) new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) @@ -542,7 +542,7 @@ class FunctionalToolAssembly(models.Model): after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', readonly=True) after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='组装后功能刀具类型', readonly=True) - after_assembly_functional_tool_diameter = fields.Integer(string='组装后功能刀具直径(mm)', readonly=True) + after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)', readonly=True) after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)', readonly=True) after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', readonly=True) cut_time = fields.Integer(string='已切削时间(min)', readonly=True) @@ -696,7 +696,7 @@ class FunctionalToolDismantle(models.Model): tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True, compute='_compute_functional_tool_num') tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', compute='_compute_functional_tool_num', store=True) - diameter = fields.Integer(string='刀具直径(mm)', compute='_compute_functional_tool_num', store=True) + diameter = fields.Float(string='刀具直径(mm)', compute='_compute_functional_tool_num', store=True) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', compute='_compute_functional_tool_num', store=True) rfid = fields.Char('Rfid', compute='_compute_functional_tool_num', store=True) rfid_dismantle = fields.Char('Rfid(已拆解)', readonly=True) diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index e855d2a9..989b4578 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -22,7 +22,7 @@ class FunctionalCuttingToolEntity(models.Model): sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', group_expand='_read_group_mrs_cutting_tool_type_id', compute_sudo=True) - functional_tool_diameter = fields.Integer(string='刀具直径(mm)', readonly=True) + functional_tool_diameter = fields.Float(string='刀具直径(mm)', readonly=True) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True) new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) @@ -244,7 +244,7 @@ class FunctionalToolWarning(models.Model): functional_tool_name_id = fields.Many2one('sf.functional.tool.assembly', string='功能刀具名称') barcode_id = fields.Many2one('stock.lot', string='功能刀具序列号', related='functional_tool_name_id.barcode_id') mrs_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型') - diameter = fields.Integer(string='刀具直径(mm)') + diameter = fields.Float(string='刀具直径(mm)') knife_tip_r_angle = fields.Float(string='刀尖R角(mm)') # 其他信息 install_tool_time = fields.Datetime("刀具组装时间", related='functional_tool_name_id.tool_loading_time') @@ -298,7 +298,7 @@ class StockMoveLine(models.Model): functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', store=True, group_expand='_read_group_functional_tool_type_id') functional_tool_name = fields.Char('刀具名称') - diameter = fields.Integer(string='刀具直径(mm)') + diameter = fields.Float(string='刀具直径(mm)') knife_tip_r_angle = fields.Float(string='刀尖R角(mm)') install_tool_time = fields.Datetime("刀具组装时间", default=fields.Datetime.now()) code = fields.Char('编码') @@ -320,7 +320,7 @@ class RealTimeDistributionOfFunctionalTools(models.Model): tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', readonly=False, required=True) sf_cutting_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=False, group_expand='_read_mrs_cutting_tool_type_ids', store=True) - diameter = fields.Integer(string='刀具直径(mm)', readonly=False) + diameter = fields.Float(string='刀具直径(mm)', readonly=False) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=False) tool_stock_num = fields.Integer(string='刀具房数量') side_shelf_num = fields.Integer(string='线边刀库数量') diff --git a/sf_tool_management/models/maintenance_equipment.py b/sf_tool_management/models/maintenance_equipment.py index f693ed2c..a4bcf751 100644 --- a/sf_tool_management/models/maintenance_equipment.py +++ b/sf_tool_management/models/maintenance_equipment.py @@ -13,9 +13,10 @@ class SfMaintenanceEquipmentTool(models.Model): image = fields.Binary('图片', related='functional_tool_name_id.image') tool_code = fields.Char('功能刀具编码', related='functional_tool_name_id.code') + rfid = fields.Char('Rfid', related='functional_tool_name_id.rfid') functional_tool_type = fields.Char('功能刀具类型', related='functional_tool_name_id.sf_cutting_tool_type_id.name') tool_groups = fields.Char('刀具组', related='functional_tool_name_id.tool_groups_id.name') - diameter = fields.Integer('直径(mm)', related='functional_tool_name_id.functional_tool_diameter') + diameter = fields.Float('直径(mm)', related='functional_tool_name_id.functional_tool_diameter') knife_tip_r_angle = fields.Float('刀尖R角(mm)', related='functional_tool_name_id.knife_tip_r_angle') life_value_max = fields.Integer('最大寿命值(min)', related='functional_tool_name_id.max_lifetime_value') alarm_value = fields.Integer('报警值(min)', related='functional_tool_name_id.alarm_value') @@ -26,15 +27,15 @@ class SfMaintenanceEquipmentTool(models.Model): # if datas: # print(datas) - @api.model_create_multi - def create(self, vals_list): - tools = super().create(vals_list) - for tool in tools: - self.env['sf.machine.table.tool.changing.apply'].sudo().create({ - 'maintenance_equipment_id': tool.equipment_id.id, - 'cutter_spacing_code_id': tool.id - }) - return tools + # @api.model_create_multi + # def create(self, vals_list): + # tools = super().create(vals_list) + # for tool in tools: + # self.env['sf.machine.table.tool.changing.apply'].sudo().create({ + # 'maintenance_equipment_id': tool.equipment_id.id, + # 'cutter_spacing_code_id': tool.id + # }) + # return tools class SfMaintenanceEquipment(models.Model): @@ -68,6 +69,18 @@ class SfMaintenanceEquipment(models.Model): [('equipment_id', '=', maintenance_equipment_id.id), ('code', '=', tool_id)]) functional_tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search( [('rfid', '=', data['RfidCode'])]) + if functional_tool_id: + # 查询该功能刀具是否已经装在机床内其他位置,如果是就删除 + equipment_tools = self.env['maintenance.equipment.tool'].sudo().search( + [('functional_tool_name_id', '=', functional_tool_id.id), ('code', '!=', tool_id)]) + if equipment_tools: + for item in equipment_tools: + item.write({ + 'functional_tool_name_id': False, + 'tool_install_time': None + }) + else: + logging.info('Rfid为【%s】的功能刀具不存在!' % data['RfidCode']) time = None if data['AddDatetime']: datatime = str(data['AddDatetime']) diff --git a/sf_tool_management/views/sf_maintenance_equipment.xml b/sf_tool_management/views/sf_maintenance_equipment.xml index 8b3de5a9..4bd8870d 100644 --- a/sf_tool_management/views/sf_maintenance_equipment.xml +++ b/sf_tool_management/views/sf_maintenance_equipment.xml @@ -13,6 +13,7 @@ + diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index c867d708..cb32833a 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -27,7 +27,7 @@ class ToolChangeRequirementInformation(models.TransientModel): [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), ('直装固定式', '直装固定式')], string='刀位接口型号', readonly=True) - diameter = fields.Integer(string='刀具直径(mm)', readonly=True) + diameter = fields.Float(string='刀具直径(mm)', readonly=True) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) alarm_value = fields.Integer(string='报警值(min)', readonly=True) @@ -39,7 +39,7 @@ class ToolChangeRequirementInformation(models.TransientModel): # 待换功能刀具信息 replacement_tool_name = fields.Char(string='待换功能刀具名称', compute='_compute_name') replacement_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='待换功能刀具类型') - replacement_diameter = fields.Integer(string='待换刀具直径(mm)') + replacement_diameter = fields.Float(string='待换刀具直径(mm)') replacement_knife_tip_r_angle = fields.Float(string='待换刀具刀尖R角(mm)', required=True) replacement_tool_setting_length = fields.Float(string='待换刀具总长度(mm)', required=True) replacement_extension_length = fields.Float(string='待换刀具伸出长(mm)') @@ -153,7 +153,7 @@ class ToolTransferRequestInformation(models.TransientModel): [('BT刀柄式', 'BT刀柄式'), ('SK刀柄式', 'SK刀柄式'), ('HSK刀柄式', 'HSK刀柄式'), ('CAT刀柄式', 'CAT刀柄式'), ('ISO刀盘式', 'ISO刀盘式'), ('DIN刀盘式', 'DIN刀盘式'), ('直装固定式', '直装固定式')], string='刀位接口型号', readonly=True) - diameter = fields.Integer(string='刀具直径(mm)', readonly=True) + diameter = fields.Float(string='刀具直径(mm)', readonly=True) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) max_lifetime_value = fields.Integer(string='最大寿命值(min)', readonly=True) alarm_value = fields.Integer(string='报警值(min)', readonly=True) @@ -197,7 +197,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): functional_tool_name = fields.Char(string='功能刀具名称', readonly=True) functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='功能刀具类型', readonly=True, group_expand='_read_group_functional_tool_type_ids') - functional_tool_diameter = fields.Integer(string='功能刀具直径(mm)', readonly=True) + functional_tool_diameter = fields.Float(string='功能刀具直径(mm)', readonly=True) knife_tip_r_angle = fields.Float(string='刀尖R角(mm)', readonly=True) coarse_middle_thin = fields.Selection([("1", "粗"), ('2', '中'), ('3', '精')], string='粗/中/精', readonly=True) new_former = fields.Selection([('0', '新'), ('1', '旧')], string='新/旧', readonly=True) @@ -463,7 +463,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel): after_assembly_functional_tool_name = fields.Char(string='组装后功能刀具名称', compute='_compute_name', store=True) after_assembly_functional_tool_type_id = fields.Many2one('sf.functional.cutting.tool.model', string='组装后功能刀具类型') - after_assembly_functional_tool_diameter = fields.Integer(string='组装后功能刀具直径(mm)') + after_assembly_functional_tool_diameter = fields.Float(string='组装后功能刀具直径(mm)') after_assembly_knife_tip_r_angle = fields.Float(string='组装后刀尖R角(mm)') after_assembly_new_former = fields.Selection([('0', '新'), ('1', '旧')], string='组装后新/旧', default='0') cut_time = fields.Integer(string='已切削时间(min)') From cda0b6d345bf5dd7c5b59f0e6824331711cc83c4 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 17 May 2024 11:04:35 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=BF=98=E5=8E=9FOCC=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/product_template.py | 6 ++---- sf_sale/models/quick_easy_order.py | 4 ++-- sf_sale/models/quick_easy_order_old.py | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index ff9d5aa6..7d9bbac5 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -7,10 +7,8 @@ import os from odoo import models, fields, api, _ from odoo.exceptions import ValidationError 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_sale/models/quick_easy_order.py b/sf_sale/models/quick_easy_order.py index 775b901a..259655ee 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 241170a1..768c483c 100644 --- a/sf_sale/models/quick_easy_order_old.py +++ b/sf_sale/models/quick_easy_order_old.py @@ -6,8 +6,8 @@ import os from datetime import datetime from stl import mesh # from OCC.Core.GProp import GProp_GProps -# from OCC.Extend.DataExchange import read_step_file -# from OCC.Extend.DataExchange import write_stl_file +from OCC.Extend.DataExchange import read_step_file +from OCC.Extend.DataExchange import write_stl_file from odoo.addons.sf_base.commons.common import Common from odoo import models, fields, api from odoo.modules import get_resource_path From e5164454f27ceccdddd68065343691df12c60e6e Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Fri, 17 May 2024 11:31:07 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=80=E5=94=AE?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_sale/views/sale_order_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml index 46e19239..4ea4c7c7 100644 --- a/sf_sale/views/sale_order_view.xml +++ b/sf_sale/views/sale_order_view.xml @@ -70,7 +70,7 @@ - +