63 Commits
9.0 ... FORK

Author SHA1 Message Date
Launchpad Translations on behalf of report-print-send-core-editors
aef73d4dd1 Launchpad automatic translations update. 2014-02-26 07:32:32 +00:00
unknown
0ec8b41e09 [ADD] printer_tray
This module extends  module
It detects trays on printer installation plus permits to select
the paper source on which you want to print directly.
2014-02-25 15:45:44 +01:00
Yannick Vaucher
6741c2e040 [ADD] security file ir.model.access.csv 2014-01-31 18:01:52 +01:00
Yannick Vaucher
a4762282df [ADD] translation files 2014-01-31 16:49:33 +01:00
Yannick Vaucher
720544f7dd [MRG] Simple split of code which was in a single file 2013-12-27 13:43:25 -05:00
Yannick Vaucher
a8689ab04c [MRG] Portage of base_report_to_printer 2013-12-27 13:33:49 -05:00
Joel Grand-Guillaume
d5be5bd135 [FIX] Use explicit kwargs: context=context 2013-12-20 15:07:09 +01:00
Yannick Vaucher
525bac2f0b [IMP] adding some explanation in description 2013-12-03 12:03:26 +01:00
Yannick Vaucher
d598e4a4bf [IMP] description add comment on update printers wizard 2013-12-03 11:52:31 +01:00
Yannick Vaucher
ff97e5df66 [IMP] module desciption and remove AUTHORS.txt file to write contributors in __openerp__ 2013-12-03 11:36:39 +01:00
Yannick Vaucher
7c21dac7b3 [IMP] update po files 2013-11-05 16:33:34 +01:00
Yannick Vaucher
f10baea517 [IMP] add external_dependencies 2013-11-05 14:14:19 +01:00
Yannick Vaucher
717c8625ba [FIX] use server_error variable to update printer status 2013-10-24 15:56:02 +02:00
Yannick Vaucher
1f720317d1 [PEP8] 2013-10-24 15:36:01 +02:00
Yannick Vaucher
935c24c893 [ADD] module printer_tray 2013-10-02 17:36:14 +02:00
Yannick Vaucher
f26fb5ec40 [IMP] base_report_to_printer - split code in multiple files 2013-10-02 14:08:48 +02:00
Yannick Vaucher
426efe9ccc [IMP] base_report_to_printer - remove osv.except_osv as it breaks the workflow and doesn't permits multiple report to be sent to the printer. 2013-10-02 11:27:43 +02:00
Yannick Vaucher
2488860e7e [FIX] base_report_to_printer - restore error message as osv + propagate options 2013-10-01 16:21:37 +02:00
Yannick Vaucher
7c277dc184 [FIX] base_report_to_printer - mistake in params of print_direct 2013-10-01 16:12:50 +02:00
Yannick Vaucher
3a40419d38 [IMP] base_report_to_printer - pass report id instead of report key 2013-10-01 15:45:37 +02:00
Yannick Vaucher
94aa5b5a47 [TYPO] 2013-10-01 15:32:52 +02:00
Yannick Vaucher
13c80b7b20 [FIX] base_report_to_printer - missing class call 2013-10-01 15:30:10 +02:00
Yannick Vaucher
2c43af4705 [IMP] base_report_to_printer - remove deprecated view type 2013-10-01 15:04:19 +02:00
Yannick Vaucher
468089e5e5 [IMP] base_report_to_printer - show field name in report and user views 2013-10-01 15:02:33 +02:00
Yannick Vaucher
fbfde84671 [IMP] base_report_to_printer - retab xml files 2013-10-01 14:43:24 +02:00
Yannick Vaucher
f47542cc63 [IMP] base_report_to_printer - return browse record instead of string in behavior for printer 2013-10-01 14:19:52 +02:00
Yannick Vaucher
fa0478a2d2 [IMP] base_report_to_printer - remove uselsee context set 2013-10-01 13:29:25 +02:00
Yannick Vaucher
4f390b4777 [FIX] base_report_to_printer - using system_name of printer instead of printer browse record 2013-10-01 13:25:20 +02:00
Yannick Vaucher
d28200628e [IMP] base_report_to_printer - use an action id in an action method instead of a report id makes more sens 2013-10-01 13:24:10 +02:00
Yannick Vaucher
2e51657de9 [IMP] base_report_to_printer - add report_id on print_direct 2013-10-01 12:46:20 +02:00
Yannick Vaucher
321a355482 [IMP] base_report_to_printer - replace lpr by use of pycups 2013-09-30 17:31:48 +02:00
Yannick Vaucher
ef6f817cb7 [TYPO] 2013-09-30 14:08:51 +02:00
Yannick Vaucher
ac03496959 [IMP] base_report_to_printer - simplify calls on class 2013-09-30 13:46:04 +02:00
Yannick Vaucher
18a351349d [IMP] base_report_to_printer - remove class call 2013-09-30 13:05:10 +02:00
Yannick Vaucher
f30200c090 [IMP] base_report_to_printer - clean imports 2013-09-30 13:03:49 +02:00
Yannick Vaucher
c19ab3e0e5 [IMP] base_report_to_printer - remove class calls and use orm.Model and orm.TransientModel instead of osv aliases 2013-09-30 11:56:20 +02:00
Yannick Vaucher
890d0d64ec [IMP] base_report_to_printer - retab and clean extra spaces 2013-09-30 11:50:14 +02:00
Yannick Vaucher
96376b10e8 [FIX] base_report_to_printer - load security first 2013-09-30 11:01:09 +02:00
Andrew Schrafel
56a5655680 base_report_to_printer V7 upgrade 2013-03-14 22:30:25 -04:00
Guewen Baconnier
458972b852 [MIGR] Set the 'installable' flags to False on addons. They should be activated when their migration is done. 2013-03-14 09:47:00 +01:00
Lorenzo Battistini
6319bf17db [FIX] base_report_to_printer - 'authors' 2013-01-16 09:38:20 +01:00
Lorenzo Battistini
83aee3f29d [FIX] base_report_to_printer - 'authors' 2013-01-15 19:49:53 +01:00
gbaconnier-c2c
f3f2222e15 [FIX] pingen bug lp:1086393 2012-12-28 15:06:44 +01:00
Omar
e38d4c394c [FIX] pingen: wrong name, company_id should be company 2012-12-21 18:16:54 +01:00
Guewen Baconnier @ Camptocamp
f4c1f5b912 [FIX] pingen: convert datetimes to UTC before storing them 2012-12-10 12:14:01 +01:00
Guewen Baconnier @ Camptocamp
e85f4f882c [FIX] wrong name: company_id should be company 2012-12-10 09:18:54 +01:00
unknown
228ed983dd [FIX] base_report_to_printer description 2012-12-08 15:57:09 +01:00
Lorenzo Battistini
92af7fd6fa [FIX] base_report_to_printer description 2012-12-07 18:54:13 +01:00
unknown
8a0da307f5 [ADD] Integration of the pingen.com online service in OpenERP 2012-12-07 16:20:35 +01:00
Guewen Baconnier @ Camptocamp
782fa55b6a [MRG] from 6.1 main branch 2012-12-07 14:31:54 +01:00
Lorenzo Battistini - Agile BG - Domsense
bd8baa93d6 [MRG] add base_report_to_printer from Lorenzo Battistini - Agile BG - Domsense 2012-12-07 09:16:30 +01:00
unknown
9f333485cd [INIT] 2012-12-07 09:13:30 +01:00
Lorenzo Battistini
c98db4a9f6 [FIX] isinstance(printer, (str,unicode)):
replaced by isinstance(printer, basestring)
2012-12-06 16:09:06 +01:00
Lorenzo Battistini
819e38b62e [FIX] using logging 2012-12-06 16:01:59 +01:00
Lorenzo Battistini
244a5a3a61 [FIX] context=None 2012-12-06 15:52:32 +01:00
Lorenzo Battistini
457d20b349 [fix] get_default return value 2012-12-06 15:49:31 +01:00
Lorenzo Battistini
f94d0e30ea [FIX] print_direct return value 2012-12-06 15:48:47 +01:00
Lorenzo Battistini
56a1e71cc5 [FIX] update method is accessible from XML/RPC and should return something else than None which is forbidden 2012-12-06 15:47:51 +01:00
Lorenzo Battistini
5249f293fd [FIX] We better have to use the "with" syntax 2012-12-06 15:46:53 +01:00
Lorenzo Battistini
5ac57dfd79 [FIX] The close should be done in the finally: clause of a try: except: because if an exception occurs,
a postgresql transaction will be leaked.
The except clause should properly rollback the cr
2012-12-04 12:05:15 +01:00
Lorenzo Battistini
7abf78a872 [imp] description with images 2012-11-30 09:31:20 +01:00
Lorenzo Battistini
f60d5ed337 [IMP] base_report_to_printer - module description 2012-11-30 09:09:32 +01:00
Lorenzo Battistini
5823ff1aa4 [ADD] base_report_to_printer 2012-11-22 22:22:52 +01:00
39 changed files with 2190 additions and 42 deletions

