From 857d5d8916c95730f8740ae6ef771df1bf2c0dde Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Fri, 19 Apr 2024 20:12:32 +0800 Subject: [PATCH 01/10] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E6=8B=86=E8=A7=A3=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=8F=8A=E5=85=B6=E5=89=8D=E7=AB=AF=E7=9A=84tree=E3=80=81form?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=89=AB=E7=A0=81?= =?UTF-8?q?=E5=BD=95=E5=85=A5=E9=9C=80=E8=A6=81=E6=8B=86=E8=A7=A3=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E5=8A=9F=E8=83=BD=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_tool_management/models/base.py | 128 +++++++++++++++- .../security/ir.model.access.csv | 6 +- sf_tool_management/views/menu_view.xml | 8 + sf_tool_management/views/tool_base_views.xml | 143 ++++++++++++++++++ sf_tool_management/wizard/wizard.py | 55 ++++--- 5 files changed, 309 insertions(+), 31 deletions(-) diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 83b4b550..235935a0 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -423,7 +423,8 @@ class FunctionalToolAssembly(models.Model): def _compute_integral_product_id(self): for item in self: if item.integral_freight_barcode: - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.integral_freight_barcode)]) + location = self.env['sf.shelf.location'].sudo().search( + [('barcode', '=', item.integral_freight_barcode)]) if location: item.integral_product_id = location.product_id.id else: @@ -442,7 +443,7 @@ class FunctionalToolAssembly(models.Model): @api.depends('blade_freight_barcode') def _compute_blade_product_id(self): for item in self: - if item.integral_freight_barcode: + if item.blade_freight_barcode: location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.blade_freight_barcode)]) if location: item.blade_product_id = location.product_id.id @@ -462,7 +463,7 @@ class FunctionalToolAssembly(models.Model): @api.depends('bar_freight_barcode') def _compute_bar_product_id(self): for item in self: - if item.integral_freight_barcode: + if item.bar_freight_barcode: location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.bar_freight_barcode)]) if location: item.bar_product_id = location.product_id.id @@ -482,7 +483,7 @@ class FunctionalToolAssembly(models.Model): @api.depends('pad_freight_barcode') def _compute_pad_product_id(self): for item in self: - if item.integral_freight_barcode: + if item.pad_freight_barcode: location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.pad_freight_barcode)]) if location: item.pad_product_id = location.product_id.id @@ -523,7 +524,7 @@ class FunctionalToolAssembly(models.Model): @api.depends('chuck_freight_barcode') def _compute_chuck_product_id(self): for item in self: - if item.integral_freight_barcode: + if item.chuck_freight_barcode: location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', item.chuck_freight_barcode)]) if location: item.chuck_product_id = location.product_id.id @@ -631,3 +632,120 @@ class FunctionalToolAssembly(models.Model): code = self._get_code(obj.loading_task_source) obj.assembly_order_code = code return obj + + +class FunctionalToolDismantle(models.Model): + _name = 'sf.functional.tool.dismantle' + _inherit = ["barcodes.barcode_events_mixin"] + _description = '功能刀具拆解' + + def on_barcode_scanned(self, barcode): + """ + 扫码 + """ + tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search([('rfid', '=', barcode)]) + if tool_id: + self.functional_tool_id = tool_id.id + else: + pass + + name = fields.Char('名称', related='functional_tool_id.name') + + functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True, + domain=[('functional_tool_status', '!=', '已拆除')]) + 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) + 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) + + dismantle_cause = fields.Selection( + [('寿命到期报废', '寿命到期报废'), ('崩刀报废', '崩刀报废'), ('更换为其他刀具', '更换为其他刀具'), + ('刀具需磨削', '刀具需磨削')], string='拆解原因', required=True) + dismantle_data = fields.Datetime('拆解日期', readonly=True) + dismantle_person = fields.Char('拆解人', readonly=True) + image = fields.Binary('图片', readonly=True) + + scrap_id = fields.Char('报废单号') + grinding_id = fields.Char('磨削单号') + + # 刀柄 + handle_product_id = fields.Many2one('product.product', string='刀柄', compute='_compute_functional_tool_num', + store=True) + handle_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', + related='handle_product_id.cutting_tool_model_id') + handle_brand_id = fields.Many2one('sf.machine.brand', string='刀柄品牌', related='handle_product_id.brand_id') + handle_rfid = fields.Char(string='刀柄Rfid') + scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False) + + # 整体式 + integral_product_id = fields.Many2one('product.product', string='整体式刀具', + compute='_compute_functional_tool_num', store=True) + integral_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='整体式刀具型号', + related='integral_product_id.cutting_tool_model_id') + integral_brand_id = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', + related='integral_product_id.brand_id') + integral_freight_barcode = fields.Char('整体式刀具目标货位') + + # 刀片 + blade_product_id = fields.Many2one('product.product', string='刀片', compute='_compute_functional_tool_num', + store=True) + blade_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', + related='blade_product_id.cutting_tool_model_id') + blade_brand_id = fields.Many2one('sf.machine.brand', string='刀片品牌', related='blade_product_id.brand_id') + blade_freight_barcode = fields.Char('刀片目标货位') + + # 刀杆 + bar_product_id = fields.Many2one('product.product', string='刀杆', compute='_compute_functional_tool_num', + store=True) + bar_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', + related='bar_product_id.cutting_tool_model_id') + bar_brand_id = fields.Many2one('sf.machine.brand', string='刀杆品牌', related='bar_product_id.brand_id') + bar_freight_barcode = fields.Char('刀杆目标货位') + + # 刀盘 + pad_product_id = fields.Many2one('product.product', string='刀盘', compute='_compute_functional_tool_num', + store=True) + pad_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', + related='pad_product_id.cutting_tool_model_id') + pad_brand_id = fields.Many2one('sf.machine.brand', string='刀盘品牌', related='pad_product_id.brand_id') + pad_freight_barcode = fields.Char('刀盘目标货位') + + # 夹头 + chuck_product_id = fields.Many2one('product.product', string='夹头', compute='_compute_functional_tool_num', + store=True) + chuck_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', + related='chuck_product_id.cutting_tool_model_id') + chuck_brand_id = fields.Many2one('sf.machine.brand', string='夹头品牌', related='chuck_product_id.brand_id') + chuck_freight_barcode = fields.Char('夹头目标货位') + + @api.depends('functional_tool_id') + def _compute_functional_tool_num(self): + for item in self: + if item.functional_tool_id: + item.tool_groups_id = item.functional_tool_id.tool_groups_id.id + item.tool_type_id = item.functional_tool_id.sf_cutting_tool_type_id.id + item.diameter = item.functional_tool_id.functional_tool_diameter + item.knife_tip_r_angle = item.functional_tool_id.knife_tip_r_angle + item.rfid = item.functional_tool_id.rfid + + item.handle_product_id = item.functional_tool_id.functional_tool_name_id.handle_product_id.id + item.integral_product_id = item.functional_tool_id.functional_tool_name_id.integral_product_id.id + item.blade_product_id = item.functional_tool_id.functional_tool_name_id.blade_product_id.id + item.bar_product_id = item.functional_tool_id.functional_tool_name_id.bar_product_id.id + item.pad_product_id = item.functional_tool_id.functional_tool_name_id.pad_product_id.id + item.chuck_product_id = item.functional_tool_id.functional_tool_name_id.chuck_product_id.id + else: + item.tool_groups_id = False + item.tool_type_id = False + item.diameter = 0 + item.knife_tip_r_angle = 0 + item.rfid = '' + + item.handle_product_id = False + item.integral_product_id = False + item.blade_product_id = False + item.bar_product_id = False + item.pad_product_id = False + item.chuck_product_id = False diff --git a/sf_tool_management/security/ir.model.access.csv b/sf_tool_management/security/ir.model.access.csv index 3a7b4589..79800637 100644 --- a/sf_tool_management/security/ir.model.access.csv +++ b/sf_tool_management/security/ir.model.access.csv @@ -30,4 +30,8 @@ access_sf_tool_material_search,sf.tool.material.search,model_sf_tool_material_se access_sf_tool_material_search_group_plan_dispatch,sf.tool.material.search,model_sf_tool_material_search,sf_base.group_plan_dispatch,1,0,0,0 access_sf_fixture_material_search,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_sf_order_user,1,0,0,0 -access_sf_fixture_material_search_group_plan_dispatch,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_plan_dispatch,1,0,0,0 \ No newline at end of file +access_sf_fixture_material_search_group_plan_dispatch,sf.fixture.material.search,model_sf_fixture_material_search,sf_base.group_plan_dispatch,1,0,0,0 + + +access_sf_functional_tool_dismantle_group_sf_tool_user,sf.functional.tool.dismantle,model_sf_functional_tool_dismantle,sf_base.group_sf_tool_user,1,1,1,0 +access_sf_functional_tool_dismantle_group_plan_dispatch,sf.functional.tool.dismantle,model_sf_functional_tool_dismantle,sf_base.group_plan_dispatch,1,0,0,0 diff --git a/sf_tool_management/views/menu_view.xml b/sf_tool_management/views/menu_view.xml index 13a12725..eae7532e 100644 --- a/sf_tool_management/views/menu_view.xml +++ b/sf_tool_management/views/menu_view.xml @@ -78,5 +78,13 @@ parent="menu_sf_tool_manage" /> + + diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 46c77b82..4e1a6fc4 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -766,5 +766,148 @@ {'search_default_no_assemble_status':1} + + + + + 功能刀具拆解 + sf.functional.tool.dismantle + + + + + + + + + + + + + + + + + 功能刀具拆解 + sf.functional.tool.dismantle + +
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + sf.functional.tool.dismantle + + + + + + + + + + + + + 功能刀具拆解 + ir.actions.act_window + sf.functional.tool.dismantle + tree,form,search + + + + + diff --git a/sf_tool_management/wizard/wizard.py b/sf_tool_management/wizard/wizard.py index 979d8efe..be31d7f0 100644 --- a/sf_tool_management/wizard/wizard.py +++ b/sf_tool_management/wizard/wizard.py @@ -243,11 +243,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel): @api.depends('integral_freight_barcode') def _compute_integral_product_id(self): - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)]) - if location: - self.integral_product_id = location.product_id.id - else: - self.integral_product_id = False + if self.integral_freight_barcode: + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.integral_freight_barcode)]) + if location: + self.integral_product_id = location.product_id.id + else: + self.integral_product_id = False # ===============刀片型号==================== blade_freight_barcode = fields.Char('刀片货位') @@ -261,11 +262,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel): @api.depends('blade_freight_barcode') def _compute_blade_product_id(self): - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)]) - if location: - self.blade_product_id = location.product_id.id - else: - self.blade_product_id = False + if self.blade_freight_barcode: + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.blade_freight_barcode)]) + if location: + self.blade_product_id = location.product_id.id + else: + self.blade_product_id = False # ====================刀杆型号================== bar_freight_barcode = fields.Char('刀杆货位') @@ -279,11 +281,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel): @api.depends('bar_freight_barcode') def _compute_bar_product_id(self): - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)]) - if location: - self.bar_product_id = location.product_id.id - else: - self.bar_product_id = False + if self.bar_freight_barcode: + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.bar_freight_barcode)]) + if location: + self.bar_product_id = location.product_id.id + else: + self.bar_product_id = False # ===============刀盘型号=================== pad_freight_barcode = fields.Char('刀盘货位') @@ -297,11 +300,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel): @api.depends('pad_freight_barcode') def _compute_pad_product_id(self): - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)]) - if location: - self.pad_product_id = location.product_id.id - else: - self.pad_product_id = False + if self.pad_freight_barcode: + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.pad_freight_barcode)]) + if location: + self.pad_product_id = location.product_id.id + else: + self.pad_product_id = False # ================刀柄型号=============== handle_freight_rfid = fields.Char('刀柄Rfid', compute='_compute_rfid') @@ -335,11 +339,12 @@ class FunctionalToolAssemblyOrder(models.TransientModel): @api.depends('chuck_freight_barcode') def _compute_chuck_product_id(self): - location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)]) - if location: - self.chuck_product_id = location.product_id.id - else: - self.chuck_product_id = False + if self.chuck_freight_barcode: + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', self.chuck_freight_barcode)]) + if location: + self.chuck_product_id = location.product_id.id + else: + self.chuck_product_id = False # ======================================== From 080a3d717535d230365517781391a8355921429e Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Mon, 22 Apr 2024 17:59:48 +0800 Subject: [PATCH 02/10] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E7=9A=84=E6=89=98=E7=9B=98=E5=B7=B2=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E7=9A=84=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=EF=BC=9B2=E3=80=81=E4=BC=98=E5=8C=96=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=9C=AA=E5=AE=A1=E6=A0=B8=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E6=95=B0=E6=8D=AE=E4=B8=8D=E8=83=BD=E6=94=B9?= =?UTF-8?q?=E5=8F=98=E7=9A=84bug=EF=BC=9B3=E3=80=81=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=80=E5=85=B7=E6=8B=86=E8=A7=A3=E5=8D=95=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E4=B8=8D=E5=90=8C=E6=83=85=E5=86=B5=E6=89=AB?= =?UTF-8?q?=E5=BA=93=E4=BD=8D=E7=A0=81=E5=BD=95=E5=85=A5=E4=BA=94=E7=A7=8D?= =?UTF-8?q?=E7=89=A9=E6=96=99=E7=9A=84=E7=9B=AE=E7=9A=84=E5=BA=93=E4=BD=8D?= =?UTF-8?q?=E7=9A=84=E4=BF=A1=E6=81=AF=EF=BC=9B4=E3=80=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=88=80=E5=85=B7=E6=8B=86=E8=A7=A3=E5=8D=95=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=8B=86=E8=A7=A3=E5=90=8E=E7=9A=84Rfid=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=8B=86=E8=A7=A3=E5=8D=95?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=AD=97=E6=AE=B5=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=88=80=E5=85=B7=E7=89=A9=E6=96=99=E5=BA=93=E4=BD=8D=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=90=9C=E7=B4=A2=E8=BF=87=E6=BB=A4=EF=BC=9B5?= =?UTF-8?q?=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E6=8B=86=E8=A7=A3?= =?UTF-8?q?=E5=8D=95=E6=96=B0=E5=A2=9E=E7=A1=AE=E8=AE=A4=E6=8B=86=E8=A7=A3?= =?UTF-8?q?=E6=8C=89=E9=92=AE=EF=BC=8C=E5=AE=8C=E6=88=90=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=8B=86=E8=A7=A3=E5=90=8E=E7=9A=84=E5=88=80?= =?UTF-8?q?=E5=85=B7=E7=89=A9=E6=96=99=E6=98=AF=E5=90=A6=E6=8A=A5=E5=BA=9F?= =?UTF-8?q?=E3=80=81=E7=A3=A8=E5=89=8A=E6=88=96=E8=80=85=E6=9B=B4=E6=8D=A2?= =?UTF-8?q?=E7=9A=84=E4=B8=8D=E5=90=8C=E6=9D=A1=E4=BB=B6=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E6=8B=86=E8=A7=A3=E5=90=8E=E7=89=A9=E6=96=99=E7=9A=84=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E5=8E=BB=E5=90=91=E7=9A=84=E5=8A=9F=E8=83=BD=E5=8F=8A?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=A7=BB=E5=8A=A8=E5=8E=86=E5=8F=B2=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E9=99=A4=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7Rfid?= =?UTF-8?q?=E7=9A=84=E7=BB=91=E5=AE=9A=E5=B9=B6=E6=9B=B4=E6=94=B9=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=AD=89=E3=80=826=E3=80=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E7=AE=A1=E7=90=86=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E8=8F=9C=E5=8D=95=E7=9B=AE=E5=BD=95=E5=B8=83=E5=B1=80?= =?UTF-8?q?=EF=BC=9B7=E3=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_workorder.py | 2 +- sf_sale/views/purchase_order_view.xml | 2 +- sf_tool_management/models/base.py | 162 ++++++++++++++++-- sf_tool_management/models/functional_tool.py | 1 + sf_tool_management/views/menu_view.xml | 120 ++++++++----- sf_tool_management/views/tool_base_views.xml | 144 ++++++++++------ .../views/tool_material_search.xml | 7 - 7 files changed, 318 insertions(+), 120 deletions(-) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 9627a0f7..54024fe3 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -988,7 +988,7 @@ class SfWorkOrderBarcodes(models.Model): # [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)]) workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)]) if workorder_old: - raise UserError('该托盘已绑定工件,请先解除绑定!!!') + raise UserError('该托盘已绑定【%s】制造订单,请先解除绑定!!!' % workorder_old.production_id.name) if workorder: if workorder.routing_type == '装夹预调': if workorder.state in ['done']: diff --git a/sf_sale/views/purchase_order_view.xml b/sf_sale/views/purchase_order_view.xml index f92658fc..90c9bd4b 100644 --- a/sf_sale/views/purchase_order_view.xml +++ b/sf_sale/views/purchase_order_view.xml @@ -94,7 +94,7 @@ {'readonly': ['&',('state', 'in', ['purchase']),('check_status','in', - ['pending','approved'])]} + ['approved'])]} diff --git a/sf_tool_management/models/base.py b/sf_tool_management/models/base.py index 235935a0..350658a4 100644 --- a/sf_tool_management/models/base.py +++ b/sf_tool_management/models/base.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +import re + import logging from datetime import timedelta @@ -643,11 +645,35 @@ class FunctionalToolDismantle(models.Model): """ 扫码 """ - tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search([('rfid', '=', barcode)]) - if tool_id: - self.functional_tool_id = tool_id.id + # 对barcode进行校验是否为货位编码 + if not re.match(r'^[A-Za-z0-9]+-[A-Za-z0-9]+-\d{3}-\d{3}$', barcode): + tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search([('rfid', '=', barcode)]) + if tool_id: + self.functional_tool_id = tool_id.id + else: + raise ValidationError('Rfid为【%s】的功能刀具不存在,请重新扫描!' % barcode) else: - pass + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', barcode)]) + if not location: + raise ValidationError('【%s】该货位不存在,请重新扫码!' % barcode) + else: + # 判断是否有夹头物料 + if not self.chuck_product_id: + # 判断是否有整体式刀具物料 + if self.integral_product_id: + # 判断货位是否为空货位 或者 是存有整体式刀具的货位 + if location.product_id in [False, self.integral_product_id]: + self.integral_freight_id = location.id + else: + raise ValidationError('【%s】该货位已存在【%s】产品,请重新扫码!' % location.barcode, + location.product_id.name) + # 判断是否有刀片物料 + elif self.blade_product_id: + # 判断是否有刀杆物料 + if self.bar_product_id: + pass + else: + pass name = fields.Char('名称', related='functional_tool_id.name') @@ -659,6 +685,7 @@ class FunctionalToolDismantle(models.Model): diameter = fields.Integer(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) dismantle_cause = fields.Selection( [('寿命到期报废', '寿命到期报废'), ('崩刀报废', '崩刀报废'), ('更换为其他刀具', '更换为其他刀具'), @@ -667,8 +694,10 @@ class FunctionalToolDismantle(models.Model): dismantle_person = fields.Char('拆解人', readonly=True) image = fields.Binary('图片', readonly=True) - scrap_id = fields.Char('报废单号') - grinding_id = fields.Char('磨削单号') + scrap_id = fields.Char('报废单号', readonly=True) + grinding_id = fields.Char('磨削单号', readonly=True) + + state = fields.Selection([('待拆解', '待拆解'), ('已拆解', '已拆解')], default='待拆解') # 刀柄 handle_product_id = fields.Many2one('product.product', string='刀柄', compute='_compute_functional_tool_num', @@ -676,7 +705,7 @@ class FunctionalToolDismantle(models.Model): handle_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀柄型号', related='handle_product_id.cutting_tool_model_id') handle_brand_id = fields.Many2one('sf.machine.brand', string='刀柄品牌', related='handle_product_id.brand_id') - handle_rfid = fields.Char(string='刀柄Rfid') + handle_rfid = fields.Char(string='刀柄Rfid', compute='_compute_functional_tool_num', store=True) scrap_boolean = fields.Boolean(string='刀柄是否报废', default=False) # 整体式 @@ -686,7 +715,8 @@ class FunctionalToolDismantle(models.Model): related='integral_product_id.cutting_tool_model_id') integral_brand_id = fields.Many2one('sf.machine.brand', string='整体式刀具品牌', related='integral_product_id.brand_id') - integral_freight_barcode = fields.Char('整体式刀具目标货位') + integral_freight_id = fields.Many2one('sf.shelf.location', '整体式刀具目标货位', + domain="[('product_id', 'in', (integral_product_id, False))]") # 刀片 blade_product_id = fields.Many2one('product.product', string='刀片', compute='_compute_functional_tool_num', @@ -694,7 +724,8 @@ class FunctionalToolDismantle(models.Model): blade_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀片型号', related='blade_product_id.cutting_tool_model_id') blade_brand_id = fields.Many2one('sf.machine.brand', string='刀片品牌', related='blade_product_id.brand_id') - blade_freight_barcode = fields.Char('刀片目标货位') + blade_freight_id = fields.Many2one('sf.shelf.location', '刀片目标货位', + domain="[('product_id', 'in', (blade_product_id, False))]") # 刀杆 bar_product_id = fields.Many2one('product.product', string='刀杆', compute='_compute_functional_tool_num', @@ -702,7 +733,8 @@ class FunctionalToolDismantle(models.Model): bar_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀杆型号', related='bar_product_id.cutting_tool_model_id') bar_brand_id = fields.Many2one('sf.machine.brand', string='刀杆品牌', related='bar_product_id.brand_id') - bar_freight_barcode = fields.Char('刀杆目标货位') + bar_freight_id = fields.Many2one('sf.shelf.location', '刀杆目标货位', + domain="[('product_id', 'in', (bar_product_id, False))]") # 刀盘 pad_product_id = fields.Many2one('product.product', string='刀盘', compute='_compute_functional_tool_num', @@ -710,7 +742,8 @@ class FunctionalToolDismantle(models.Model): pad_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀盘型号', related='pad_product_id.cutting_tool_model_id') pad_brand_id = fields.Many2one('sf.machine.brand', string='刀盘品牌', related='pad_product_id.brand_id') - pad_freight_barcode = fields.Char('刀盘目标货位') + pad_freight_id = fields.Many2one('sf.shelf.location', '刀盘目标货位', + domain="[('product_id', 'in', (pad_product_id, False))]") # 夹头 chuck_product_id = fields.Many2one('product.product', string='夹头', compute='_compute_functional_tool_num', @@ -718,7 +751,8 @@ class FunctionalToolDismantle(models.Model): chuck_type_id = fields.Many2one('sf.cutting_tool.standard.library', string='夹头型号', related='chuck_product_id.cutting_tool_model_id') chuck_brand_id = fields.Many2one('sf.machine.brand', string='夹头品牌', related='chuck_product_id.brand_id') - chuck_freight_barcode = fields.Char('夹头目标货位') + chuck_freight_id = fields.Many2one('sf.shelf.location', '夹头目标货位', + domain="[('product_id', 'in', (chuck_product_id, False))]") @api.depends('functional_tool_id') def _compute_functional_tool_num(self): @@ -729,6 +763,7 @@ class FunctionalToolDismantle(models.Model): item.diameter = item.functional_tool_id.functional_tool_diameter item.knife_tip_r_angle = item.functional_tool_id.knife_tip_r_angle item.rfid = item.functional_tool_id.rfid + item.handle_rfid = item.functional_tool_id.rfid item.handle_product_id = item.functional_tool_id.functional_tool_name_id.handle_product_id.id item.integral_product_id = item.functional_tool_id.functional_tool_name_id.integral_product_id.id @@ -742,6 +777,7 @@ class FunctionalToolDismantle(models.Model): item.diameter = 0 item.knife_tip_r_angle = 0 item.rfid = '' + item.handle_rfid = '' item.handle_product_id = False item.integral_product_id = False @@ -749,3 +785,105 @@ class FunctionalToolDismantle(models.Model): item.bar_product_id = False item.pad_product_id = False item.chuck_product_id = False + + def confirmation_disassembly(self): + logging.info('%s刀具确认拆解' % self.dismantle_cause) + location = self.env['stock.location'].search([('name', '=', '刀具组装位置')]) + location_dest = self.env['stock.location'].search([('name', '=', '刀具房')]) + # =================刀柄是否报废拆解======= + location_dest_scrap = self.env['stock.location'].search([('name', '=', 'Scrap')]) + if self.handle_rfid: + lot = self.env['stock.lot'].sudo().search([('name', '=', self.handle_rfid)]) + functional_tool_assembly = self.functional_tool_id.functional_tool_name_id + if self.scrap_boolean: + # 刀柄报废 入库到Scrap + lot.create_stock_quant(location, location_dest_scrap, functional_tool_assembly.id, '功能刀具拆解', + functional_tool_assembly) + else: + # 刀柄不报废 入库到刀具房 + lot.create_stock_quant(location, location_dest, functional_tool_assembly.id, '功能刀具拆解', + functional_tool_assembly) + # ==============功能刀具报废拆解================ + if self.dismantle_cause in ['寿命到期报废', '崩刀报废']: + # 除刀柄外物料报废 入库到Scrap + if self.integral_freight_id: + self.integral_product_id.dismantle_stock_moves(False, location, location_dest_scrap) + elif self.blade_freight_id: + self.blade_product_id.dismantle_stock_moves(False, location, location_dest_scrap) + if self.bar_freight_id: + self.bar_product_id.dismantle_stock_moves(False, location, location_dest_scrap) + elif self.pad_freight_id: + self.pad_product_id.dismantle_stock_moves(False, location, location_dest_scrap) + if self.chuck_freight_id: + self.chuck_product_id.dismantle_stock_moves(False, location, location_dest_scrap) + # ===========功能刀具磨削拆解============== + elif self.dismantle_cause in ['刀具需磨削']: + location_dest = self.env['stock.location'].search([('name', '=', '磨削房')]) + # 除刀柄外物料拆解 入库到具体库位 + if self.integral_freight_id: + self.integral_product_id.dismantle_stock_moves(False, location, location_dest) + elif self.blade_freight_id: + self.blade_product_id.dismantle_stock_moves(False, location, location_dest) + if self.bar_freight_id: + self.bar_product_id.dismantle_stock_moves(False, location, location_dest) + elif self.pad_freight_id: + self.pad_product_id.dismantle_stock_moves(False, location, location_dest) + if self.chuck_freight_id: + self.chuck_product_id.dismantle_stock_moves(False, location, location_dest) + # ==============功能刀具更换拆解============== + elif self.dismantle_cause in ['更换为其他刀具']: + # 除刀柄外物料拆解 入库到具体库位 + if self.integral_freight_id: + self.integral_product_id.dismantle_stock_moves(self.integral_freight_id.barcode, location, + location_dest) + elif self.blade_freight_id: + self.blade_product_id.dismantle_stock_moves(self.blade_freight_id.barcode, location, location_dest) + if self.bar_freight_id: + self.bar_product_id.dismantle_stock_moves(self.bar_freight_id.barcode, location, location_dest) + elif self.pad_freight_id: + self.pad_product_id.dismantle_stock_moves(self.pad_freight_id.barcode, location, location_dest) + if self.chuck_freight_id: + self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id.barcode, location, location_dest) + # ===============删除功能刀具的Rfid字段的值, 赋值给Rfid(已拆解)字段===== + self.functional_tool_id.write({ + 'rfid_dismantle': self.functional_tool_id.rfid, + 'rfid': '', + 'functional_tool_status': '已拆除' + }) + # 修改拆解单的值 + self.write({ + 'rfid_dismantle': self.rfid, + 'rfid': '', + 'state': '已拆解' + }) + + +class ProductProduct(models.Model): + _inherit = 'product.product' + + def dismantle_stock_moves(self, shelf_location_barcode, location_id, location_dest_id): + # 创建功能刀具拆解单产品库存移动记录 + stock_move_id = self.env['stock.move'].sudo().create({ + 'name': '功能刀具拆解', + 'product_id': self.id, + 'location_id': location_id.id, + 'location_dest_id': location_dest_id.id, + 'product_uom_qty': 1.00, + 'state': 'done' + }) + if shelf_location_barcode: + location = self.env['sf.shelf.location'].sudo().search([('barcode', '=', shelf_location_barcode)]) + location.product_num = location.product_num + 1 + else: + location = False + # 创建移动历史记录 + stock_move_line_id = self.env['stock.move.line'].sudo().create({ + 'product_id': self.id, + 'move_id': stock_move_id.id, + 'current_location_id': location.id or False, + 'install_tool_time': fields.Datetime.now(), + 'qty_done': 1.0, + 'state': 'done', + }) + + return stock_move_id, stock_move_line_id diff --git a/sf_tool_management/models/functional_tool.py b/sf_tool_management/models/functional_tool.py index c37d5317..d4718f34 100644 --- a/sf_tool_management/models/functional_tool.py +++ b/sf_tool_management/models/functional_tool.py @@ -14,6 +14,7 @@ class FunctionalCuttingToolEntity(models.Model): tool_groups_id = fields.Many2one('sf.tool.groups', '刀具组', related='functional_tool_name_id.tool_groups_id') code = fields.Char('编码') rfid = fields.Char('Rfid', readonly=True) + rfid_dismantle = fields.Char('Rfid(已拆解)', readonly=True) name = fields.Char('名称') tool_name_id = fields.Many2one('sf.tool.inventory', '功能刀具名称') sf_cutting_tool_model_id = fields.Many2one('sf.cutting_tool.standard.library', string='刀具型号') diff --git a/sf_tool_management/views/menu_view.xml b/sf_tool_management/views/menu_view.xml index eae7532e..8ddee8eb 100644 --- a/sf_tool_management/views/menu_view.xml +++ b/sf_tool_management/views/menu_view.xml @@ -14,77 +14,111 @@ parent="mrp.menu_mrp_root" sequence="20"/> - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/sf_tool_management/views/tool_base_views.xml b/sf_tool_management/views/tool_base_views.xml index 4e1a6fc4..944decd2 100644 --- a/sf_tool_management/views/tool_base_views.xml +++ b/sf_tool_management/views/tool_base_views.xml @@ -792,11 +792,16 @@ sf.functional.tool.dismantle
+
+

