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) {