0
README Normal file
View File

View File

@@ -0,0 +1,30 @@
# -*- 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
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import printing
from . import report_xml_action
from . import report_service
from . import users
from . import ir_report
from . import wizard

View File

@@ -0,0 +1,96 @@
# -*- 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
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': "Report to printer",
'version': '0.1',
'category': 'Generic Modules/Base',
'description': """
Report to printer
-----------------
This module allows users to send reports to a printer attached to the server.
It adds an optional behaviour on reports to send it directly to a printer.
* `Send to Client` is the default behavious providing you a downloadable PDF
* `Send to Printer` prints the report on selected printer
Report behaviour is defined by settings.
Settings can be configured:
* globaly
* per user
* per report
* per user and report
After installing enable the "Printing / Print Operator" option under access
rights to give users the ability to view the print menu.
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'],
'data': [
'security/security.xml',
'printing_data.xml',
'printing_view.xml',
'wizard/update_printers.xml',
],
'installable': True,
'auto_install': False,
'application': True,
'external_dependencies': {
'python': ['cups']
}
}

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 ""
#. 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 ""
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Unknown"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,system_name:0
msgid "System Name"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,location:0
msgid "Location"
msgstr ""
#. 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 ""
#. 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
#: field:printing.action,type:0
msgid "Type"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,model:0
msgid "Model"
msgstr ""
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Available"
msgstr ""
#. 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 ""
#. 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"
msgstr ""
#. module: base_report_to_printer
#: field:printing.report.xml.action,user_id:0
msgid "User"
msgstr ""
#. module: base_report_to_printer
#: field:printing.report.xml.action,report_id:0
msgid "Report"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,status:0
msgid "Status"
msgstr ""
#. module: base_report_to_printer
#: 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
msgid "Ok"
msgstr ""
#. module: base_report_to_printer
#: field:printing.action,name:0
#: field:printing.printer,name:0
msgid "Name"
msgstr ""
#. module: base_report_to_printer
#: view:printing.printer:0
msgid "Set Default"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,default:0
#: field:res.users,printing_printer_id:0
msgid "Default Printer"
msgstr ""
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:186
#, python-format
msgid "Send to Client"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,uri:0
msgid "URI"
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
#: view:printing.printer.update.wizard:0
msgid "Update Printers from CUPS"
msgstr ""
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:185
#, python-format
msgid "Send to Printer"
msgstr ""
#. 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 ""
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Error"
msgstr ""
#. module: base_report_to_printer
#: field:ir.actions.report.xml,property_printing_action:0
#: field:printing.report.xml.action,action:0
msgid "Action"
msgstr ""
#. module: base_report_to_printer
#: view:ir.actions.report.xml:0
msgid "Security"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,status_message:0
msgid "Status Message"
msgstr ""
#. 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 ""
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Server Error"
msgstr ""
#. module: base_report_to_printer
#: field:ir.actions.report.xml,printing_action_ids:0
msgid "Actions"
msgstr ""
#. module: base_report_to_printer
#: view:printing.printer.update.wizard:0
msgid "Cancel"
msgstr ""
#. 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 ""

View File

@@ -0,0 +1,230 @@
# 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: 2014-02-25 15:06+0000\n"
"Last-Translator: Yannick Vaucher @ Camptocamp <Unknown>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-02-26 07:32+0000\n"
"X-Generator: Launchpad (build 16935)\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.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 "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:189
#, 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:188
#, 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:190
#, python-format
msgid "Use user's defaults"
msgstr "Utiliser la configuration par défaut de l'utilisateur"

View File

@@ -0,0 +1,230 @@
# 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: 2014-02-25 15:09+0000\n"
"Last-Translator: Yannick Vaucher @ Camptocamp <Unknown>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-02-26 07:32+0000\n"
"X-Generator: Launchpad (build 16935)\n"
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Unavailable"
msgstr "Non disponibile"
#. 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 ""
"Questo processo creerà tutte le stampante mancanti dal server CUPS corrente"
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Unknown"
msgstr "Sconosciuto"
#. module: base_report_to_printer
#: field:printing.printer,system_name:0
msgid "System Name"
msgstr "Nome di sistema"
#. 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
#: 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"
msgstr "Disponibile"
#. 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 "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"
#. 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"
#. module: base_report_to_printer
#: field:printing.report.xml.action,user_id:0
msgid "User"
msgstr "Utente"
#. module: base_report_to_printer
#: field:printing.report.xml.action,report_id:0
msgid "Report"
msgstr "Report"
#. module: base_report_to_printer
#: field:printing.printer,status:0
msgid "Status"
msgstr "Stato"
#. module: base_report_to_printer
#: 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
msgid "Ok"
msgstr "Ok"
#. module: base_report_to_printer
#: field:printing.action,name:0
#: field:printing.printer,name:0
msgid "Name"
msgstr "Nome"
#. module: base_report_to_printer
#: view:printing.printer:0
msgid "Set Default"
msgstr "Imposta default"
#. module: base_report_to_printer
#: field:printing.printer,default:0
#: field:res.users,printing_printer_id:0
msgid "Default Printer"
msgstr "Stampante di default"
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:189
#, python-format
msgid "Send to Client"
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.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 "Aggiorna stampanti da CUPS"
#. module: base_report_to_printer
#: code:addons/base_report_to_printer/printing.py:188
#, python-format
msgid "Send to Printer"
msgstr "Invia alla stampante"
#. 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 "Stampa"
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Error"
msgstr "Errore"
#. module: base_report_to_printer
#: field:ir.actions.report.xml,property_printing_action:0
#: field:printing.report.xml.action,action:0
msgid "Action"
msgstr "Azione"
#. module: base_report_to_printer
#: view:ir.actions.report.xml:0
msgid "Security"
msgstr ""
#. module: base_report_to_printer
#: field:printing.printer,status_message:0
msgid "Status Message"
msgstr "Messaggio di stato"
#. 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 ""
"Questo campo permette di configurare azioni e stampanti sulla base degli "
"utenti"
#. module: base_report_to_printer
#: selection:printing.printer,status:0
msgid "Server Error"
msgstr "Errore server"
#. module: base_report_to_printer
#: field:ir.actions.report.xml,printing_action_ids:0
msgid "Actions"
msgstr "Azioni"
#. module: base_report_to_printer
#: view:printing.printer.update.wizard:0
msgid "Cancel"
msgstr "Annulla"
#. 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:190
#, python-format
msgid "Use user's defaults"
msgstr "Utilizza i default dell'utente"

View File

@@ -0,0 +1,130 @@
# -*- 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
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import os
import base64
from tempfile import mkstemp
import logging
import cups
from openerp.osv import orm, fields
#
# Reports
#
class report_xml(orm.Model):
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))
finally:
os.close(fd)
printer_system_name = ''
if printer:
if isinstance(printer, (basestring)):
printer_system_name = printer
else:
printer_system_name = printer.system_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'" % file_name)
return True
_inherit = 'ir.actions.report.xml'
_columns = {
'property_printing_action': fields.property(
#'ir.actions.report.xml',
'printing.action',
type='many2one',
relation='printing.action',
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):
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 = printer_obj.get_default(cr, uid, context=context)
if default_printer:
default_printer = printer_obj.browse(cr, uid, default_printer, context=context)
# Retrieve user default values
user = self.pool.get('res.users').browse(cr, uid, context)
if user.printing_action:
default_action = user.printing_action
if user.printing_printer_id:
default_printer = user.printing_printer_id
for report in self.browse(cr, uid, ids, context):
action = default_action
printer = default_printer
# Retrieve report default values
if report.property_printing_action and report.property_printing_action.type != 'user_default':
action = report.property_printing_action.type
if report.printing_printer_id:
printer = report.printing_printer_id
# Retrieve report-user specific values
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)
action = user_action['action']
if user_action['printer']:
printer = user_action['printer']
result[report.id] = {
'action': action,
'printer': printer,
}
return result

View File

@@ -0,0 +1,199 @@
# -*- 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
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import time
import base64
import cups
from threading import Thread
from threading import Lock
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(orm.Model):
_name = "printing.printer"
_description = "Printer"
_columns = {
'name' : fields.char('Name',size=64,required=True,select="1"),
'system_name': fields.char('System Name',size=64,required=True,select="1"),
'default':fields.boolean('Default Printer',required=True,readonly=True),
'status': fields.selection([('unavailable','Unavailable'),('printing','Printing'),('unknown','Unknown'),('available','Available'),('error','Error'),('server-error','Server Error')], 'Status', required=True, readonly=True),
'status_message': fields.char('Status Message', size=500, readonly=True),
'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)
self.lock = Lock()
self.last_update = None
self.updating = False
def update_printers_status(self, db_name, uid, context=None):
db, pool = pooler.get_db_and_pool(db_name)
cr = db.cursor()
try:
connection = cups.Connection()
printers = connection.getPrinters()
server_error = False
except:
server_error = True
mapping = {
3 : 'available',
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.search(cr, uid, [], context=ctx)
for printer in self.browse(cr, uid, ids, context=ctx):
vals = {}
if server_error:
status = 'server-error'
elif printer.system_name in printers:
info = printers[printer.system_name]
status = mapping.get( info['printer-state'], 'unknown' )
vals = {
'model': info.get('printer-make-and-model', False),
'location': info.get('printer-location', False),
'uri': info.get('device-uri', False),
}
else:
status = 'unavailable'
vals['status'] = status
self.write(cr, uid, [printer.id], vals, context=context)
cr.commit()
except:
cr.rollback()
raise
finally:
cr.close()
with self.lock:
self.updating = False
self.last_update = time.time()
def start_printer_update(self, cr, uid, context):
self.lock.acquire()
if self.updating:
self.lock.release()
return
self.updating = True
self.lock.release()
thread = Thread(target=self.update_printers_status, args=(cr.dbname, uid, context.copy()))
thread.start()
def update(self, cr, uid, context=None):
if not context or context.get('skip_update'):
return
self.lock.acquire()
last_update = self.last_update
updating = self.updating
self.lock.release()
now = time.time()
# Only update printer status if current status is more than 10 seconds old.
if not last_update or now - last_update > 10:
self.start_printer_update(cr, uid, context)
# Wait up to five seconds for printer status update
for x in range(0,5):
time.sleep(1)
self.lock.acquire()
updating = self.updating
self.lock.release()
if not updating:
break
return True
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
self.update(cr, uid, context)
return super(printing_printer,self).search(cr, uid, args, offset, limit, order, context, count)
def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'):
self.update(cr, uid, context)
return super(printing_printer,self).read(cr, uid, ids, fields, context, load)
def browse(self, cr, uid, ids, context=None):
self.update(cr, uid, context)
return super(printing_printer,self).browse(cr, uid, ids, context)
def set_default(self, cr, uid, ids, context):
if not ids:
return
default_ids= self.search(cr, uid,[('default','=',True)])
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
#
# Actions
#
def _available_action_types(self, cr, uid, context=None):
return [
('server',_('Send to Printer')),
('client',_('Send to Client')),
('user_default',_("Use user's defaults")),
]
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),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -0,0 +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>
</openerp>

View File

@@ -0,0 +1,114 @@
<?xml version="1.0"?>
<openerp>
<data>
<menuitem name="Printing" id="menu_printing_main" parent="base.menu_config" groups="res_groups_printingprintoperator0"/>
<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="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="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">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_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="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>
<separator string="Specific actions per user"/>
<field name="printing_action_ids"/>
</page>
</page>
</field>
</record>
<!-- 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>

View File

@@ -0,0 +1,72 @@
# -*- 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
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import base64
from openerp import pooler
from openerp.addons.base_calendar import base_calendar
class virtual_report_spool(base_calendar.virtual_report_spool):
def exp_report(self, db, uid, object, ids, datas=None, context=None):
res = super(virtual_report_spool, self).exp_report(db, uid, object, ids, datas, context)
self._reports[res]['report_name'] = object
return res
def exp_report_get(self, db, uid, report_id):
cr = pooler.get_db(db).cursor()
try:
pool = pooler.get_pool(cr.dbname)
# First of all load report defaults: name, action and printer
report_obj = pool.get('ir.actions.report.xml')
report = report_obj.search(cr,uid,[('report_name','=',self._reports[report_id]['report_name'])])
if report:
report = report_obj.browse(cr,uid,report[0])
name = report.name
data = report.behaviour()[report.id]
action = data['action']
printer = data['printer']
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, 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
finally:
cr.close()
res = super(virtual_report_spool, self).exp_report_get(db, uid, report_id)
return res
virtual_report_spool()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -0,0 +1,50 @@
# -*- 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
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
from printing import _available_action_types
class report_xml_action(orm.Model):
_name = 'printing.report.xml.action'
_description = 'Report Printing Actions'
_columns = {
'report_id': fields.many2one('ir.actions.report.xml', 'Report', required=True, ondelete='cascade'),
'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, act_id, context=None):
result = {}
if not act_id:
return False
action = self.browse(cr, uid, act_id, context=context)
return {
'action': action.action,
'printer': action.printer_id,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" ?>
<openerp>
<data noupdate="1">
<record id="res_groups_printingprintoperator0" model="res.groups">
<field eval="&quot;&quot;&quot;Printing / Print Operator&quot;&quot;&quot;" name="name"/>
</record>
<record id="ir_model_access_printingprintergroup1" model="ir.model.access">
<field name="model_id" ref="model_printing_printer"/>
<field eval="1" name="perm_read"/>
<field eval="&quot;&quot;&quot;printing_printer group&quot;&quot;&quot;" name="name"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_create"/>
<field name="group_id" ref="res_groups_printingprintoperator0"/>
</record>
<record id="ir_model_access_printing_action" model="ir.model.access">
<field name="model_id" ref="model_printing_action"/>
<field eval="1" name="perm_read"/>
<field eval="&quot;&quot;&quot;printing_printer group&quot;&quot;&quot;" name="name"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_create"/>
<field name="group_id" ref="res_groups_printingprintoperator0"/>
</record>
<record id="ir_model_access_printingreportxmlaction" model="ir.model.access">
<field name="model_id" ref="model_printing_report_xml_action"/>
<field eval="1" name="perm_read"/>
<field eval="&quot;&quot;&quot;printing_printer group&quot;&quot;&quot;" name="name"/>
<field eval="1" name="perm_unlink"/>
<field eval="1" name="perm_write"/>
<field eval="1" name="perm_create"/>
<field name="group_id" ref="res_groups_printingprintoperator0"/>
</record>
</data>
<data>
<record id="ir_model_access_printingprinterall0" model="ir.model.access">
<field name="model_id" ref="model_printing_printer"/>
<field eval="1" name="perm_read"/>
<field eval="&quot;&quot;&quot;printing_printer all&quot;&quot;&quot;" name="name"/>
<field eval="0" name="perm_unlink"/>
<field eval="0" name="perm_write"/>
<field eval="0" name="perm_create"/>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,46 @@
# -*- 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
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
from printing import _available_action_types
#
# Users
#
class res_users(orm.Model):
_name = "res.users"
_inherit = "res.users"
def _user_available_action_types(self, cr, uid, context=None):
if context is None:
context={}
return [x for x in _available_action_types(self, cr, uid, context) if x[0] != 'user_default']
_columns = {
'printing_action': fields.selection(_user_available_action_types, 'Printing Action'),
'printing_printer_id': fields.many2one('printing.printer', 'Default Printer'),
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# 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>)
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import update_printers

View File

@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# 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>)
# All Rights Reserved
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import cups
from openerp.osv import orm
class printing_printer_update_wizard(orm.TransientModel):
_name = "printing.printer.update.wizard"
_columns = {
}
def action_cancel(self, cr, uid, ids, context=None):
return {}
def action_ok(self, cr, uid, ids, context=None):
# Update Printers
try:
connection = cups.Connection()
printers = connection.getPrinters()
except:
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=context):
del printers[printer.system_name]
for name in printers:
printer = printers[name]
self.pool.get('printing.printer').create(cr, uid, {
'name': printer['printer-info'],
'system_name': name,
'model': printer.get('printer-make-and-model', False),
'location': printer.get('printer-location', False),
'uri': printer.get('device-uri', False),
}, context)
return {
'name': 'Printers',
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'printing.printer',
'type': 'ir.actions.act_window',
'target': 'current',
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -0,0 +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_main"/>
</data>
</openerp>

View File

@@ -113,7 +113,7 @@ Dependencies
'security/ir.model.access.csv',
],
'tests': [],
'installable': True,
'installable': False,
'auto_install': False,
'application': True,
}

View File

@@ -6,14 +6,15 @@ msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-11-26 10:54+0000\n"
"PO-Revision-Date: 2012-11-26 10:54+0000\n"
"Last-Translator: <>\n"
"POT-Creation-Date: 2012-11-26 10:55+0000\n"
"PO-Revision-Date: 2014-02-25 15:09+0000\n"
"Last-Translator: Yannick Vaucher @ Camptocamp <Unknown>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-02-26 07:32+0000\n"
"X-Generator: Launchpad (build 16935)\n"
#. module: pingen
#: code:addons/pingen/pingen_document.py:177
@@ -52,7 +53,9 @@ msgstr "Envoyer"
#: code:addons/pingen/pingen_document.py:399
#, python-format
msgid "Connection Error when updating the status of Document %s from Pingen"
msgstr "Erreur de connexion lors de la mise à jour de l'état du document %s depuis Pingen"
msgstr ""
"Erreur de connexion lors de la mise à jour de l'état du document %s depuis "
"Pingen"
#. module: pingen
#: field:pingen.document,state:0
@@ -72,9 +75,11 @@ msgstr "Attachement"
#. module: pingen
#: code:addons/pingen/pingen_document.py:405
#, python-format
msgid "Error when updating the status of Document %s from Pingen: \n"
msgid ""
"Error when updating the status of Document %s from Pingen: \n"
"%s"
msgstr "Erreur lors de la mise à jour de l'état du document %s depuis Pingen: \n"
msgstr ""
"Erreur lors de la mise à jour de l'état du document %s depuis Pingen: \n"
"%s"
#. module: pingen
@@ -119,9 +124,11 @@ msgstr "Uniquement un document Pingen est autorisé par attachement."
#: code:addons/pingen/pingen_document.py:168
#: code:addons/pingen/pingen_document.py:298
#, python-format
msgid "Error when asking Pingen to send the document %s: \n"
msgid ""
"Error when asking Pingen to send the document %s: \n"
"%s"
msgstr "Erreurs lors de l'envoi du document par Pingen %s: \n"
msgstr ""
"Erreurs lors de l'envoi du document par Pingen %s: \n"
"%s"
#. module: pingen
@@ -277,7 +284,7 @@ msgstr "L'attachement %s est déjà envoyé sur pingen.com."
#. module: pingen
#: view:pingen.document:0
msgid "Attached To"
msgstr "Attaché à "
msgstr "Attaché à"
#. module: pingen
#: code:addons/pingen/pingen_document.py:136
@@ -387,4 +394,3 @@ msgstr "ID de lettre Pingen"
#: help:ir.attachment,pingen_speed:0
msgid "Defines the sending speed if the document is automatically sent"
msgstr "Définit la vitesse d'envoi si le document est automatiquement envoyé"

View File

@@ -23,7 +23,9 @@ import requests
import logging
import urlparse
import json
import pytz
from datetime import datetime
from requests.packages.urllib3.filepost import encode_multipart_formdata
_logger = logging.getLogger(__name__)
@@ -37,6 +39,23 @@ POST_SENDING_STATUS = {
400: 'Sending cancelled',
}
DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S' # this is the format used by pingen API
TZ = pytz.timezone('Europe/Zurich') # this is the timezone of the pingen API
def pingen_datetime_to_utc(dt):
""" Convert a date/time used by pingen.com to UTC timezone
:param dt: pingen date/time as string (as received from the API)
to convert to UTC
:return: datetime in the UTC timezone
"""
utc = pytz.utc
dt = datetime.strptime(dt, DATETIME_FORMAT)
localized_dt = TZ.localize(dt, is_dst=True)
return localized_dt.astimezone(utc)
class PingenException(RuntimeError):
"""There was an ambiguous exception that occurred while handling your