+ options="{'no_create': True}" attrs="{‘readonly': [('state', '=', '已拆解')]}"/>

@@ -807,76 +812,103 @@ - + + + + + + + + + + + - - - - - + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - + - - - - - - + + + + + + + + + + - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + diff --git a/sf_tool_management/views/tool_material_search.xml b/sf_tool_management/views/tool_material_search.xml index ee63ba26..d4772244 100644 --- a/sf_tool_management/views/tool_material_search.xml +++ b/sf_tool_management/views/tool_material_search.xml @@ -94,12 +94,5 @@ sf.tool.material.search tree,form - From 307e052740fc030efdabe01185210c97095489c3 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Tue, 23 Apr 2024 14:05:10 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BC=98=E5=8C=96agv=E5=8F=8A=E7=AB=99?= =?UTF-8?q?=E7=82=B9=E4=BD=8D=E7=BD=AE=E5=92=8C=E5=AF=B9=E5=BA=94=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 20 +- sf_manufacturing/controllers/workpiece.py | 5 + sf_manufacturing/models/agv_setting.py | 19 + sf_manufacturing/models/mrp_workorder.py | 703 +++++++++--------- sf_manufacturing/models/product_template.py | 4 +- .../wizard/workpiece_delivery_views.xml | 11 +- .../wizard/workpiece_delivery_wizard.py | 2 - sf_mrs_connect/models/res_config_setting.py | 4 + .../views/res_config_settings_views.xml | 4 + sf_sale/models/quick_easy_order.py | 4 +- sf_sale/models/quick_easy_order_old.py | 4 +- .../models/maintenance_equipment.py | 10 +- 12 files changed, 411 insertions(+), 379 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index b9cef58e..bbd9cac9 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -432,7 +432,7 @@ class Manufacturing_Connect(http.Controller): logging.info('DeviceId:%s' % ret['DeviceId']) workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( [('feeder_station_start_id.name', '=', ret['DeviceId']), - ('status', '=', '待配送')], limit=1, order='id asc') + ('status', '=', '已配送'), ('type', '=', '上产线')], order='id asc') if workpiece_delivery: for wd in workpiece_delivery: logging.info('wd.production_id:%s' % wd.production_id.name) @@ -441,7 +441,7 @@ class Manufacturing_Connect(http.Controller): wd.production_id.write({'production_line_state': '已上产线'}) wd.write({'production_line_state': '已上产线'}) else: - res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'} + res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的已配送工件数据'} else: res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传DeviceId字段'} except Exception as e: @@ -466,26 +466,16 @@ class Manufacturing_Connect(http.Controller): if 'DeviceId' in ret: logging.info('DeviceId:%s' % ret['DeviceId']) workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( - [('feeder_station_destination_id.name', '=', ret['DeviceId']), - ('status', '=', '待配送')], limit=1, order='id asc') + [('feeder_station_start_id.name', '=', ret['DeviceId']), + ('status', '=', '已配送'), ('type', '=', '上产线')], order='id asc') if workpiece_delivery: for wd in workpiece_delivery: logging.info('wd.production_id:%s' % wd.production_id.name) if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线': logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state) - workpiece_delivery_off = request.env['sf.workpiece.delivery'].sudo().create({ - 'production_id': wd.production_id.id, - 'feeder_station_start_id': workpiece_delivery.feeder_station_start_id.id, - 'feeder_station_destination_id': '', - 'workorder_id': workpiece_delivery.workorder_id.id, - 'workpiece_code': workpiece_delivery.workpiece_code, - 'production_line_id': workpiece_delivery.production_line_id.id, - 'task_delivery_time': datetime.now(), - 'production_line_state': '已下产线' - }) wd.production_id.write({'production_line_state': '已下产线'}) logging.info('开始向agv下发下产线任务') - workpiece_delivery_off._delivery_avg() + wd._delivery_avg() logging.info('agv下发下产线任务已配送') else: diff --git a/sf_manufacturing/controllers/workpiece.py b/sf_manufacturing/controllers/workpiece.py index fcdcf606..775da5a0 100644 --- a/sf_manufacturing/controllers/workpiece.py +++ b/sf_manufacturing/controllers/workpiece.py @@ -28,6 +28,11 @@ class Workpiece(http.Controller): [('production_id.name', '=', ret['reqCode']), ('agv_task_code'), '=', ret['taskCode']]) if workpiece_delivery: workpiece_delivery.write({'status': '已配送', 'task_completion_time': ret['reqTime']}) + if workpiece_delivery.type == '下产线': + workpiece_delivery_clear = request.env['sf.workpiece.delivery'].sudo().search( + [('production_id.name', '=', ret['reqCode']), ('type', '=', '运送空料架')]) + if workpiece_delivery_clear: + workpiece_delivery_clear._delivery_avg() else: res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该reqCode暂未查到对应的工件配送记录'} else: diff --git a/sf_manufacturing/models/agv_setting.py b/sf_manufacturing/models/agv_setting.py index 22c486d1..70075285 100644 --- a/sf_manufacturing/models/agv_setting.py +++ b/sf_manufacturing/models/agv_setting.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +import requests +import logging from odoo import fields, models @@ -13,6 +15,23 @@ class AgvSetting(models.Model): ('占用', '占用'), ('空闲', '空闲')], string='状态') divide_the_work = fields.Char('主要分工') + active = fields.Boolean('有效', default=True) + + def update_site_state(self): + # 调取中控的接驳站接口并修改对应站点的状态 + config = self.env['res.config.settings'].get_values() + # token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A] + headers = {'Authorization': config['center_control_Authorization']} + center_control_url = config['center_control_url'] + "/AutoDeviceApi/GetAgvStationState" + center_control_r = requests.get(center_control_url, params={}, headers=headers) + ret = center_control_r.json() + logging.info('工件配送-请求中控站点信息:%s' % ret) + datas = ret['Datas'] + for item in self: + for da in datas: + if da['DeviceId'] == item.name: + if da['AtHome'] is True: + item.state = '占用' class AgvTaskRoute(models.Model): diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index ab520434..2184e7d1 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -458,360 +458,376 @@ class ResMrpWorkOrder(models.Model): 'date_planned_finished': False, 'duration_expected': duration_expected, 'duration': 0, - 'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self.env[ - 'sf.workpiece.delivery'].create( - {'production_id': production.id}) + 'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self._json_workpiece_delivery_list( + production) }] return workorders_values_str - # 拼接工单对象属性值(表面工艺) - def _json_workorder_surface_process_str(self, production, route, process_parameter, supplier_id): - workorders_values_str = [0, '', { - 'product_uom_id': production.product_uom_id.id, - 'qty_producing': 0, - 'operation_id': False, - 'name': '%s-%s' % (route.name, process_parameter.name), - 'processing_panel': '', - 'routing_type': '表面工艺', - 'surface_technics_parameters_id': process_parameter.id, - 'work_state': '', - 'supplier_id': supplier_id, - 'is_subcontract': True if process_parameter.gain_way == '外协' else False, - 'workcenter_id': self.env[ - 'mrp.workcenter'].get_process_outsourcing_workcenter() if process_parameter.gain_way == '外协' else - self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids, - route.routing_type, - production.product_id), - 'date_planned_start': False, - 'date_planned_finished': False, - 'duration_expected': 60, - 'duration': 0 - }] - return workorders_values_str + def _json_workpiece_delivery_list(self, production): + return [ + [0, '', {'production_id': production.id, 'type': '上产线'}], + [0, '', {'production_id': production.id, 'type': '下产线'}], + [0, '', {'production_id': production.id, 'type': '运送空料架'}], + ] + + +# 拼接工单对象属性值(表面工艺) +def _json_workorder_surface_process_str(self, production, route, process_parameter, supplier_id): + workorders_values_str = [0, '', { + 'product_uom_id': production.product_uom_id.id, + 'qty_producing': 0, + 'operation_id': False, + 'name': '%s-%s' % (route.name, process_parameter.name), + 'processing_panel': '', + 'routing_type': '表面工艺', + 'surface_technics_parameters_id': process_parameter.id, + 'work_state': '', + 'supplier_id': supplier_id, + 'is_subcontract': True if process_parameter.gain_way == '外协' else False, + 'workcenter_id': self.env[ + 'mrp.workcenter'].get_process_outsourcing_workcenter() if process_parameter.gain_way == '外协' else + self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids, + route.routing_type, + production.product_id), + 'date_planned_start': False, + 'date_planned_finished': False, + 'duration_expected': 60, + 'duration': 0 + }] + return workorders_values_str + + +# 维修模块按钮 +def button_maintenance_req(self): + self.ensure_one() + return { + 'name': _('New Maintenance Request'), + 'view_mode': 'form', + 'views': [(self.env.ref('mrp_maintenance.maintenance_request_view_form_inherit_mrp').id, 'form')], + 'res_model': 'maintenance.request', + 'type': 'ir.actions.act_window', + 'context': { + 'default_company_id': self.company_id.id, + 'default_workorder_id': self.id, + 'default_production_id': self.production_id.id, + 'discard_on_footer_button': True, + }, + 'target': 'new', + 'domain': [('workorder_id', '=', self.id)] + } + + +# tray_id = fields.Many2one('sf.tray', string="托盘信息", tracking=True) + +# 扫码绑定托盘方法 + +# def gettray(self): +# if self.tray_code != False: +# values = self.env['sf.tray'].search([("code", "=", self.tray_code)]) +# if values: +# if values.state == "占用": +# raise UserError('该托盘已占用') +# if values.state == "报损": +# raise UserError('该托盘已损坏') +# else: +# values.update({ +# 'workorder_id': self, +# 'production_id': self.production_id, +# 'state': '占用', +# }) +# self.work_state = "已绑定" +# orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)]) +# for a in orders: +# a.tray_id = values +# else: +# raise UserError('该托盘编码已失效') +# else: +# raise UserError('托盘码不能为空') + +# 验证坯料序列号是否正确 +def pro_code_is_ok(self, barcode): + if barcode is not False: + if barcode != self.pro_code: + raise UserError('坯料序列号错误') + return False + else: + return True + + +pro_code = fields.Char(string='坯料序列号') + +pro_code_ok = fields.Boolean(default=False) + + +# 托盘扫码绑定 +# def gettray_auto(self, barcode): +# if barcode != False: +# values = self.env['sf.tray'].search([("code", "=", barcode)]) +# +# if values: +# if values.state == "占用": +# raise UserError('该托盘已占用') +# if values.state == "报损": +# raise UserError('该托盘已损坏') +# else: +# values.update({ +# 'workorder_id': self, +# 'production_id': self.production_id, +# 'state': '占用', +# }) +# self.work_state = "已绑定" +# orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)]) +# for a in orders: +# a.tray_id = values +# +# return values +# +# # return { +# # 'name': _('New Maintenance Request'), +# # 'view_mode': 'form', +# # 'res_model': 'maintenance.request', +# # 'type': 'ir.actions.act_window', +# # 'context': { +# # 'default_company_id': self.company_id.id, +# # 'default_production_id': self.id, +# # }, +# # 'domain': [('production_id', '=', self.id)], +# # } +# else: +# raise UserError('该托盘编码已失效') +# else: +# raise UserError('托盘码不能为空') + +# 解除托盘绑定 +# def unbindtray(self): +# tray = self.env['sf.tray'].search([("production_id", "=", self.production_id.id)]) +# if tray: +# tray.unclamp() +# self.tray_id = False + +# return { +# 'name': _('New Maintenance Request'), +# 'view_mode': 'form', +# 'res_model': 'maintenance.request', +# 'res_id':self.id, +# 'type': 'ir.actions.act_window', +# 'context': { +# 'default_company_id': self.company_id.id, +# 'default_production_id': self.id, +# }, +# 'domain': [('production_id', '=', self.id)], +# 'target':'new' +# } + +def recreateManufacturingOrWorkerOrder(self): + """ + 重新生成制造订单或者重新生成工单 + """ + if self.test_results == '报废': + values = self.env['mrp.production'].create_production1_values(self.production_id) + productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company( + self.production_id.company_id).create( + values) + self.env['stock.move'].sudo().create(productions._get_moves_raw_values()) + self.env['stock.move'].sudo().create(productions._get_moves_finished_values()) + productions._create_workorder() + productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \ + ( + p.move_dest_ids.procure_method != 'make_to_order' and + not p.move_raw_ids and not p.workorder_ids)).action_confirm() + + for production in productions: + origin_production = production.move_dest_ids and production.move_dest_ids[ + 0].raw_material_production_id or False + orderpoint = production.orderpoint_id + if orderpoint and orderpoint.create_uid.id == SUPERUSER_ID and orderpoint.trigger == 'manual': + production.message_post( + body=_('This production order has been created from Replenishment Report.'), + message_type='comment', + subtype_xmlid='mail.mt_note') + elif orderpoint: + production.message_post_with_view( + 'mail.message_origin_link', + values={'self': production, 'origin': orderpoint}, + subtype_id=self.env.ref('mail.mt_note').id) + elif origin_production: + production.message_post_with_view( + 'mail.message_origin_link', + values={'self': production, 'origin': origin_production}, + subtype_id=self.env.ref('mail.mt_note').id) + if self.test_results == '返工': + productions = self.production_id + # self.env['stock.move'].sudo().create(productions._get_moves_raw_values()) + # self.env['stock.move'].sudo().create(productions._get_moves_finished_values()) + productions._create_workorder2(self.processing_panel) + else: + self.results = '合格' + + +def json_workorder_str1(self, k, production, route): + workorders_values_str = [0, '', { + 'product_uom_id': production.product_uom_id.id, + 'qty_producing': 0, + 'operation_id': False, + 'name': '%s(返工)' % route.route_workcenter_id.name, + 'processing_panel': k, + 'routing_type': route.routing_type, + 'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起', + 'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids, + route.routing_type, + production.product_id), + 'date_planned_start': False, + 'date_planned_finished': False, + 'duration_expected': 60, + 'duration': 0, + + }] + return workorders_values_str + + +# 重写工单开始按钮方法 +def button_start(self): + if self.routing_type == '装夹预调' and self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name: + self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name + # 外协出库单,从“正在等待”变为“就绪”状态 + if self.is_subcontract is True: + picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)]) + if picking_out.state == 'confirmed': + picking_out.write({'state': 'assigned'}) + if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress': + self.move_raw_ids = self.production_id.move_raw_ids + self.move_raw_ids[0].write({ + 'materiel_length': self.move_raw_ids[0].product_id.length, + 'materiel_width': self.move_raw_ids[0].product_id.width, + 'materiel_height': self.move_raw_ids[0].product_id.height + }) - # 维修模块按钮 - def button_maintenance_req(self): self.ensure_one() - return { - 'name': _('New Maintenance Request'), - 'view_mode': 'form', - 'views': [(self.env.ref('mrp_maintenance.maintenance_request_view_form_inherit_mrp').id, 'form')], - 'res_model': 'maintenance.request', - 'type': 'ir.actions.act_window', - 'context': { - 'default_company_id': self.company_id.id, - 'default_workorder_id': self.id, - 'default_production_id': self.production_id.id, - 'discard_on_footer_button': True, - }, - 'target': 'new', - 'domain': [('workorder_id', '=', self.id)] - } + if any(not time.date_end for time in self.time_ids.filtered(lambda t: t.user_id.id == self.env.user.id)): + return True + # As button_start is automatically called in the new view + if self.state in ('done', 'cancel'): + return True - # tray_id = fields.Many2one('sf.tray', string="托盘信息", tracking=True) - - # 扫码绑定托盘方法 - - # def gettray(self): - # if self.tray_code != False: - # values = self.env['sf.tray'].search([("code", "=", self.tray_code)]) - # if values: - # if values.state == "占用": - # raise UserError('该托盘已占用') - # if values.state == "报损": - # raise UserError('该托盘已损坏') - # else: - # values.update({ - # 'workorder_id': self, - # 'production_id': self.production_id, - # 'state': '占用', - # }) - # self.work_state = "已绑定" - # orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)]) - # for a in orders: - # a.tray_id = values - # else: - # raise UserError('该托盘编码已失效') - # else: - # raise UserError('托盘码不能为空') - - # 验证坯料序列号是否正确 - def pro_code_is_ok(self, barcode): - if barcode is not False: - if barcode != self.pro_code: - raise UserError('坯料序列号错误') - return False - else: - return True - - pro_code = fields.Char(string='坯料序列号') - - pro_code_ok = fields.Boolean(default=False) - - # 托盘扫码绑定 - # def gettray_auto(self, barcode): - # if barcode != False: - # values = self.env['sf.tray'].search([("code", "=", barcode)]) - # - # if values: - # if values.state == "占用": - # raise UserError('该托盘已占用') - # if values.state == "报损": - # raise UserError('该托盘已损坏') - # else: - # values.update({ - # 'workorder_id': self, - # 'production_id': self.production_id, - # 'state': '占用', - # }) - # self.work_state = "已绑定" - # orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)]) - # for a in orders: - # a.tray_id = values - # - # return values - # - # # return { - # # 'name': _('New Maintenance Request'), - # # 'view_mode': 'form', - # # 'res_model': 'maintenance.request', - # # 'type': 'ir.actions.act_window', - # # 'context': { - # # 'default_company_id': self.company_id.id, - # # 'default_production_id': self.id, - # # }, - # # 'domain': [('production_id', '=', self.id)], - # # } - # else: - # raise UserError('该托盘编码已失效') - # else: - # raise UserError('托盘码不能为空') - - # 解除托盘绑定 - # def unbindtray(self): - # tray = self.env['sf.tray'].search([("production_id", "=", self.production_id.id)]) - # if tray: - # tray.unclamp() - # self.tray_id = False - - # return { - # 'name': _('New Maintenance Request'), - # 'view_mode': 'form', - # 'res_model': 'maintenance.request', - # 'res_id':self.id, - # 'type': 'ir.actions.act_window', - # 'context': { - # 'default_company_id': self.company_id.id, - # 'default_production_id': self.id, - # }, - # 'domain': [('production_id', '=', self.id)], - # 'target':'new' - # } - - def recreateManufacturingOrWorkerOrder(self): - """ - 重新生成制造订单或者重新生成工单 - """ - if self.test_results == '报废': - values = self.env['mrp.production'].create_production1_values(self.production_id) - productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company( - self.production_id.company_id).create( - values) - self.env['stock.move'].sudo().create(productions._get_moves_raw_values()) - self.env['stock.move'].sudo().create(productions._get_moves_finished_values()) - productions._create_workorder() - productions.filtered(lambda p: (not p.orderpoint_id and p.move_raw_ids) or \ - ( - p.move_dest_ids.procure_method != 'make_to_order' and - not p.move_raw_ids and not p.workorder_ids)).action_confirm() - - for production in productions: - origin_production = production.move_dest_ids and production.move_dest_ids[ - 0].raw_material_production_id or False - orderpoint = production.orderpoint_id - if orderpoint and orderpoint.create_uid.id == SUPERUSER_ID and orderpoint.trigger == 'manual': - production.message_post( - body=_('This production order has been created from Replenishment Report.'), - message_type='comment', - subtype_xmlid='mail.mt_note') - elif orderpoint: - production.message_post_with_view( - 'mail.message_origin_link', - values={'self': production, 'origin': orderpoint}, - subtype_id=self.env.ref('mail.mt_note').id) - elif origin_production: - production.message_post_with_view( - 'mail.message_origin_link', - values={'self': production, 'origin': origin_production}, - subtype_id=self.env.ref('mail.mt_note').id) - if self.test_results == '返工': - productions = self.production_id - # self.env['stock.move'].sudo().create(productions._get_moves_raw_values()) - # self.env['stock.move'].sudo().create(productions._get_moves_finished_values()) - productions._create_workorder2(self.processing_panel) + if self.product_tracking == 'serial': + self.qty_producing = 1.0 else: - self.results = '合格' + self.qty_producing = self.qty_remaining - def json_workorder_str1(self, k, production, route): - workorders_values_str = [0, '', { - 'product_uom_id': production.product_uom_id.id, - 'qty_producing': 0, - 'operation_id': False, - 'name': '%s(返工)' % route.route_workcenter_id.name, - 'processing_panel': k, - 'routing_type': route.routing_type, - 'work_state': '' if not route.routing_type == '获取CNC加工程序' else '待发起', - 'workcenter_id': self.env['mrp.routing.workcenter'].get_workcenter(route.workcenter_ids.ids, - route.routing_type, - production.product_id), - 'date_planned_start': False, - 'date_planned_finished': False, - 'duration_expected': 60, - 'duration': 0, - - }] - return workorders_values_str - - # 重写工单开始按钮方法 - def button_start(self): - if self.routing_type == '装夹预调' and self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name: - self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name - # 外协出库单,从“正在等待”变为“就绪”状态 - if self.is_subcontract is True: - picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)]) - if picking_out.state == 'confirmed': - picking_out.write({'state': 'assigned'}) - if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress': - self.move_raw_ids = self.production_id.move_raw_ids - self.move_raw_ids[0].write({ - 'materiel_length': self.move_raw_ids[0].product_id.length, - 'materiel_width': self.move_raw_ids[0].product_id.width, - 'materiel_height': self.move_raw_ids[0].product_id.height + self.env['mrp.workcenter.productivity'].create( + self._prepare_timeline_vals(self.duration, datetime.now()) + ) + if self.production_id.state != 'progress': + self.production_id.write({ + 'date_start': datetime.now(), }) - - self.ensure_one() - if any(not time.date_end for time in self.time_ids.filtered(lambda t: t.user_id.id == self.env.user.id)): - return True - # As button_start is automatically called in the new view - if self.state in ('done', 'cancel'): - return True - - if self.product_tracking == 'serial': - self.qty_producing = 1.0 - else: - self.qty_producing = self.qty_remaining - - self.env['mrp.workcenter.productivity'].create( - self._prepare_timeline_vals(self.duration, datetime.now()) - ) - if self.production_id.state != 'progress': - self.production_id.write({ - 'date_start': datetime.now(), - }) - if self.state == 'progress': - return True - start_date = datetime.now() - vals = { - 'state': 'progress', - 'date_start': start_date, - } - if not self.leave_id: - leave = self.env['resource.calendar.leaves'].create({ - 'name': self.display_name, - 'calendar_id': self.workcenter_id.resource_calendar_id.id, - 'date_from': start_date, - 'date_to': start_date + relativedelta(minutes=self.duration_expected), - 'resource_id': self.workcenter_id.resource_id.id, - 'time_type': 'other' - }) - vals['leave_id'] = leave.id - return self.write(vals) - else: - if self.date_planned_start > start_date: - vals['date_planned_start'] = start_date - if self.date_planned_finished and self.date_planned_finished < start_date: - vals['date_planned_finished'] = start_date - return self.write(vals) + if self.state == 'progress': + return True + start_date = datetime.now() + vals = { + 'state': 'progress', + 'date_start': start_date, + } + if not self.leave_id: + leave = self.env['resource.calendar.leaves'].create({ + 'name': self.display_name, + 'calendar_id': self.workcenter_id.resource_calendar_id.id, + 'date_from': start_date, + 'date_to': start_date + relativedelta(minutes=self.duration_expected), + 'resource_id': self.workcenter_id.resource_id.id, + 'time_type': 'other' + }) + vals['leave_id'] = leave.id + return self.write(vals) else: - raise UserError(_('请先完成上一步工单')) + if self.date_planned_start > start_date: + vals['date_planned_start'] = start_date + if self.date_planned_finished and self.date_planned_finished < start_date: + vals['date_planned_finished'] = start_date + return self.write(vals) + else: + raise UserError(_('请先完成上一步工单')) - def button_finish(self): - if self.routing_type == '装夹预调': - if not self.material_center_point and self.X_deviation_angle > 0: - raise UserError("请对前置三元检测定位参数进行计算定位") - if not self.rfid_code: - raise UserError("请扫RFID码进行绑定") - if self.picking_out_id: - picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)]) - if picking_out.workorder_out_id: - order_line_ids = [] - for item in picking_out.workorder_out_id: - server_product = self.env['product.template'].search( - [('server_product_process_parameters_id', '=', item.surface_technics_parameters_id.id), - ('detailed_type', '=', 'service')]) - if server_product: - order_line_ids.append((0, 0, { - 'product_id': server_product.product_variant_id.id, - 'product_qty': 1, - 'product_uom': server_product.uom_id.id - })) - else: - raise UserError( - '请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name) - self.env['purchase.order'].create({ - 'partner_id': server_product.seller_ids.partner_id.id, - 'state': 'draft', - 'order_line': order_line_ids, - }) - super().button_finish() - is_production_id = True + +def button_finish(self): + if self.routing_type == '装夹预调': + if not self.material_center_point and self.X_deviation_angle > 0: + raise UserError("请对前置三元检测定位参数进行计算定位") + if not self.rfid_code: + raise UserError("请扫RFID码进行绑定") + if self.picking_out_id: + picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)]) + if picking_out.workorder_out_id: + order_line_ids = [] + for item in picking_out.workorder_out_id: + server_product = self.env['product.template'].search( + [('server_product_process_parameters_id', '=', item.surface_technics_parameters_id.id), + ('detailed_type', '=', 'service')]) + if server_product: + order_line_ids.append((0, 0, { + 'product_id': server_product.product_variant_id.id, + 'product_qty': 1, + 'product_uom': server_product.uom_id.id + })) + else: + raise UserError( + '请先在产品中配置表面工艺为%s相关的外协服务产品' % item.surface_technics_parameters_id.name) + self.env['purchase.order'].create({ + 'partner_id': server_product.seller_ids.partner_id.id, + 'state': 'draft', + 'order_line': order_line_ids, + }) + super().button_finish() + is_production_id = True + for workorder in self.production_id.workorder_ids: + if workorder.state != 'done': + is_production_id = False + if is_production_id == True and self.name == '解除装夹': for workorder in self.production_id.workorder_ids: - if workorder.state != 'done': - is_production_id = False - if is_production_id == True and self.name == '解除装夹': - for workorder in self.production_id.workorder_ids: - workorder.rfid_code_old = workorder.rfid_code - workorder.rfid_code = None - for move_raw_id in self.production_id.move_raw_ids: - move_raw_id.quantity_done = move_raw_id.product_uom_qty - self.production_id.button_mark_done1() - # self.production_id.state = 'done' + workorder.rfid_code_old = workorder.rfid_code + workorder.rfid_code = None + for move_raw_id in self.production_id.move_raw_ids: + move_raw_id.quantity_done = move_raw_id.product_uom_qty + self.production_id.button_mark_done1() + # self.production_id.state = 'done' - # 将FTP的检测报告文件下载到临时目录 - def download_reportfile_tmp(self, workorder, reportpath): - logging.info('reportpath:%s' % reportpath) - production_no_ftp = reportpath.split('/') - production_no = workorder.production_id.name.replace('/', '_') - # ftp地址 - remotepath = os.path.join('/NC', production_no_ftp[1], 'detection') - logging.info('ftp地址:%s' % remotepath) - if reportpath.find(production_no) != -1: - # 服务器内临时地址 - serverdir = os.path.join('/tmp', production_no_ftp[1], 'detection') - 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']) - download_state = ftp.download_reportfile_tree(remotepath, serverdir, reportpath) - logging.info('download_state:%s' % download_state) - else: - download_state = 2 - return download_state - # 根据中控系统提供的检测文件地址去ftp里对应的制造订单里获取 - def get_detection_file(self, workorder, reportPath): - if reportPath.startswith('/'): - reportPath = reportPath[1:] - serverdir = os.path.join('/tmp', reportPath) - logging.info('get_detection_file-serverdir:%s' % serverdir) - serverdir_prefix = os.path.dirname(serverdir) - for root, dirs, files in os.walk(serverdir_prefix): - for filename in files: - if filename == os.path.basename(reportPath): - report_file_path = os.path.join(root, filename) - logging.info('get_detection_file-report_file_path:%s' % report_file_path) - workorder.detection_report = base64.b64encode(open(report_file_path, 'rb').read()) - return True +# 将FTP的检测报告文件下载到临时目录 +def download_reportfile_tmp(self, workorder, reportpath): + logging.info('reportpath:%s' % reportpath) + production_no_ftp = reportpath.split('/') + production_no = workorder.production_id.name.replace('/', '_') + # ftp地址 + remotepath = os.path.join('/NC', production_no_ftp[1], 'detection') + logging.info('ftp地址:%s' % remotepath) + if reportpath.find(production_no) != -1: + # 服务器内临时地址 + serverdir = os.path.join('/tmp', production_no_ftp[1], 'detection') + 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']) + download_state = ftp.download_reportfile_tree(remotepath, serverdir, reportpath) + logging.info('download_state:%s' % download_state) + else: + download_state = 2 + return download_state + + +# 根据中控系统提供的检测文件地址去ftp里对应的制造订单里获取 +def get_detection_file(self, workorder, reportPath): + if reportPath.startswith('/'): + reportPath = reportPath[1:] + serverdir = os.path.join('/tmp', reportPath) + logging.info('get_detection_file-serverdir:%s' % serverdir) + serverdir_prefix = os.path.dirname(serverdir) + for root, dirs, files in os.walk(serverdir_prefix): + for filename in files: + if filename == os.path.basename(reportPath): + report_file_path = os.path.join(root, filename) + logging.info('get_detection_file-report_file_path:%s' % report_file_path) + workorder.detection_report = base64.b64encode(open(report_file_path, 'rb').read()) + return True class CNCprocessing(models.Model): @@ -1084,6 +1100,8 @@ class WorkPieceDelivery(models.Model): feeder_station_destination_id = fields.Many2one('sf.agv.site', '目的接驳站') task_delivery_time = fields.Datetime('任务下发时间') task_completion_time = fields.Datetime('任务完成时间') + type = fields.Selection( + [('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型') delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration') status = fields.Selection( [('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', @@ -1124,6 +1142,9 @@ class WorkPieceDelivery(models.Model): # 配送至avg小车 def _delivery_avg(self): + agv_site = self.env['sf.agv.site'].search([]) + if agv_site: + agv_site.update_site_state() config = self.env['res.config.settings'].get_values() positionCode_Arr = [] if self.feeder_station_start_id: @@ -1143,7 +1164,7 @@ class WorkPieceDelivery(models.Model): 'podDir': '', 'materialLot': '', 'priority': '', 'taskCode': '', 'agvCode': '', 'materialLot': '', 'data': ''} try: - config['agv_rcs_url'] = 'http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask' + # config['agv_rcs_url'] = 'http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask' logging.info('AGV请求路径:%s' % config['agv_rcs_url']) logging.info('AGV-json:%s' % res) headers = {'Content-Type': 'application/json'} diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index d766629c..16ea429a 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -7,8 +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_manufacturing/wizard/workpiece_delivery_views.xml b/sf_manufacturing/wizard/workpiece_delivery_views.xml index 34625878..83cfb89f 100644 --- a/sf_manufacturing/wizard/workpiece_delivery_views.xml +++ b/sf_manufacturing/wizard/workpiece_delivery_views.xml @@ -5,18 +5,11 @@ sf.workpiece.delivery.wizard - - - -
- - 确认上述信息正确无误. -
+
是否确定配送?
-
diff --git a/sf_manufacturing/wizard/workpiece_delivery_wizard.py b/sf_manufacturing/wizard/workpiece_delivery_wizard.py index 1de3e84c..ab7f4556 100644 --- a/sf_manufacturing/wizard/workpiece_delivery_wizard.py +++ b/sf_manufacturing/wizard/workpiece_delivery_wizard.py @@ -11,8 +11,6 @@ class WorkpieceDeliveryWizard(models.TransientModel): delivery_id = fields.Many2one('sf.workpiece.delivery', string='配送') workorder_id = fields.Many2one('mrp.workorder', string='工单') - route_id = fields.Many2one('sf.agv.task.route', '任务路线') - is_ok = fields.Boolean('确认上述信息正确无误.') def confirm(self): if self.workorder_id: diff --git a/sf_mrs_connect/models/res_config_setting.py b/sf_mrs_connect/models/res_config_setting.py index ef2d93d8..035b10a0 100644 --- a/sf_mrs_connect/models/res_config_setting.py +++ b/sf_mrs_connect/models/res_config_setting.py @@ -17,6 +17,7 @@ class ResConfigSettings(models.TransientModel): default='http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask') center_control_url = fields.Char(string='中控访问地址', default='http://172.16.21.50:8001') + center_control_Authorization = fields.Char(string='中控访问认证') wbcode = fields.Char('地码') agv_code = fields.Char(string='agv编号') task_type_no = fields.Char('任务单类型编号') @@ -102,6 +103,7 @@ class ResConfigSettings(models.TransientModel): wbcode = config.get_param('wbcode', default='') agv_code = config.get_param('agv_code', default='') center_control_url = config.get_param('center_control_url', default='') + center_control_Authorization = config.get_param('center_control_Authorization', default='') ftp_host = config.get_param('ftp_host', default='') ftp_port = config.get_param('ftp_port', default='') ftp_user = config.get_param('ftp_user', default='') @@ -115,6 +117,7 @@ class ResConfigSettings(models.TransientModel): wbcode=wbcode, agv_code=agv_code, center_control_url=center_control_url, + center_control_Authorization=center_control_Authorization, ftp_host=ftp_host, ftp_port=ftp_port, ftp_user=ftp_user, @@ -132,6 +135,7 @@ class ResConfigSettings(models.TransientModel): ir_config.set_param("wbcode", self.wbcode or "") ir_config.set_param("agv_code", self.agv_code or "") ir_config.set_param("center_control_url", self.center_control_url or "") + ir_config.set_param("center_control_Authorization", self.center_control_Authorization or "") ir_config.set_param("ftp_host", self.ftp_host or "") ir_config.set_param("ftp_port", self.ftp_port or "") ir_config.set_param("ftp_user", self.ftp_user or "") diff --git a/sf_mrs_connect/views/res_config_settings_views.xml b/sf_mrs_connect/views/res_config_settings_views.xml index 0d1ccc3e..2be92365 100644 --- a/sf_mrs_connect/views/res_config_settings_views.xml +++ b/sf_mrs_connect/views/res_config_settings_views.xml @@ -106,6 +106,10 @@