From dc5b68cca08bd96c438bd63bc78e322d07f83e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Tue, 20 Aug 2024 10:45:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E6=80=BB=E7=9B=91=E3=80=81?= =?UTF-8?q?=E6=9C=BA=E5=BA=8A=E6=93=8D=E4=BD=9C=E5=B2=97=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?agv=E8=B0=83=E5=BA=A6=E8=8F=9C=E5=8D=95=E6=9D=83=E9=99=90?= =?UTF-8?q?=EF=BC=8CAGV=E4=B8=8B=E5=8F=91=E4=BB=BB=E5=8A=A1=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E9=9C=80=E4=BA=8C=E6=AC=A1=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/__manifest__.py | 1 + sf_manufacturing/controllers/controllers.py | 4 +- sf_manufacturing/models/agv_scheduling.py | 1 + .../js/workpiece_delivery_wizard_confirm.js | 53 +++++++++++++++ .../views/agv_scheduling_views.xml | 1 + sf_manufacturing/views/mrp_workorder_view.xml | 6 ++ .../wizard/workpiece_delivery_views.xml | 4 +- .../wizard/workpiece_delivery_wizard.py | 68 ++++++++++++------- sf_plan/views/view.xml | 1 + 9 files changed, 112 insertions(+), 27 deletions(-) create mode 100644 sf_manufacturing/static/src/js/workpiece_delivery_wizard_confirm.js diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 9ea3bb60..e84b34cc 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -43,6 +43,7 @@ 'sf_manufacturing/static/src/js/kanban_change.js', 'sf_manufacturing/static/src/scss/kanban_change.scss', 'sf_manufacturing/static/src/xml/button_show_on_tree.xml', + 'sf_manufacturing/static/src/js/workpiece_delivery_wizard_confirm.js', ] }, diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 84ee9f46..4c5788ef 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -458,7 +458,7 @@ class Manufacturing_Connect(http.Controller): if f'RfidCode{i}' in ret: rfid_code = ret[f'RfidCode{i}'] logging.info('RfidCode:%s' % rfid_code) - if rfid_code is not None: + if rfid_code is not None and rfid_code != '': rfid_codes.append(rfid_code) domain = [ ('rfid_code', '=', rfid_code), @@ -531,7 +531,7 @@ class Manufacturing_Connect(http.Controller): if f'RfidCode{i}' in ret: rfid_code = ret[f'RfidCode{i}'] logging.info('RfidCode:%s' % rfid_code) - if rfid_code is not None: + if rfid_code is not None and rfid_code != '': domain = [ ('rfid_code', '=', rfid_code), ('routing_type', '=', 'CNC加工'), ('state', '!=', 'rework') diff --git a/sf_manufacturing/models/agv_scheduling.py b/sf_manufacturing/models/agv_scheduling.py index c84f741d..4fbfbf8d 100644 --- a/sf_manufacturing/models/agv_scheduling.py +++ b/sf_manufacturing/models/agv_scheduling.py @@ -88,6 +88,7 @@ class AgvScheduling(models.Model): agv_route_type: AGV任务类型 workorders: 工单 """ + _logger.info('创建AGV调度任务\r\n起点为【%s】,任务类型为【%s】,工单为【%s】' % (agv_start_site_name, agv_route_type, workorders)) if not workorders: raise UserError(_('工单不能为空')) agv_start_site = self.env['sf.agv.site'].sudo().search([('name', '=', agv_start_site_name)], limit=1) diff --git a/sf_manufacturing/static/src/js/workpiece_delivery_wizard_confirm.js b/sf_manufacturing/static/src/js/workpiece_delivery_wizard_confirm.js new file mode 100644 index 00000000..cb044955 --- /dev/null +++ b/sf_manufacturing/static/src/js/workpiece_delivery_wizard_confirm.js @@ -0,0 +1,53 @@ +odoo.define('sf_manufacturing.action_dispatch_confirm', function (require) { + const core = require('web.core'); + const ajax = require('web.ajax'); + const Dialog = require('web.Dialog'); + var rpc = require('web.rpc'); + var _t = core._t; + + async function dispatch_confirm(parent, {params}) { + console.log(params, 'params') + console.log("
本次下发的工件数量为:" + params.workorder_count + ",是否确认?
", 'content') + const dialog = new Dialog(parent, { + title: "确认", + $content: $('
').append("请确认是否仅配送" + params.workorder_count + "个工件?"), + buttons: [ + { text: "确认", classes: 'btn-primary', close: true, click: () => dispatchConfirmed(parent, params) }, + { text: "取消", close: true }, + ], + }); + dialog.open(); + + + async function dispatchConfirmed(parent, params) { + console.log(parent, 'parent') + rpc.query({ + model: 'sf.workpiece.delivery.wizard', + method: 'confirm', + args: [params.active_id] + , + kwargs: { + context: params.context, + } + }).then(res => { + console.log(res, 'res') + console.log(res.name, 'res') + parent.services.action.doAction({ + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'target': 'new', + 'params': { + 'message': '任务下发成功!AGV任务调度编号为【' + res.name + '】', + 'type': 'success', + 'sticky': false, + 'next': {'type': 'ir.actions.act_window_close'}, + } + }); + }) + + } + } + + core.action_registry.add('dispatch_confirm', dispatch_confirm); + return dispatch_confirm; +}); diff --git a/sf_manufacturing/views/agv_scheduling_views.xml b/sf_manufacturing/views/agv_scheduling_views.xml index be7b35cf..ef932e54 100644 --- a/sf_manufacturing/views/agv_scheduling_views.xml +++ b/sf_manufacturing/views/agv_scheduling_views.xml @@ -73,6 +73,7 @@ sequence="28" action="action_agv_scheduling_tree" parent="mrp.menu_mrp_manufacturing" + groups="sf_base.group_sf_order_user,sf_base.group_sf_mrp_manager,sf_base.group_sf_equipment_user" /> \ No newline at end of file diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index b0815ed5..12b15968 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -835,5 +835,11 @@ tree [('type','in',['运送空料架']),('name','not ilike','WDO')] + + diff --git a/sf_manufacturing/wizard/workpiece_delivery_views.xml b/sf_manufacturing/wizard/workpiece_delivery_views.xml index cec33be9..a4723b6b 100644 --- a/sf_manufacturing/wizard/workpiece_delivery_views.xml +++ b/sf_manufacturing/wizard/workpiece_delivery_views.xml @@ -18,8 +18,8 @@