View File

@@ -26,8 +26,9 @@ from cStringIO import StringIO
from contextlib import closing
from openerp.osv import osv, orm, fields
from openerp.tools.translate import _
from openerp import pooler
from .pingen import APIError, ConnectionError, POST_SENDING_STATUS
from openerp import pooler, tools
from .pingen import APIError, ConnectionError, POST_SENDING_STATUS, \
pingen_datetime_to_utc
_logger = logging.getLogger(__name__)
@@ -135,10 +136,12 @@ class pingen_document(orm.Model):
state = 'pingen_error'
error = _('The document does not meet the Pingen requirements.')
push_date = pingen_datetime_to_utc(infos['date'])
document.write(
{'last_error_message': error,
'state': state,
'push_date': infos['date'],
'push_date': push_date.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT),
'pingen_id': doc_id,
'post_id': post_id},
context=context)
@@ -336,13 +339,16 @@ class pingen_document(orm.Model):
cr, uid, [('name', '=', post_infos['currency'])], context=context)
country_ids = self.pool.get('res.country').search(
cr, uid, [('code', '=', post_infos['country'])], context=context)
send_date = pingen_datetime_to_utc(infos['date'])
vals = {
'post_status': POST_SENDING_STATUS[post_infos['status']],
'cost': post_infos['cost'],
'currency_id': currency_ids[0] if currency_ids else False,
'parsed_address': post_infos['address'],
'country_id': country_ids[0] if country_ids else False,
'send_date': post_infos['date'],
'send_date': send_date.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT),
'pages': post_infos['pages'],
'last_error_message': False,
}

