From a06dc38f530301a6abcdb055b7be4ce8c8b8218c Mon Sep 17 00:00:00 2001 From: Graeme Gellatly Date: Wed, 6 Dec 2017 22:21:51 +1300 Subject: [PATCH] [FIX] Runbot error, try new cron code, plus @yajo review cleanup --- base_report_to_printer/README.rst | 9 ++--- base_report_to_printer/data/printing_data.xml | 4 +-- .../9.0.2.0.0/post-10-create_server_record.py | 19 ----------- .../static/src/js/qweb_action_manager.js | 34 +++++++++++-------- 4 files changed, 23 insertions(+), 43 deletions(-) delete mode 100644 base_report_to_printer/migrations/9.0.2.0.0/post-10-create_server_record.py diff --git a/base_report_to_printer/README.rst b/base_report_to_printer/README.rst index ecce690..a47b4ed 100644 --- a/base_report_to_printer/README.rst +++ b/base_report_to_printer/README.rst @@ -40,8 +40,8 @@ Installation sudo apt-get install cups sudo apt-get install libcups2-dev - sudo apt-get install python-dev OR sudo apt-get install python3-dev - sudo easy_install pycups OR sudo pip install pycups + sudo apt-get install python3-dev + sudo pip install pycups Configuration @@ -77,11 +77,6 @@ displayed for the deprecated report types (RML, Webkit, ...). :target: https://runbot.odoo-community.org/runbot/144/11.0 -Known issues / Roadmap -====================== - - - Bug Tracker =========== diff --git a/base_report_to_printer/data/printing_data.xml b/base_report_to_printer/data/printing_data.xml index 7c88ad4..1763048 100644 --- a/base_report_to_printer/data/printing_data.xml +++ b/base_report_to_printer/data/printing_data.xml @@ -26,8 +26,8 @@ -1 - - + code + model.action_update_jobs() diff --git a/base_report_to_printer/migrations/9.0.2.0.0/post-10-create_server_record.py b/base_report_to_printer/migrations/9.0.2.0.0/post-10-create_server_record.py deleted file mode 100644 index 6ae342b..0000000 --- a/base_report_to_printer/migrations/9.0.2.0.0/post-10-create_server_record.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2016 SYLEAM () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from openerp import SUPERUSER_ID, api -from openerp.tools.config import config - -__name__ = 'Create a printing.server record from previous configuration' - - -def migrate(cr, v): - with api.Environment.manage(): - uid = SUPERUSER_ID - env = api.Environment(cr, uid, {}) - env['printing.server'].create({ - 'name': config.get('cups_host', 'localhost'), - 'address': config.get('cups_host', 'localhost'), - 'port': config.get('cups_port', 631), - }) diff --git a/base_report_to_printer/static/src/js/qweb_action_manager.js b/base_report_to_printer/static/src/js/qweb_action_manager.js index d1f884f..7133e0f 100644 --- a/base_report_to_printer/static/src/js/qweb_action_manager.js +++ b/base_report_to_printer/static/src/js/qweb_action_manager.js @@ -15,21 +15,25 @@ odoo.define('base_report_to_printer.print', function(require) { if ('report_type' in action_val && action_val.report_type === 'qweb-pdf') { framework.blockUI(); - new Model('ir.actions.report'). - call('print_action_for_report_name', [action_val.report_name]). - then(function(print_action){ - if (print_action && print_action.action_val === 'server') { - framework.unblockUI(); - new Model('report'). - call('print_document', - [action_val.context.active_ids, action_val.report_name], - {data: action_val.data || {}, context: action_val.context || {}}). - then(function(){ - self.do_notify(_t('Report'), - _t('Document sent to the printer ') + print_action.printer_name); - }).fail(function() { - self.do_notify(_t('Report'), - _t('Error when sending the document to the printer ') + print_action.printer_name); + rpc.query({ + model: 'ir.actions.report', + method: 'print_action_for_report_name', + args: [action_val.report_name] + }).then(function (print_action) { + if (print_action && print_action.action_val === 'server') { + framework.unblockUI(); + rpc.query({ + model: 'ir.actions.report', + method: 'print_document', + args: [action_val.context.active_ids, action_val.report_name], + kwargs: {data: action_val.data || {}}, + context: action_val.context || {} + }).then(function () { + self.do_notify(_t('Report'), + _.str.sprintf(_t('Document sent to the printer %s'), print_action.printer_name)); + }).fail(function () { + self.do_notify(_t('Report'), + _.str.sprintf(_t('Error when sending the document to the printer '), print_action.printer_name)); }); } else {