From eff6ce9f1b41d9631795426f568f9c070b0938ef Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 14 May 2024 14:09:42 +0800 Subject: [PATCH 1/7] =?UTF-8?q?1=E3=80=81=E5=85=B3=E9=97=AD=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E3=80=81=E9=87=87=E8=B4=AD=E5=8D=95=E4=B8=AD=E5=85=B3?= =?UTF-8?q?=E8=81=94=E5=AD=97=E6=AE=B5=E7=9A=84=E5=88=9B=E5=BB=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9B2=E3=80=81=E4=BC=98=E5=8C=96=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E5=85=A5=E5=BA=93=E9=AA=8C=E8=AF=81=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/product_template_management_view.xml | 14 +++++++++----- sf_sale/views/purchase_order_view.xml | 3 +++ sf_sale/views/sale_order_view.xml | 2 +- sf_tool_management/wizard/wizard.py | 3 +++ sf_warehouse/models/model.py | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/sf_dlm_management/views/product_template_management_view.xml b/sf_dlm_management/views/product_template_management_view.xml index 94fc6b45..8842f8bf 100644 --- a/sf_dlm_management/views/product_template_management_view.xml +++ b/sf_dlm_management/views/product_template_management_view.xml @@ -32,6 +32,7 @@ attrs="{'invisible': [('categ_type', '!=', '刀具')],'required': [('categ_type', '=', '刀具')],'readonly': [('id', '!=', False)]}" placeholder="请选择"/> @@ -39,6 +40,7 @@ @@ -436,7 +438,7 @@ - + @@ -453,7 +455,7 @@ - + @@ -464,8 +466,8 @@ - - + @@ -553,14 +555,16 @@ - + diff --git a/sf_sale/views/purchase_order_view.xml b/sf_sale/views/purchase_order_view.xml index b0a4ed98..85f5b1c8 100644 --- a/sf_sale/views/purchase_order_view.xml +++ b/sf_sale/views/purchase_order_view.xml @@ -83,6 +83,9 @@ {'readonly': [('state', 'in', ['purchase'])]} + + {'no_create': True} + {'readonly': [('state', 'in', ['purchase'])]} diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml index 8350c761..5670e2aa 100644 --- a/sf_sale/views/sale_order_view.xml +++ b/sf_sale/views/sale_order_view.xml @@ -119,7 +119,7 @@ string="模型文件" attrs="{'readonly': [('state', 'in', ['draft'])]}"/> - {'no_create': True} + {'no_create': True, 'no_quick_create': True} {'is_sale_order_line': True } diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index a77c9010..d6981922 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -1,3 +1,5 @@ +import logging + from datetime import timedelta, datetime from odoo import fields, models, api @@ -807,6 +809,7 @@ class ProductProduct(models.Model): """ product_id = self.env['product.product'].search([('name', '=', '功能刀具')]) + logging.info("product_id: %s" % product_id) stock_lot = self.env['stock.lot'].create({ 'name': self.get_stock_lot_name(tool_assembly_order_id), 'product_id': product_id.id, diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py index 236781ee..1a7ba1e0 100644 --- a/sf_warehouse/models/model.py +++ b/sf_warehouse/models/model.py @@ -880,7 +880,7 @@ class SfStockPicking(models.Model): line.compute_destination_location_id() else: # 对除刀柄之外的刀具物料进行 目标货位必填校验 - if self.location_dest_id.name == '刀具房' and line.product_id.cutting_tool_material_id not in ( + if self.location_dest_id.name == '刀具房' and line.product_id.cutting_tool_material_id.name not in ( '刀柄', False): raise ValidationError('请选择【%s】产品的目标货位!' % line.product_id.name) if line.current_location_id: From 62ec721c6919457b9bef9f6978ede811b9a4176c Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 14 May 2024 14:19:44 +0800 Subject: [PATCH 2/7] 1 --- sf_manufacturing/models/mrp_workorder.py | 1 + sf_mrs_connect/controllers/controllers.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) 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_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index 4b45014a..9b1405bb 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -65,8 +65,11 @@ class Sf_Mrs_Connect(http.Controller): if cnc_program and cnc_processing_arr: logging.info('cnc_processing_arr:%s' % cnc_processing_arr) cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'}) - cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write( - {'cnc_ids': cnc_processing_arr}) + # cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write( + # {'cnc_ids': cnc_processing_arr}) + for cnc_item in cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工'): + logging.info('cnc_item:%s' % cnc_item.production_id.name) + cnc_item.write({'cnc_ids': cnc_processing_arr}) cnc_program_ids = [item.id for item in cnc_program] workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( [('production_id', 'in', cnc_program_ids)]) From 002c5c06b4658618ebb085e6ab3f4a0118e41e99 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Tue, 14 May 2024 15:55:34 +0800 Subject: [PATCH 3/7] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96CNC=E5=8A=A0?= =?UTF-8?q?=E5=B7=A5=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 4 ++-- sf_mrs_connect/controllers/controllers.py | 16 +++++++--------- sf_tool_management/models/mrp_workorder.py | 5 +++-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 2214696c..7533c7ec 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -965,7 +965,6 @@ class CNCprocessing(models.Model): def cnc_processing_create(self, cnc_workorder, ret, program_path, program_path_tmp): cnc_processing = None for obj in ret['programming_list']: - # 暂时不注释,批次插入不需要单个workorder workorder = self.env['mrp.workorder'].search( [('production_id.name', '=', cnc_workorder.name), ('processing_panel', '=', obj['processing_panel']), @@ -974,7 +973,7 @@ class CNCprocessing(models.Model): if obj['program_name'] in program_path: logging.info('obj:%s' % obj['program_name']) cnc_processing = self.env['sf.cnc.processing'].create({ - # 'workorder_id': workorder.id, + 'workorder_id': workorder.id, 'sequence_number': obj['sequence_number'], 'program_name': obj['program_name'], 'cutting_tool_name': obj['cutting_tool_name'], @@ -990,6 +989,7 @@ class CNCprocessing(models.Model): 'program_path': program_path.replace('/tmp', '/home/ftp/ftp_root/NC') }) cnc_processing.get_cnc_processing_file(program_path_tmp, cnc_processing, program_path) + cnc_workorder.write({'programming_state': '已编程', 'work_state': '已编程'}) return cnc_processing def _json_cnc_processing(self, obj): diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index 9b1405bb..3a55f517 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -27,11 +27,11 @@ class Sf_Mrs_Connect(http.Controller): # 查询状态为进行中且类型为获取CNC加工程序的工单 cnc_production = request.env['mrp.production'].with_user( request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'].split(',')[0])]) - # cnc_program = request.env['mrp.production'].with_user( - # request.env.ref("base.user_admin")).search( - # [('programming_no', '=', cnc_production.programming_no), ('id', '!=', cnc_production.id)]) cnc_program = request.env['mrp.production'].with_user( - request.env.ref("base.user_admin")).search([('programming_no', '=', cnc_production.programming_no)]) + request.env.ref("base.user_admin")).search( + [('programming_no', '=', cnc_production.programming_no), ('id', '!=', cnc_production.id)]) + # cnc_program = request.env['mrp.production'].with_user( + # request.env.ref("base.user_admin")).search([('programming_no', '=', cnc_production.programming_no)]) logging.info('制造订单号:%s' % cnc_production.name) if cnc_production: # if ret['glb_file']: @@ -60,16 +60,14 @@ class Sf_Mrs_Connect(http.Controller): cnc_processing = request.env['sf.cnc.processing'].with_user( request.env.ref("base.user_admin")).cnc_processing_create(cnc_production, ret, program_path, program_path_tmp) + logging.info('cnc_processing111:%s' % cnc_processing) if cnc_processing: cnc_processing_arr.append(cnc_processing._json_cnc_processing(cnc_processing)) if cnc_program and cnc_processing_arr: logging.info('cnc_processing_arr:%s' % cnc_processing_arr) cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'}) - # cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write( - # {'cnc_ids': cnc_processing_arr}) - for cnc_item in cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工'): - logging.info('cnc_item:%s' % cnc_item.production_id.name) - cnc_item.write({'cnc_ids': cnc_processing_arr}) + cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write( + {'cnc_ids': cnc_processing_arr}) cnc_program_ids = [item.id for item in cnc_program] workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( [('production_id', 'in', cnc_program_ids)]) diff --git a/sf_tool_management/models/mrp_workorder.py b/sf_tool_management/models/mrp_workorder.py index 44c4ef95..e21941ca 100644 --- a/sf_tool_management/models/mrp_workorder.py +++ b/sf_tool_management/models/mrp_workorder.py @@ -32,8 +32,9 @@ class CNCprocessing(models.Model): @api.model_create_multi def create(self, vals): obj = super(CNCprocessing, self).create(vals) - # 调用CAM工单程序用刀计划创建方法 - self.env['sf.cam.work.order.program.knife.plan'].create_cam_work_plan(obj) + for item in obj: + # 调用CAM工单程序用刀计划创建方法 + self.env['sf.cam.work.order.program.knife.plan'].create_cam_work_plan(item) logging.info('成功调用CAM工单程序用刀计划创建方法!!!') return obj From d244409d9cb616b2c807c059d09b0ab1b212c069 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 15 May 2024 14:09:44 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=A4=84=E7=90=86=E7=89=A9=E6=B5=81?= =?UTF-8?q?=E5=A4=84=E4=BF=AE=E6=94=B9=E9=94=80=E5=94=AE=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_bf_connect/models/jd_eclp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sf_bf_connect/models/jd_eclp.py b/sf_bf_connect/models/jd_eclp.py index c740869a..d755c7be 100644 --- a/sf_bf_connect/models/jd_eclp.py +++ b/sf_bf_connect/models/jd_eclp.py @@ -164,8 +164,8 @@ class JdEclp(models.Model): self.is_bill = True self.logistics_status = '1' - # 京东物流下单后,销售订单状态改为待收货 - self.env['sale.order'].search([('name', '=', self.origin)]).write({'scheduled_status': 'to receive'}) + # # 京东物流下单后,销售订单状态改为待收货 + # self.env['sale.order'].search([('name', '=', self.origin)]).write({'scheduled_status': 'to receive'}) # else: # raise UserError("选择京东物流才能下单呦") 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 5/7] =?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 6/7] =?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 7/7] =?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)')