View File

@@ -37,6 +37,6 @@ class res_company(orm.Model):
assert isinstance(company, (int, long, browse_record)), \
"one id or browse_record expected"
if not isinstance(company, browse_record):
company = self.browse(cr, uid, company_id, context=context)
company = self.browse(cr, uid, company, context=context)
return Pingen(company.pingen_token, staging=company.pingen_staging)

View File

@@ -36,6 +36,6 @@ Glue module between the `pingen` and the `document` modules.
'pingen_document_view.xml',
],
'tests': [],
'installable': True,
'installable': False,
'auto_install': True,
}

View File

@@ -6,14 +6,15 @@ msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-11-26 10:54+0000\n"
"PO-Revision-Date: 2012-11-26 10:54+0000\n"
"Last-Translator: <>\n"
"POT-Creation-Date: 2012-11-26 10:56+0000\n"
"PO-Revision-Date: 2014-02-25 15:09+0000\n"
"Last-Translator: Yannick Vaucher @ Camptocamp <Unknown>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-02-26 07:32+0000\n"
"X-Generator: Launchpad (build 16935)\n"
#. module: pingen_document
#: view:ir.attachment:0
@@ -29,4 +30,3 @@ msgstr "Pingen Documents"
#: view:ir.attachment:0
msgid "Pingen.com"
msgstr "Pingen.com"

