mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[10.0][MIG] base_report_to_printer (#68)
* Set api.multi for action called as `object` on view * Merge syleam printers module into base_report_to_printer (#60) * [IMP] Updated unit tests * [FIX] Fixed renamed attributes * [FIX] Remove deleted fields * [IMP] Add printing.server and printing.job models * [IMP] Allow to cancel all jobs, enable, and disable printers * [IMP] Split the cups part of print_document into a new print_file method * [IMP] Updated cron job to run the action_update_jobs method * [ADD] Add a migration script to create a printing server from configuration * [MIG] Migrate base_report_to_printer to v10.0 Removed deprecated methods on printing.printer (replaced by methods on printing.server) * [IMP] Add wkhtmltopdf in travis configuration file * [FIX] base_report_to_printer: Fix Update Job Cron * Fix API issue with Update Job Cron ** Forward Port from 9.0 * [FIX] Fixed the res.users view The string attribute should not be used as a selector, because it is translatable. * [FIX] Fixed the print_document method of report The new API migration was made to @api.multi because of the "cr, uid, ids" signature, but "ids" was the ids of the records to print here, not the report's ids. Also, the new API version of "get_pdf" get directly the ids of the records to print in the standard module, not a recordset. * [FIX] UI is now (un)blocked only when using qweb-pdf reports in standard addons
This commit is contained in:
committed by
John Herholz
parent
fe2015bbfd
commit
ed27efa2db
@@ -7,16 +7,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from openerp.exceptions import UserError
|
||||
from openerp import models, api, _
|
||||
|
||||
from ..models.printing_printer import CUPS_HOST, CUPS_PORT
|
||||
|
||||
try:
|
||||
import cups
|
||||
except ImportError:
|
||||
_logger = logging.getLogger(__name__)
|
||||
_logger.debug('Cannot `import cups`.')
|
||||
from odoo import models, api
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -26,40 +17,10 @@ class PrintingPrinterUpdateWizard(models.TransientModel):
|
||||
_name = 'printing.printer.update.wizard'
|
||||
_description = 'Printing Printer Update Wizard'
|
||||
|
||||
@api.model
|
||||
@api.multi
|
||||
def action_ok(self):
|
||||
# Update Printers
|
||||
printer_obj = self.env['printing.printer']
|
||||
try:
|
||||
_logger.info('Trying to get list of printers')
|
||||
connection = cups.Connection(CUPS_HOST, CUPS_PORT)
|
||||
printers = connection.getPrinters()
|
||||
_logger.info('Printers found: %s' % ','.join(printers.keys()))
|
||||
except:
|
||||
raise UserError(
|
||||
_('Could not get the list of printers from the CUPS server '
|
||||
'(%s:%s)') % (CUPS_HOST, CUPS_PORT))
|
||||
|
||||
printer_recs = printer_obj.search(
|
||||
[('system_name', 'in', printers.keys())]
|
||||
)
|
||||
for printer in printer_recs:
|
||||
del printers[printer.system_name]
|
||||
_logger.info(
|
||||
'Printer %s was already created' % printer.system_name)
|
||||
|
||||
for name, printer in printers.iteritems():
|
||||
values = {
|
||||
'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),
|
||||
}
|
||||
printer_obj.create(values)
|
||||
_logger.info(
|
||||
'Created new printer %s with URI %s'
|
||||
% (values['name'], values['uri']))
|
||||
self.env['printing.server'].search([]) \
|
||||
.update_printers(raise_on_error=True)
|
||||
|
||||
return {
|
||||
'name': 'Printers',
|
||||
|
||||
@@ -1,28 +1,26 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<odoo>
|
||||
<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="arch" type="xml">
|
||||
<form string="Update Printers from CUPS">
|
||||
<label string="This process will create all missing printers from the current CUPS server." colspan="2"/>
|
||||
<footer>
|
||||
<button name="action_ok" string="Ok" type="object" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
<field name="name">printing.printer.update.wizard</field>
|
||||
<field name="model">printing.printer.update.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Update Printers from CUPS">
|
||||
<label string="This process will create all missing printers from the current CUPS server." colspan="2"/>
|
||||
<footer>
|
||||
<button name="action_ok" string="Ok" type="object" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel"/>
|
||||
</footer>
|
||||
</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>
|
||||
<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="printing_menu"/>
|
||||
</data>
|
||||
</openerp>
|
||||
<menuitem action="action_printer_update_wizard" sequence="40" id="menu_printer_update_wizard" parent="printing_menu"/>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user