From 568f3e4f3021dd8d3e8c67a4de6e9f20d40d2618 Mon Sep 17 00:00:00 2001 From: hyyy <123@qq.com> Date: Tue, 17 Jun 2025 09:58:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BC=A0=E5=8F=82=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8F=90=E7=A4=BA=EF=BC=8C=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E7=AC=AC=E4=B8=80=E4=B8=AA=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_demand_plan/static/src/js/print_demand.js | 32 +++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/sf_demand_plan/static/src/js/print_demand.js b/sf_demand_plan/static/src/js/print_demand.js index e66484f0..6dacc7b3 100644 --- a/sf_demand_plan/static/src/js/print_demand.js +++ b/sf_demand_plan/static/src/js/print_demand.js @@ -10,7 +10,8 @@ odoo.define('sf_demand.print_demand', function (require) { var CustomListRenderer = ListRenderer.extend({ _render: function () { var self = this; - this.getParent()?.$buttons.hide() + this.getParent()?.$buttons.hide(); + return this._super.apply(this, arguments).then(function () { // 添加图片预览容器到页面左侧 if (!$('.table-image-preview-container').length) { @@ -34,7 +35,12 @@ odoo.define('sf_demand.print_demand', function (require) { } }); }, - + start: function() { + setTimeout(() => { + this.$el.find('.o_data_row').eq(0).trigger('click') + }, 500); + return this._super(); + }, events: _.extend({}, ListRenderer.prototype.events, { 'click .o_data_row': '_onCustomRowClick', 'click .o_print_custom': '_onPrintClick', @@ -48,7 +54,6 @@ odoo.define('sf_demand.print_demand', function (require) { var $row = $(ev.currentTarget); var index = $row.index(); var data = this.state.data[index]; - console.log(this, 'this', data); if(data.fileData?.fileUrl) { } else { @@ -71,7 +76,6 @@ odoo.define('sf_demand.print_demand', function (require) { Object.assign(data.fileData, attachment) this._getTypeInfo(attachment.mimetype, data.fileData) } - console.log(data, 'data', attachment); const fileUrl = this.getFileUrl(data.fileData.attachment_type, data, key) data.fileData.fileUrl = fileUrl } @@ -90,22 +94,28 @@ odoo.define('sf_demand.print_demand', function (require) { }) }, _onPrintClick(e) { - console.log(e, 'asdsadadsadasdad', this); var print_ids = this.getSelectedIds(); - console.log(print_ids); this._rpc({ model: 'sf.demand.plan.print.wizard', method: 'demand_plan_print', - kwargs: print_ids, + args: [ print_ids ] , // context: this.state.getContext() - }).then(function() { - self.do_notify("成功", "打印任务已发送到打印机"); + }).then((e) => { + + this.getParent()?.getParent()?.env.services?.notification.notify( { + type: 'info', + message: e.message, + }) + // self.do_notify("成功", "打印任务已发送到打印机"); }).catch(function(error) { console.error("打印错误:", error); - self.do_warn("打印失败", error.data.message || "未知错误"); - }); + // self.do_warn("打印失败", error.data.message || "未知错误"); + }).finally(e => { + this.getParent().reload() + + }) }, getFileUrl(attachment_type, data, key) {