View File

@@ -6,14 +6,15 @@ msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-11-26 10:54+0000\n"
"PO-Revision-Date: 2012-11-26 10:54+0000\n"
"Last-Translator: <>\n"
"POT-Creation-Date: 2012-11-26 10:56+0000\n"
"PO-Revision-Date: 2014-02-25 15:09+0000\n"
"Last-Translator: Yannick Vaucher @ Camptocamp <Unknown>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-02-26 07:32+0000\n"
"X-Generator: Launchpad (build 16935)\n"
#. module: pingen_document
#: view:ir.attachment:0
@@ -29,4 +30,3 @@ msgstr "Pingen Documents"
#: view:ir.attachment:0
msgid "Pingen.com"
msgstr "Pingen.com"

View File

@@ -6,14 +6,15 @@ msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-11-26 10:54+0000\n"
"PO-Revision-Date: 2012-11-26 10:54+0000\n"
"Last-Translator: <>\n"
"POT-Creation-Date: 2012-11-26 10:56+0000\n"
"PO-Revision-Date: 2014-02-25 15:06+0000\n"
"Last-Translator: Yannick Vaucher @ Camptocamp <Unknown>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-02-26 07:32+0000\n"
"X-Generator: Launchpad (build 16935)\n"
#. module: pingen_document
#: view:ir.attachment:0
@@ -29,4 +30,3 @@ msgstr "Pingen Documents"
#: view:ir.attachment:0
msgid "Pingen.com"
msgstr "Pingen.com"

