[MRG] Portage of base_report_to_printer

This commit is contained in:
Yannick Vaucher
2013-12-27 13:33:49 -05:00
committed by Maxime Chambreuil
13 changed files with 582 additions and 382 deletions

View File

@@ -1,4 +0,0 @@
Ferran Pegueroles <ferran@pegueroles.com>
Albert Cervera i Areny <albert@nan-tic.com>
Davide Corio <davide.corio@agilebg.com>
Lorenzo Battistini <lorenzo.battistini@agilebg.com>

View File

@@ -21,5 +21,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import printing
import wizard
from . import printing
from . import wizard

View File

@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# Copyright (c) 2007 Ferran Pegueroles <ferran@pegueroles.com>
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
# Copyright (C) 2011 Domsense srl (<http://www.domsense.com>)
# Copyright (C) 2013 Camptocamp (<http://www.camptocamp.com>)
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
@@ -26,44 +27,70 @@
'version': '0.1',
'category': 'Generic Modules/Base',
'description': """
Extracted from printjob ( http://apps.openerp.com/addon/1727 ), this module allows to send reports to a printer attached to the server. Settings can be configured globaly, per user, per report and per user and report.
Report to printer
-----------------
This module allows users to send reports to a printer attached to the server.
Configuration
=============
.. image:: http://planet.domsense.com/wp-content/uploads/2011/09/printing-menu.png
:width: 400 px
It adds an optional behaviour on reports to send it directly to a printer.
First of all, you have to load CUPS printers in OpenERP. You can use a wizard that retrieves them automatically. You just have to click on Update Printers from CUPS and printers will appear within the available printers list.
* `Send to Client` is the default behavious providing you a downloadable PDF
* `Send to Printer` prints the report on selected printer
In the next step you will configure the reports to send to the printers.
Report behaviour is defined by settings.
.. image:: http://planet.domsense.com/wp-content/uploads/2011/09/reports.png
:width: 400 px
Through the report form you can define the systems behaviour while producing the report.
Settings can be configured:
.. image:: http://planet.domsense.com/wp-content/uploads/2011/09/report-configuration.png
:width: 400 px
* globaly
* per user
* per report
* per user and report
You can set a global behaviour, or differentiate it according to the user whos printing. In the example, the global behaviour defines to send the report to client directly (Send to Client), therefore without sending it to the printer. But if user elbati is printing, the report will be sent to the selected printer (Send to Printer).
You can also define a default behaviour associated to the user, in order to establish whether a certain user, when not differently set, wants to send the reports always to a specific printer or not.
After installing enable the "Printing / Print Operator" option under access
rights to give users the ability to view the print menu.
After finishing the configuration, you will just have to click on printing button associated to the report (or launch the report by a wizard or whatever) and the system will automatically send the report to the previously set printer
""",
'author': ['Agile Business Group', 'Pegueroles SCP', 'NaN'],
To show all available printers for your server, uses
`Settings/Configuration/Printing/Update Printers from CUPS` wizard.
Then goto the user profile and set the users printing action and default
printer.
Dependencies
------------
This module requires pycups
https://pypi.python.org/pypi/pycups
Contributors
------------
* Ferran Pegueroles <ferran@pegueroles.com>
* Albert Cervera i Areny <albert@nan-tic.com>
* Davide Corio <davide.corio@agilebg.com>
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
* Yannick Vaucher <yannick.vaucher@camptocamp.com>
""",
'author': 'Agile Business Group & Domsense, Pegueroles SCP, NaN',
'website': 'http://www.agilebg.com',
'license': 'AGPL-3',
"depends" : ['base', 'base_calendar'],
"init_xml" : [],
"update_xml" : [
'data': [
'security/security.xml',
'printing_data.xml',
'printing_view.xml',
'wizard/update_printers.xml',
'security/security.xml',
],
"demo_xml" : [],
"active": False,
"installable": False
],
'installable': True,
'auto_install': False,
'application': True,
'external_dependencies': {
'python': ['cups']
}
}

View File

@@ -4,10 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.0.3\n"
"Report-Msgid-Bugs-To: support@openerp.com\n"
"POT-Creation-Date: 2011-09-26 09:06+0000\n"
"PO-Revision-Date: 2011-09-26 09:06+0000\n"
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-05 14:48+0000\n"
"PO-Revision-Date: 2013-11-05 14:48+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -15,11 +15,6 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: base_report_to_printer
#: sql_constraint:res.users:0
msgid "You can not have two users with the same login !"
msgstr ""
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Unavailable"
@@ -35,46 +30,40 @@ msgstr ""
msgid "Unknown"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,status:0
msgid "Status"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,system_name:0
msgid "System Name"
msgstr ""
#. module: base_report_to_printer
#: constraint:res.users:0
msgid "The chosen company is not in the allowed companies for this user"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,location:0
msgid "Location"
msgstr ""
#. module: base_report_to_printer
#: model:ir.actions.act_window,name:base_report_to_printer.action_printing_printer_form
#: model:ir.ui.menu,name:base_report_to_printer.menu_printing_printer_form
#: view:printing.printer:0
msgid "Printers"
msgstr ""
#. module: base_report_to_printer
#: view:ir.actions.report.xml:0
msgid "Print"
msgstr ""
#. module: base_report_to_printer
#: field:res.users,printing_action:0
msgid "Printing Action"
msgstr ""
#. module: base_report_to_printer
#: model:ir.module.module,description:base_report_to_printer.module_meta_information
msgid "Extracted from printjob ( http://apps.openerp.com/addon/1727 ), this module allows to send reports to a printer attached to the server. Settings can be configured globaly, per user, per report and per user and report."
#: field:printing.action,type:0
msgid "Type"
msgstr ""
#. module: base_report_to_printer
#: field:printing.action,type:0
msgid "Type"
#: field:printing.printer,model:0
msgid "Model"
msgstr ""
#. module: base_report_to_printer
@@ -89,12 +78,22 @@ msgstr ""
msgid "Printer"
msgstr ""
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_res_users
msgid "Users"
msgstr ""
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_printing_report_xml_action
#: view:printing.report.xml.action:0
msgid "Report Printing Actions"
msgstr ""
#. module: base_report_to_printer
#: view:ir.actions.report.xml:0
msgid "Specific actions per user"
msgstr ""
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_printing_action
msgid "Print Job Action"
@@ -111,18 +110,13 @@ msgid "Report"
msgstr ""
#. module: base_report_to_printer
#: model:ir.ui.menu,name:base_report_to_printer.menu_printing_config
msgid "Configuration"
#: field:printing.printer,status:0
msgid "Status"
msgstr ""
#. module: base_report_to_printer
#: model:ir.module.module,shortdesc:base_report_to_printer.module_meta_information
msgid "Report to printer"
msgstr ""
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_printjob_printer_update_wizard
msgid "printjob.printer.update.wizard"
#: model:ir.actions.act_window,name:base_report_to_printer.action_printing_printer_form
msgid "Show Printers"
msgstr ""
#. module: base_report_to_printer
@@ -148,7 +142,7 @@ msgid "Default Printer"
msgstr ""
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:189
#: code:addons/base_report_to_printer/printing.py:186
#, python-format
msgid "Send to Client"
msgstr ""
@@ -158,11 +152,6 @@ msgstr ""
msgid "URI"
msgstr ""
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_printing_printer_update_wizard
msgid "printing.printer.update.wizard"
msgstr ""
#. module: base_report_to_printer
#: model:ir.actions.act_window,name:base_report_to_printer.action_printer_update_wizard
#: model:ir.ui.menu,name:base_report_to_printer.menu_printer_update_wizard
@@ -171,7 +160,7 @@ msgid "Update Printers from CUPS"
msgstr ""
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:188
#: code:addons/base_report_to_printer/printing.py:185
#, python-format
msgid "Send to Printer"
msgstr ""
@@ -194,8 +183,8 @@ msgid "Action"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,model:0
msgid "Model"
#: view:ir.actions.report.xml:0
msgid "Security"
msgstr ""
#. module: base_report_to_printer
@@ -218,29 +207,19 @@ msgstr ""
msgid "Actions"
msgstr ""
#. module: base_report_to_printer
#: view:printing.job:0
msgid "Print Jobs"
msgstr ""
#. module: base_report_to_printer
#: view:printing.printer.update.wizard:0
msgid "Cancel"
msgstr ""
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_res_users
msgid "res.users"
#: model:res.groups,name:base_report_to_printer.res_groups_printingprintoperator0
msgid "Printing / Print Operator"
msgstr ""
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:190
#: code:addons/base_report_to_printer/printing.py:187
#, python-format
msgid "Use user's defaults"
msgstr ""
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_ir_actions_report_xml
msgid "ir.actions.report.xml"
msgstr ""

View File

@@ -0,0 +1,225 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * base_report_to_printer
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-05 14:48+0000\n"
"PO-Revision-Date: 2013-11-05 14:48+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Unavailable"
msgstr "Non disponible"
#. module: base_report_to_printer
#: view:printing.printer.update.wizard:0
msgid "This process will create all missing printers from the current CUPS server."
msgstr "Cette opération va créer les imprimantes manquantes à partir du server CUPS courant."
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Unknown"
msgstr "Inconnu"
#. module: base_report_to_printer
#: field:printing.printer,system_name:0
msgid "System Name"
msgstr "Nom sytème"
#. module: base_report_to_printer
#: field:printing.printer,location:0
msgid "Location"
msgstr "Emplacement"
#. module: base_report_to_printer
#: model:ir.ui.menu,name:base_report_to_printer.menu_printing_printer_form
#: view:printing.printer:0
msgid "Printers"
msgstr "Imprimantes"
#. module: base_report_to_printer
#: view:ir.actions.report.xml:0
msgid "Print"
msgstr "Imprimer"
#. module: base_report_to_printer
#: field:res.users,printing_action:0
msgid "Printing Action"
msgstr "Activité d'impression"
#. module: base_report_to_printer
#: field:printing.action,type:0
msgid "Type"
msgstr "Type"
#. module: base_report_to_printer
#: field:printing.printer,model:0
msgid "Model"
msgstr "Modèle"
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Available"
msgstr "Disponible"
#. module: base_report_to_printer
#: field:ir.actions.report.xml,printing_printer_id:0
#: model:ir.model,name:base_report_to_printer.model_printing_printer
#: field:printing.report.xml.action,printer_id:0
msgid "Printer"
msgstr "Imprimante"
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_res_users
msgid "Users"
msgstr "Utilisateurs"
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_printing_report_xml_action
#: view:printing.report.xml.action:0
msgid "Report Printing Actions"
msgstr "Rapport d'activité d'impression"
#. module: base_report_to_printer
#: view:ir.actions.report.xml:0
msgid "Specific actions per user"
msgstr "Action spécifique par utilisateur"
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_printing_action
msgid "Print Job Action"
msgstr "Action de Job d'impression"
#. module: base_report_to_printer
#: field:printing.report.xml.action,user_id:0
msgid "User"
msgstr "Utilisateur"
#. module: base_report_to_printer
#: field:printing.report.xml.action,report_id:0
msgid "Report"
msgstr "Rapport"
#. module: base_report_to_printer
#: field:printing.printer,status:0
msgid "Status"
msgstr "Statut"
#. module: base_report_to_printer
#: model:ir.actions.act_window,name:base_report_to_printer.action_printing_printer_form
msgid "Show Printers"
msgstr "Afficher les imprimantes"
#. module: base_report_to_printer
#: view:printing.printer.update.wizard:0
msgid "Ok"
msgstr "Ok"
#. module: base_report_to_printer
#: field:printing.action,name:0
#: field:printing.printer,name:0
msgid "Name"
msgstr "Nom"
#. module: base_report_to_printer
#: view:printing.printer:0
msgid "Set Default"
msgstr "Définitir par défaut"
#. module: base_report_to_printer
#: field:printing.printer,default:0
#: field:res.users,printing_printer_id:0
msgid "Default Printer"
msgstr "Imprimante par défaut"
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:186
#, python-format
msgid "Send to Client"
msgstr "Envoyer au client"
#. module: base_report_to_printer
#: field:printing.printer,uri:0
msgid "URI"
msgstr "URI"
#. module: base_report_to_printer
#: model:ir.actions.act_window,name:base_report_to_printer.action_printer_update_wizard
#: model:ir.ui.menu,name:base_report_to_printer.menu_printer_update_wizard
#: view:printing.printer.update.wizard:0
msgid "Update Printers from CUPS"
msgstr "Mettre à jour les imprimantes depuis CUPS"
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:185
#, python-format
msgid "Send to Printer"
msgstr "Envoyer à l'imprimante"
#. module: base_report_to_printer
#: model:ir.ui.menu,name:base_report_to_printer.menu_printing_main
#: selection:printing.printer,status:0
msgid "Printing"
msgstr "Impression en cours"
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Error"
msgstr "Erreur"
#. module: base_report_to_printer
#: field:ir.actions.report.xml,property_printing_action:0
#: field:printing.report.xml.action,action:0
msgid "Action"
msgstr "Action"
#. module: base_report_to_printer
#: view:ir.actions.report.xml:0
msgid "Security"
msgstr "Sécurité"
#. module: base_report_to_printer
#: field:printing.printer,status_message:0
msgid "Status Message"
msgstr "Message de Statut"
#. module: base_report_to_printer
#: help:ir.actions.report.xml,printing_action_ids:0
msgid "This field allows configuring action and printer on a per user basis"
msgstr "Ce champs permet de configurer les action et les imprimante par utilisateur"
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Server Error"
msgstr "Erreur serveur"
#. module: base_report_to_printer
#: field:ir.actions.report.xml,printing_action_ids:0
msgid "Actions"
msgstr "Actions"
#. module: base_report_to_printer
#: view:printing.printer.update.wizard:0
msgid "Cancel"
msgstr "Annuler"
#. module: base_report_to_printer
#: model:res.groups,name:base_report_to_printer.res_groups_printingprintoperator0
msgid "Printing / Print Operator"
msgstr ""
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:187
#, python-format
msgid "Use user's defaults"
msgstr "Utiliser la configuration par défaut de l'utilisateur"

View File

@@ -4,22 +4,17 @@
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.0.3\n"
"Report-Msgid-Bugs-To: support@openerp.com\n"
"POT-Creation-Date: 2011-09-26 09:06+0000\n"
"PO-Revision-Date: 2011-09-26 11:14+0100\n"
"Last-Translator: Lorenzo Battistini <lorenzo.battistini@agilebg.com>\n"
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-05 14:48+0000\n"
"PO-Revision-Date: 2013-11-05 14:48+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: base_report_to_printer
#: sql_constraint:res.users:0
msgid "You can not have two users with the same login !"
msgstr "Non è possibile inserire due utenti con lo stesso nome di login!"
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Unavailable"
@@ -35,48 +30,42 @@ msgstr "Questo processo creerà tutte le stampante mancanti dal server CUPS corr
msgid "Unknown"
msgstr "Sconosciuto"
#. module: base_report_to_printer
#: field:printing.printer,status:0
msgid "Status"
msgstr "Stato"
#. module: base_report_to_printer
#: field:printing.printer,system_name:0
msgid "System Name"
msgstr "Nome di sistema"
#. module: base_report_to_printer
#: constraint:res.users:0
msgid "The chosen company is not in the allowed companies for this user"
msgstr "L'azienda selezionata non è tra quelle a cui è permesso l'accesso a questo utente"
#. module: base_report_to_printer
#: field:printing.printer,location:0
msgid "Location"
msgstr "Locazione"
#. module: base_report_to_printer
#: model:ir.actions.act_window,name:base_report_to_printer.action_printing_printer_form
#: model:ir.ui.menu,name:base_report_to_printer.menu_printing_printer_form
#: view:printing.printer:0
msgid "Printers"
msgstr "Stampanti"
#. module: base_report_to_printer
#: view:ir.actions.report.xml:0
msgid "Print"
msgstr ""
#. module: base_report_to_printer
#: field:res.users,printing_action:0
msgid "Printing Action"
msgstr "Azione di stampa"
#. module: base_report_to_printer
#: model:ir.module.module,description:base_report_to_printer.module_meta_information
msgid "Extracted from printjob ( http://apps.openerp.com/addon/1727 ), this module allows to send reports to a printer attached to the server. Settings can be configured globaly, per user, per report and per user and report."
msgstr "Estratto da printjob ( http://apps.openerp.com/addon/1727 ), questo modulo permetto di inviare i report alle stampanti collegate al server. Le impostazioni possono essere configurate globalmente, per utente, per report e per utente e report."
#. module: base_report_to_printer
#: field:printing.action,type:0
msgid "Type"
msgstr "Tipo"
#. module: base_report_to_printer
#: field:printing.printer,model:0
msgid "Model"
msgstr "Model"
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Available"
@@ -89,41 +78,46 @@ msgstr "Disponibile"
msgid "Printer"
msgstr "Stampante"
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_res_users
msgid "Users"
msgstr ""
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_printing_report_xml_action
#: view:printing.report.xml.action:0
msgid "Report Printing Actions"
msgstr "Azioni di stampa report"
msgstr ""
#. module: base_report_to_printer
#: view:ir.actions.report.xml:0
msgid "Specific actions per user"
msgstr ""
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_printing_action
msgid "Print Job Action"
msgstr "Azione di stampa"
msgstr ""
#. module: base_report_to_printer
#: field:printing.report.xml.action,user_id:0
msgid "User"
msgstr "Utente"
msgstr ""
#. module: base_report_to_printer
#: field:printing.report.xml.action,report_id:0
msgid "Report"
msgstr "Report"
msgstr ""
#. module: base_report_to_printer
#: model:ir.ui.menu,name:base_report_to_printer.menu_printing_config
msgid "Configuration"
msgstr "Configurazione"
#: field:printing.printer,status:0
msgid "Status"
msgstr ""
#. module: base_report_to_printer
#: model:ir.module.module,shortdesc:base_report_to_printer.module_meta_information
msgid "Report to printer"
msgstr "Report alla stampante"
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_printjob_printer_update_wizard
msgid "printjob.printer.update.wizard"
msgstr "printjob.printer.update.wizard"
#: model:ir.actions.act_window,name:base_report_to_printer.action_printing_printer_form
msgid "Show Printers"
msgstr ""
#. module: base_report_to_printer
#: view:printing.printer.update.wizard:0
@@ -148,7 +142,7 @@ msgid "Default Printer"
msgstr "Stampante di default"
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:189
#: code:addons/base_report_to_printer/printing.py:186
#, python-format
msgid "Send to Client"
msgstr "Invia al client"
@@ -156,12 +150,7 @@ msgstr "Invia al client"
#. module: base_report_to_printer
#: field:printing.printer,uri:0
msgid "URI"
msgstr "URI"
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_printing_printer_update_wizard
msgid "printing.printer.update.wizard"
msgstr "printing.printer.update.wizard"
msgstr ""
#. module: base_report_to_printer
#: model:ir.actions.act_window,name:base_report_to_printer.action_printer_update_wizard
@@ -171,7 +160,7 @@ msgid "Update Printers from CUPS"
msgstr "Aggiorna stampanti da CUPS"
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:188
#: code:addons/base_report_to_printer/printing.py:185
#, python-format
msgid "Send to Printer"
msgstr "Invia alla stampante"
@@ -194,9 +183,9 @@ msgid "Action"
msgstr "Azione"
#. module: base_report_to_printer
#: field:printing.printer,model:0
msgid "Model"
msgstr "Model"
#: view:ir.actions.report.xml:0
msgid "Security"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,status_message:0
@@ -218,29 +207,19 @@ msgstr "Errore server"
msgid "Actions"
msgstr "Azioni"
#. module: base_report_to_printer
#: view:printing.job:0
msgid "Print Jobs"
msgstr "Stampe"
#. module: base_report_to_printer
#: view:printing.printer.update.wizard:0
msgid "Cancel"
msgstr "Annulla"
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_res_users
msgid "res.users"
msgstr "res.users"
#: model:res.groups,name:base_report_to_printer.res_groups_printingprintoperator0
msgid "Printing / Print Operator"
msgstr ""
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:190
#: code:addons/base_report_to_printer/printing.py:187
#, python-format
msgid "Use user's defaults"
msgstr "Utilizza i default dell'utente"
#. module: base_report_to_printer
#: model:ir.model,name:base_report_to_printer.model_ir_actions_report_xml
msgid "ir.actions.report.xml"
msgstr "ir.actions.report.xml"

144
base_report_to_printer/printing.py Executable file → Normal file
View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# Copyright (c) 2007 Ferran Pegueroles <ferran@pegueroles.com>
# Copyright (c) 2009 Albert Cervera i Areny <albert@nan-tic.com>
# Copyright (C) 2011 Agile Business Group sagl (<http://www.agilebg.com>)
@@ -23,31 +23,25 @@
##############################################################################
import os
import time
import base64
import threading
from tempfile import mkstemp
import logging
import cups
import thread
from threading import Thread
from threading import Lock
import netsvc
import tools
import time
from osv import fields
from osv import osv
import pooler
import tools
from tools.translate import _
from base_calendar import base_calendar
import logging
from openerp import pooler
from openerp.osv import orm, fields
from openerp.tools.translate import _
from openerp.addons.base_calendar import base_calendar
#
# Printers
#
class printing_printer(osv.osv):
class printing_printer(orm.Model):
_name = "printing.printer"
_description = "Printer"
@@ -60,13 +54,14 @@ class printing_printer(osv.osv):
'model': fields.char('Model', size=500, readonly=True),
'location': fields.char('Location', size=500, readonly=True),
'uri': fields.char('URI', size=500, readonly=True),
}
}
_order = "name"
_defaults = {
'default': lambda *a: False,
'status': lambda *a: 'unknown',
}
}
def __init__(self, pool, cr):
super(printing_printer, self).__init__(pool, cr)
@@ -74,7 +69,7 @@ class printing_printer(osv.osv):
self.last_update = None
self.updating = False
def update_printers_status(self, db_name, uid, context):
def update_printers_status(self, db_name, uid, context=None):
db, pool = pooler.get_db_and_pool(db_name)
cr = db.cursor()
@@ -90,13 +85,15 @@ class printing_printer(osv.osv):
4 : 'printing',
5 : 'error'
}
if context is None:
context = {}
try:
# Skip update to avoid the thread being created again
ctx = context.copy()
ctx['skip_update'] = True
ids = self.pool.get('printing.printer').search(cr, uid, [], context=ctx)
for printer in self.pool.get('printing.printer').browse(cr, uid, ids, context=ctx):
ids = self.search(cr, uid, [], context=ctx)
for printer in self.browse(cr, uid, ids, context=ctx):
vals = {}
if server_error:
status = 'server-error'
@@ -112,7 +109,7 @@ class printing_printer(osv.osv):
status = 'unavailable'
vals['status'] = status
self.pool.get('printing.printer').write(cr, uid, [printer.id], vals, context)
self.write(cr, uid, [printer.id], vals, context=context)
cr.commit()
except:
cr.rollback()
@@ -174,16 +171,13 @@ class printing_printer(osv.osv):
self.write(cr, uid, default_ids, {'default':False}, context)
self.write(cr, uid, ids[0], {'default':True}, context)
return True
def get_default(self,cr,uid,context):
printer_ids = self.search(cr, uid,[('default','=',True)])
if printer_ids:
return printer_ids[0]
return False
printing_printer()
#
# Actions
@@ -194,23 +188,22 @@ def _available_action_types(self, cr, uid, context=None):
('server',_('Send to Printer')),
('client',_('Send to Client')),
('user_default',_("Use user's defaults")),
]
]
class printing_action(osv.osv):
class printing_action(orm.Model):
_name = 'printing.action'
_description = 'Print Job Action'
_columns = {
'name': fields.char('Name', size=256, required=True),
'type': fields.selection(_available_action_types, 'Type', required=True),
}
printing_action()
}
#
#
# Users
#
class res_users(osv.osv):
class res_users(orm.Model):
_name = "res.users"
_inherit = "res.users"
@@ -222,17 +215,26 @@ class res_users(osv.osv):
_columns = {
'printing_action': fields.selection(_user_available_action_types, 'Printing Action'),
'printing_printer_id': fields.many2one('printing.printer', 'Default Printer'),
}
res_users()
}
#
# Reports
#
#
class report_xml(osv.osv):
class report_xml(orm.Model):
def print_direct(self, cr, uid, result, format, printer):
def set_print_options(self, cr, uid, report_id, format, context=None):
"""
Hook to set print options
"""
options = {}
if format == 'raw':
options['raw'] = True
return options
def print_direct(self, cr, uid, report_id, result, format, printer, context=None):
user_obj = self.pool.get('res.users')
fd, file_name = mkstemp()
try:
os.write(fd, base64.decodestring(result))
@@ -244,14 +246,13 @@ class report_xml(osv.osv):
printer_system_name = printer
else:
printer_system_name = printer.system_name
if format == 'raw':
# -l is the same as -o raw
cmd = "lpr -l -P %s %s" % (printer_system_name,file_name)
else:
cmd = "lpr -P %s %s" % (printer_system_name,file_name)
connection = cups.Connection()
options = self.set_print_options(cr, uid, report_id, format, context=context)
connection.printFile(printer_system_name, file_name, file_name, options=options)
logger = logging.getLogger('base_report_to_printer')
logger.info("Printing job : '%s'" % cmd)
os.system(cmd)
logger.info("Printing job : '%s'" % file_name)
return True
_inherit = 'ir.actions.report.xml'
@@ -264,22 +265,21 @@ class report_xml(osv.osv):
string='Action',
view_load=True,
method=True,
),
),
'printing_printer_id': fields.many2one('printing.printer', 'Printer'),
'printing_action_ids': fields.one2many('printing.report.xml.action', 'report_id', 'Actions', help='This field allows configuring action and printer on a per user basis'),
}
}
def behaviour(self, cr, uid, ids, context=None):
if context is None:
context={}
result = {}
printer_obj = self.pool.get('printing.printer')
printing_act_obj = self.pool.get('printing.report.xml.action')
# Set hardcoded default action
default_action = 'client'
# Retrieve system wide printer
default_printer = self.pool.get('printing.printer').get_default(cr,uid,context)
default_printer = printer_obj.get_default(cr, uid, context=context)
if default_printer:
default_printer = self.pool.get('printing.printer').browse(cr,uid,default_printer,context).system_name
default_printer = printer_obj.browse(cr, uid, default_printer, context=context)
# Retrieve user default values
@@ -287,7 +287,7 @@ class report_xml(osv.osv):
if user.printing_action:
default_action = user.printing_action
if user.printing_printer_id:
default_printer = user.printing_printer_id.system_name
default_printer = user.printing_printer_id
for report in self.browse(cr, uid, ids, context):
action = default_action
@@ -300,8 +300,12 @@ class report_xml(osv.osv):
printer = report.printing_printer_id
# Retrieve report-user specific values
user_action = self.pool.get('printing.report.xml.action').behaviour(cr, uid, report.id, context)
if user_action and user_action['action'] != 'user_default':
act_ids = printing_act_obj.search(cr, uid,
[('report_id', '=', report.id),
('user_id', '=', uid),
('action', '!=', 'user_default')], context=context)
if act_ids:
user_action = printing_act_obj.behaviour(cr, uid, act_ids[0], context=context)
action = user_action['action']
if user_action['printer']:
printer = user_action['printer']
@@ -309,13 +313,11 @@ class report_xml(osv.osv):
result[report.id] = {
'action': action,
'printer': printer,
}
}
return result
report_xml()
class report_xml_action(osv.osv):
class report_xml_action(orm.Model):
_name = 'printing.report.xml.action'
_description = 'Report Printing Actions'
_columns = {
@@ -323,21 +325,18 @@ class report_xml_action(osv.osv):
'user_id': fields.many2one('res.users', 'User', required=True, ondelete='cascade'),
'action': fields.selection(_available_action_types, 'Action', required=True),
'printer_id': fields.many2one('printing.printer', 'Printer'),
}
}
def behaviour(self, cr, uid, report_id, context=None):
if context is None:
context={}
def behaviour(self, cr, uid, act_id, context=None):
result = {}
ids = self.search(cr, uid, [('report_id','=',report_id),('user_id','=',uid)], context=context)
if not ids:
if not act_id:
return False
action = self.browse(cr, uid, ids[0], context)
action = self.browse(cr, uid, act_id, context=context)
return {
'action': action.action,
'printer': action.printer_id.system_name,
}
report_xml_action()
'printer': action.printer_id,
}
class virtual_report_spool(base_calendar.virtual_report_spool):
@@ -363,8 +362,13 @@ class virtual_report_spool(base_calendar.virtual_report_spool):
if action != 'client':
if (self._reports and self._reports.get(report_id, False) and self._reports[report_id].get('result', False)
and self._reports[report_id].get('format', False)):
report_obj.print_direct(cr, uid, base64.encodestring(self._reports[report_id]['result']),
report_obj.print_direct(cr, uid, report.id, base64.encodestring(self._reports[report_id]['result']),
self._reports[report_id]['format'], printer)
# XXX "Warning" removed as it breaks the workflow
# it would be interesting to have a dialog box to confirm if we really want to print
# in this case it must be with a by pass parameter to allow massive impression
#raise osv.except_osv(_('Printing...'), _('Document sent to printer %s') % (printer,))
except:
cr.rollback()
raise

34
base_report_to_printer/printing_data.xml Executable file → Normal file
View File

@@ -1,20 +1,20 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- printing.action -->
<record model="printing.action" id="printing_action_1">
<field name="name">Send to Printer</field>
<field name="type">server</field>
</record>
<record model="printing.action" id="printing_action_2">
<field name="name">Send to Client</field>
<field name="type">client</field>
</record>
<!-- properties -->
<record forcecreate="True" id="property_printing_action" model="ir.property">
<field name="name">property_printing_action</field>
<field name="fields_id" search="[('model','=','ir.actions.report.xml'),('name','=','property_printing_action')]"/>
<field name="value" eval="'printing.action,'+str(printing_action_2)"/>
</record>
</data>
<data>
<!-- printing.action -->
<record model="printing.action" id="printing_action_1">
<field name="name">Send to Printer</field>
<field name="type">server</field>
</record>
<record model="printing.action" id="printing_action_2">
<field name="name">Send to Client</field>
<field name="type">client</field>
</record>
<!-- properties -->
<record forcecreate="True" id="property_printing_action" model="ir.property">
<field name="name">property_printing_action</field>
<field name="fields_id" search="[('model','=','ir.actions.report.xml'),('name','=','property_printing_action')]"/>
<field name="value" eval="'printing.action,'+str(printing_action_2)"/>
</record>
</data>
</openerp>

195
base_report_to_printer/printing_view.xml Executable file → Normal file
View File

@@ -1,113 +1,114 @@
<?xml version="1.0"?>
<openerp>
<data>
<data>
<menuitem name="Printing" id="menu_printing_main" parent="base.menu_config" groups="res_groups_printingprintoperator0"/>
<menuitem name="Printing" id="menu_printing_main" icon="STOCK_PRINT" parent="base.menu_custom"/>
<menuitem name="Configuration" id="menu_printing_config" parent="menu_printing_main" />
<record model="ir.ui.view" id="view_printing_printer_form">
<field name="name">printing.printer.form</field>
<field name="model">printing.printer</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Printers">
<field name="name" select="1"/>
<field name="system_name" select="1"/>
<group col="3" colspan="2">
<field name="default" select="1"/>
<button name="set_default" string="Set Default" type="object"/>
</group>
<field name="uri" select="2"/>
<field name="model" select="2"/>
<field name="location" select="2"/>
<field name="status" select="1"/>
<field name="status_message" select="2"/>
</form>
</field>
<field name="name">printing.printer.form</field>
<field name="model">printing.printer</field>
<field name="arch" type="xml">
<form string="Printers">
<field name="name" select="1"/>
<field name="system_name" select="1"/>
<group col="3" colspan="2">
<field name="default" select="1"/>
<button name="set_default" string="Set Default" type="object"/>
</group>
<field name="uri" select="2"/>
<field name="model" select="2"/>
<field name="location" select="2"/>
<field name="status" select="1"/>
<field name="status_message" select="2"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="view_printing_printer_tree">
<field name="name">printing.printer.tree</field>
<field name="model">printing.printer</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Printers" colors="green:status=='available'; orange:status=='printing'; red:1;">
<field name="default"/>
<field name="name"/>
<field name="system_name"/>
<field name="status"/>
</tree>
</field>
<field name="name">printing.printer.tree</field>
<field name="model">printing.printer</field>
<field name="arch" type="xml">
<tree string="Printers" colors="green:status=='available'; orange:status=='printing'; red:1;">
<field name="default"/>
<field name="name"/>
<field name="system_name"/>
<field name="status"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_printing_printer_form">
<field name="name">Printers</field>
<field name="res_model">printing.printer</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="auto_refresh">20</field>
<field name="name">Show Printers</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">printing.printer</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="auto_refresh">20</field>
</record>
<menuitem name="Printers"
id="menu_printing_printer_form"
parent="menu_printing_config"
icon="STOCK_PRINT"
action="action_printing_printer_form"/>
<menuitem name="Printers"
id="menu_printing_printer_form"
parent="menu_printing_main"
action="action_printing_printer_form"/>
<record model="ir.ui.view" id="action_report_xml_form">
<field name="name">ir.actions.report.xml.printing</field>
<field name="model">ir.actions.report.xml</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.act_report_xml_view" />
<field name="arch" type="xml">
<field name="groups_id" position="before">
<field name="property_printing_action"/>
<field name="printing_printer_id"/>
<field name="printing_action_ids" colspan="4"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="action_report_xml_form">
<field name="name">ir.actions.report.xml.printing</field>
<field name="model">ir.actions.report.xml</field>
<field name="inherit_id" ref="base.act_report_xml_view" />
<field name="arch" type="xml">
<page string="Security" position="after">
<page string="Print">
<group>
<field name="property_printing_action"/>
<field name="printing_printer_id"/>
</group>
<!-- res.users -->
<record model="ir.ui.view" id="view_printing_users_form">
<field name="name">res.users.form.printing</field>
<field name="type">form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form" />
<field name="arch" type="xml">
<field name="context_tz" position="after">
<field name="printing_action" />
<field name="printing_printer_id" />
</field>
</field>
</record>
<separator string="Specific actions per user"/>
<field name="printing_action_ids"/>
</page>
</page>
</field>
</record>
<!-- printing.report.xml.action -->
<record model="ir.ui.view" id="printing_report_xml_action_form">
<field name="name">printing.report.xml.action.form</field>
<field name="model">printing.report.xml.action</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Report Printing Actions">
<field name="user_id"/>
<label string=""/>
<field name="action"/>
<field name="printer_id" select="1"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="printing_report_xml_action_tree">
<field name="name">printing.report.xml.action.tree</field>
<field name="model">printing.report.xml.action</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Report Printing Actions">
<field name="user_id"/>
<field name="action" />
<field name="printer_id" />
</tree>
</field>
</record>
</data>
<!-- res.users -->
<record model="ir.ui.view" id="view_printing_users_form">
<field name="name">res.users.form.printing</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form" />
<field name="arch" type="xml">
<field name="lang" position="after">
<group>
<field name="printing_action"/>
<field name="printing_printer_id"/>
</group>
</field>
</field>
</record>
<!-- printing.report.xml.action -->
<record model="ir.ui.view" id="printing_report_xml_action_form">
<field name="name">printing.report.xml.action.form</field>
<field name="model">printing.report.xml.action</field>
<field name="arch" type="xml">
<form string="Report Printing Actions">
<field name="user_id"/>
<label string=""/>
<field name="action"/>
<field name="printer_id" select="1"/>
</form>
</field>
</record>
<record model="ir.ui.view" id="printing_report_xml_action_tree">
<field name="name">printing.report.xml.action.tree</field>
<field name="model">printing.report.xml.action</field>
<field name="arch" type="xml">
<tree string="Report Printing Actions">
<field name="user_id"/>
<field name="action" />
<field name="printer_id" />
</tree>
</field>
</record>
</data>
</openerp>

8
base_report_to_printer/security/security.xml Executable file → Normal file
View File

@@ -31,13 +31,7 @@
<field eval="1" name="perm_create"/>
<field name="group_id" ref="res_groups_printingprintoperator0"/>
</record>
<record id="menu_printing_printer_form" model="ir.ui.menu">
<field eval="[(6,0,[ref('res_groups_printingprintoperator0')])]" name="groups_id"/>
<field eval="&quot;&quot;&quot;Printers&quot;&quot;&quot;" name="name"/>
<field eval="10" name="sequence"/>
<field name="parent_id" ref="menu_printing_config"/>
<field eval="&quot;&quot;&quot;STOCK_PRINT&quot;&quot;&quot;" name="icon"/>
</record>
</data>
<data>
<record id="ir_model_access_printingprinterall0" model="ir.model.access">

View File

@@ -20,4 +20,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import update_printers
from . import update_printers

20
base_report_to_printer/wizard/update_printers.py Executable file → Normal file
View File

@@ -21,21 +21,16 @@
#
##############################################################################
import time
import subprocess
import cups
import netsvc
from osv import fields
from osv import osv
from tools.translate import _
from openerp.osv import orm
class printing_printer_update_wizard(osv.osv_memory):
class printing_printer_update_wizard(orm.TransientModel):
_name = "printing.printer.update.wizard"
_columns = {
}
}
def action_cancel(self, cr, uid, ids, context=None):
return {}
@@ -49,9 +44,9 @@ class printing_printer_update_wizard(osv.osv_memory):
return {}
ids = self.pool.get('printing.printer').search(cr, uid, [('system_name','in',printers.keys())], context=context)
for printer in self.pool.get('printing.printer').browse(cr, uid, ids, context):
for printer in self.pool.get('printing.printer').browse(cr, uid, ids, context=context):
del printers[printer.system_name]
for name in printers:
printer = printers[name]
self.pool.get('printing.printer').create(cr, uid, {
@@ -60,7 +55,7 @@ class printing_printer_update_wizard(osv.osv_memory):
'model': printer.get('printer-make-and-model', False),
'location': printer.get('printer-location', False),
'uri': printer.get('device-uri', False),
}, context)
}, context)
return {
'name': 'Printers',
@@ -69,8 +64,7 @@ class printing_printer_update_wizard(osv.osv_memory):
'res_model': 'printing.printer',
'type': 'ir.actions.act_window',
'target': 'current',
}
}
printing_printer_update_wizard()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -1,26 +1,27 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="printer_update_wizard" model="ir.ui.view">
<field name="name">printing.printer.update.wizard</field>
<field name="model">printing.printer.update.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Update Printers from CUPS" col="2">
<label string="This process will create all missing printers from the current CUPS server." colspan="2"/>
<separator string="" colspan="2"/>
<button name="action_cancel" icon="gtk-cancel" string="Cancel" special="cancel"/>
<button name="action_ok" type="object" icon="gtk-ok" string="Ok"/>
</form>
</field>
</record>
<record id="action_printer_update_wizard" model="ir.actions.act_window">
<field name="name">Update Printers from CUPS</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">printing.printer.update.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem action="action_printer_update_wizard" id="menu_printer_update_wizard" parent="menu_printing_config"/>
</data>
<data>
<record id="printer_update_wizard" model="ir.ui.view">
<field name="name">printing.printer.update.wizard</field>
<field name="model">printing.printer.update.wizard</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Update Printers from CUPS" col="2">
<label string="This process will create all missing printers from the current CUPS server." colspan="2"/>
<separator string="" colspan="2"/>
<button name="action_cancel" icon="gtk-cancel" string="Cancel" special="cancel"/>
<button name="action_ok" type="object" icon="gtk-ok" string="Ok"/>
</form>
</field>
</record>
<record id="action_printer_update_wizard" model="ir.actions.act_window">
<field name="name">Update Printers from CUPS</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">printing.printer.update.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<menuitem action="action_printer_update_wizard" id="menu_printer_update_wizard" parent="menu_printing_main"/>
</data>
</openerp>