View File

@@ -7,13 +7,14 @@ msgstr ""
"Project-Id-Version: OpenERP Server 6.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-11-26 10:56+0000\n"
"PO-Revision-Date: 2012-11-26 10:56+0000\n"
"Last-Translator: <>\n"
"PO-Revision-Date: 2014-02-25 15:06+0000\n"
"Last-Translator: Yannick Vaucher @ Camptocamp <Unknown>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2014-02-26 07:32+0000\n"
"X-Generator: Launchpad (build 16935)\n"
#. module: pingen_document
#: view:ir.attachment:0
@@ -29,4 +30,3 @@ msgstr "Documents Pingen"
#: view:ir.attachment:0
msgid "Pingen.com"
msgstr "Pingen.com"

24
printer_tray/__init__.py Normal file
View File

@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2013 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import ir_report
from . import printer_tray
from . import printer
from . import users

View File

@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2013 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{'name': 'Report to printer - Paper tray selection',
'version': '1.0',
'category': 'Printer',
'description': """
Report to printer - Paper tray selection
========================================
**Author:** Camptocamp SA
*This module extends `Report to printer` module.*
It detects trays on printer installation plus permits to select
the paper source on which you want to print directly.
You will find this option on default user config, on default report config
and on specific config per user per report.
This allows you to dedicate a specific paper source for exemple for prepinted
paper such as payment slip.
""",
'author': 'Camptocamp',
'maintainer': 'Camptocamp',
'website': 'http://www.camptocamp.com/',
'depends': ['base_report_assembler',
'base_report_to_printer',
],
'data': [
'users_view.xml',
'ir_report_view.xml',
],
'test': [],
'installable': True,
'auto_install': False,
'application': True,
}

63
printer_tray/i18n/fr.po Normal file
View File

@@ -0,0 +1,63 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * printer_tray
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-01-31 15:44+0000\n"
"PO-Revision-Date: 2014-01-31 16:48+0100\n"
"Last-Translator: Yannick Vaucher <yannick.vaucher@camptocamp.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_printing_tray
msgid "Printer Tray"
msgstr "Bac d'impression"
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_printing_printer
#: field:printing.tray,printer_id:0
msgid "Printer"
msgstr "Imprimante"
#. module: printer_tray
#: field:res.users,printer_tray_id:0
msgid "Default Printer Paper Source"
msgstr "Source de papier par défaut"
#. module: printer_tray
#: field:printing.tray,name:0
msgid "Name"
msgstr "Nom"
#. module: printer_tray
#: field:printing.tray,system_name:0
msgid "System Name"
msgstr "Nom système"
#. module: printer_tray
#: field:printing.printer,tray_ids:0
msgid "Paper Sources"
msgstr "Sources de papier"
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_res_users
msgid "Users"
msgstr "Utilisateur"
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_ir_actions_report_xml
msgid "ir.actions.report.xml"
msgstr ""
#. module: printer_tray
#: field:ir.actions.report.xml,printer_tray_id:0
msgid "Paper Source"
msgstr "Source de papier"

View File

@@ -0,0 +1,63 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * printer_tray
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-01-31 15:44+0000\n"
"PO-Revision-Date: 2014-01-31 16:48+0100\n"
"Last-Translator: Yannick Vaucher <yannick.vaucher@camptocamp.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_printing_tray
msgid "Printer Tray"
msgstr ""
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_printing_printer
#: field:printing.tray,printer_id:0
msgid "Printer"
msgstr ""
#. module: printer_tray
#: field:res.users,printer_tray_id:0
msgid "Default Printer Paper Source"
msgstr ""
#. module: printer_tray
#: field:printing.tray,name:0
msgid "Name"
msgstr ""
#. module: printer_tray
#: field:printing.tray,system_name:0
msgid "System Name"
msgstr ""
#. module: printer_tray
#: field:printing.printer,tray_ids:0
msgid "Paper Sources"
msgstr ""
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_res_users
msgid "Users"
msgstr ""
#. module: printer_tray
#: model:ir.model,name:printer_tray.model_ir_actions_report_xml
msgid "ir.actions.report.xml"
msgstr ""
#. module: printer_tray
#: field:ir.actions.report.xml,printer_tray_id:0
msgid "Paper Source"
msgstr ""

63
printer_tray/ir_report.py Normal file
View File

@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2013 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
class ReportXML(orm.Model):
_inherit = 'ir.actions.report.xml'
_columns = {
'printer_tray_id': fields.many2one(
'printing.tray', 'Paper Source',
domain="[('printer_id', '=', printing_printer_id)]"),
}
def set_print_options(self, cr, uid, report_id, format, context=None):
"""
Hook to define Tray
"""
printing_act_obj = self.pool.get('printing.report.xml.action')
options = super(ReportXML, self).set_print_options(cr, uid, report_id, format, context=context)
# Retrieve user default values
user = self.pool.get('res.users').browse(cr, uid, context)
tray = user.printer_tray_id
report = self.browse(cr, uid, report_id, context=context)
# Retrieve report default values
if report.printer_tray_id:
tray = report.printer_tray_id
# Retrieve report-user specific values
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.browse(cr, uid, act_ids[0], context=context)
if user_action.tray_id:
tray = user_action.tray_id
if tray:
options['InputSlot'] = str(tray.system_name)
return options

View File

@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- ir.report form view -->
<record model="ir.ui.view" id="action_report_xml_form">
<field name="name">ir.actions.report.xml.add.printer.tray</field>
<field name="model">ir.actions.report.xml</field>
<field name="inherit_id" ref="base_report_to_printer.action_report_xml_form" />
<field name="arch" type="xml">
<field name="printing_printer_id" position="after">
<field name="printer_tray_id"/>
</field>
</field>
</record>
</data>
</openerp>

99
printer_tray/printer.py Normal file
View File

@@ -0,0 +1,99 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2013 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import cups
from cups import PPD
from openerp import pooler
from openerp.osv import orm, fields
class Printer(orm.Model):
_inherit = 'printing.printer'
_columns = {
'tray_ids': fields.one2many('printing.tray', 'printer_id', 'Paper Sources'),
}
def _update_tray_option(self, db_name, uid, printer, context=None):
"""
Create missing tray for a printer
"""
db, pool = pooler.get_db_and_pool(db_name)
cr = db.cursor()
tray_obj = pool.get('printing.tray')
# get printers options from a PPD file
try:
connection = cups.Connection()
ppd_file_path = connection.getPPD3(printer.system_name)
except:
return
if not ppd_file_path[2]:
return
ppd = PPD(ppd_file_path[2])
option = ppd.findOption('InputSlot')
if not option:
return
try:
for tray_opt in option.choices:
if tray_opt['choice'] not in [t.system_name for t in printer.tray_ids]:
tray_vals = {
'name': tray_opt['text'],
'system_name': tray_opt['choice'],
'printer_id': printer.id,
}
tray_obj.create(cr, uid, tray_vals, context=context)
cr.commit()
except:
cr.rollback()
raise
finally:
cr.close()
return True
def update_printers_status(self, db_name, uid, context=None):
"""
Add creation of tray if no tray are defined
"""
db, pool = pooler.get_db_and_pool(db_name)
cr = db.cursor()
res = super(Printer, self).update_printers_status(db_name, uid, context=context)
try:
connection = cups.Connection()
printers = connection.getPrinters()
server_error = False
except:
server_error = True
printer_ids = self.search(cr, uid, [('system_name', 'in', printers.keys())], context=context)
if server_error:
vals = {'status': 'server_error'}
self.write(cr, uid, printer_ids, vals, context=context)
return res
printer_list = self.browse(cr, uid, printer_ids, context=context)
for printer in printer_list:
# XXX we consider config of printer won't change
if not printer.tray_ids:
self._update_tray_option(db_name, uid, printer, context=context)
return res

View File

@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2013 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
class PrinterTray(orm.Model):
_name = 'printing.tray'
_description = 'Printer Tray'
_columns = {
'name': fields.char('Name', size=64, required=True),
'system_name': fields.char('System Name', size=64, required=True),
'printer_id': fields.many2one('printing.printer', 'Printer', required=True),
}

View File

@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2013 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
class ReportXMLAction(orm.Model):
_inherit = 'printing.report.xml.action'
_columns = {
'printer_tray_id': fields.many2one(
'printing.tray', 'Paper Source',
domain="[('printer_id', '=', printer_id)]"),
}
def behaviour(self, cr, uid, act_id, context=None):
res = super(ReportXMLAction, self).behaviour(cr, uid, act_id, context=context)
action = self.browse(cr, uid, act_id, context=context)
res['tray'] = action.printer_tray_id.system_name
return res

View File

@@ -0,0 +1,3 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
access_printing_tray_all,printing_tray all,model_printing_tray,,1,0,0,0
access_printing_tray_operator,printing_tray operator,model_printing_tray,base_report_to_printer.res_groups_printingprintoperator0,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_printing_tray_all printing_tray all model_printing_tray 1 0 0 0
3 access_printing_tray_operator printing_tray operator model_printing_tray base_report_to_printer.res_groups_printingprintoperator0 1 1 1 1

32
printer_tray/users.py Normal file
View File

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Yannick Vaucher
# Copyright 2013 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
class ResUsers(orm.Model):
_inherit = "res.users"
_columns = {
'printer_tray_id': fields.many2one(
'printing.tray', 'Default Printer Paper Source',
domain="[('printer_id', '=', printing_printer_id)]"),
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- res.users form view -->
<record model="ir.ui.view" id="view_users_form">
<field name="name">res.users.form.add.printer.tray</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base_report_to_printer.view_printing_users_form" />
<field name="arch" type="xml">
<field name="printing_printer_id" position="after">
<field name="printer_tray_id"/>
</field>
</field>
</record>
</data>
</openerp>