mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[MIG] base_report_to_printer: Migration to 13.0
This commit is contained in:
committed by
Carlos Roca
parent
32352977ed
commit
b1103c7b6d
@@ -54,7 +54,6 @@ class IrActionsReport(models.Model):
|
||||
}
|
||||
return serializable_result
|
||||
|
||||
@api.multi
|
||||
def _get_user_default_print_behaviour(self):
|
||||
printer_obj = self.env['printing.printer']
|
||||
user = self.env.user
|
||||
@@ -65,7 +64,6 @@ class IrActionsReport(models.Model):
|
||||
user.printer_tray_id else False
|
||||
)
|
||||
|
||||
@api.multi
|
||||
def _get_report_default_print_behaviour(self):
|
||||
result = {}
|
||||
report_action = self.property_printing_action_id
|
||||
@@ -77,7 +75,6 @@ class IrActionsReport(models.Model):
|
||||
result['tray'] = self.printer_tray_id.system_name
|
||||
return result
|
||||
|
||||
@api.multi
|
||||
def behaviour(self):
|
||||
self.ensure_one()
|
||||
printing_act_obj = self.env['printing.report.xml.action']
|
||||
@@ -98,7 +95,6 @@ class IrActionsReport(models.Model):
|
||||
print_action.behaviour().items() if v})
|
||||
return result
|
||||
|
||||
@api.multi
|
||||
def print_document(self, record_ids, data=None):
|
||||
""" Print a document, do not return the document file """
|
||||
document, doc_format = self.with_context(
|
||||
@@ -116,7 +112,6 @@ class IrActionsReport(models.Model):
|
||||
doc_format=self.report_type,
|
||||
**behaviour)
|
||||
|
||||
@api.multi
|
||||
def _can_print_report(self, behaviour, printer, document):
|
||||
"""Predicate that decide if report can be sent to printer
|
||||
|
||||
@@ -129,7 +124,6 @@ class IrActionsReport(models.Model):
|
||||
return True
|
||||
return False
|
||||
|
||||
@api.noguess
|
||||
def report_action(self, docids, data=None, config=True):
|
||||
res = super().report_action(docids, data=data, config=config)
|
||||
if not res.get('id'):
|
||||
|
||||
@@ -25,5 +25,4 @@ class PrintingAction(models.Model):
|
||||
selection=_available_action_types,
|
||||
string='Type',
|
||||
required=True,
|
||||
oldname='type'
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import logging
|
||||
from odoo import models, fields, api
|
||||
from odoo import models, fields
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -85,12 +85,10 @@ class PrintingJob(models.Model):
|
||||
'The id of the job must be unique per server !'),
|
||||
]
|
||||
|
||||
@api.multi
|
||||
def action_cancel(self):
|
||||
self.ensure_one()
|
||||
return self.cancel()
|
||||
|
||||
@api.multi
|
||||
def cancel(self, purge_job=False):
|
||||
for job in self:
|
||||
connection = job.server_id._open_connection()
|
||||
|
||||
@@ -11,7 +11,7 @@ import logging
|
||||
import os
|
||||
from tempfile import mkstemp
|
||||
|
||||
from odoo import models, fields, api
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
@@ -60,7 +60,6 @@ class PrintingPrinter(models.Model):
|
||||
inverse_name='printer_id',
|
||||
string='Paper Sources')
|
||||
|
||||
@api.multi
|
||||
def _prepare_update_from_cups(self, cups_connection, cups_printer):
|
||||
mapping = {
|
||||
3: 'available',
|
||||
@@ -116,7 +115,6 @@ class PrintingPrinter(models.Model):
|
||||
])
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
def print_document(self, report, content, **print_opts):
|
||||
""" Print a file
|
||||
Format could be pdf, qweb-pdf, raw, ...
|
||||
@@ -138,7 +136,6 @@ class PrintingPrinter(models.Model):
|
||||
# Backwards compatibility of builtin used as kwarg
|
||||
_set_option_format = _set_option_doc_format
|
||||
|
||||
@api.multi
|
||||
def _set_option_tray(self, report, value):
|
||||
"""Note we use self here as some older PPD use tray
|
||||
rather than InputSlot so we may need to query printer in override"""
|
||||
@@ -151,7 +148,6 @@ class PrintingPrinter(models.Model):
|
||||
_set_option_action = _set_option_noop
|
||||
_set_option_printer = _set_option_noop
|
||||
|
||||
@api.multi
|
||||
def print_options(self, report=None, **print_opts):
|
||||
options = {}
|
||||
for option, value in print_opts.items():
|
||||
@@ -162,7 +158,6 @@ class PrintingPrinter(models.Model):
|
||||
options[option] = str(value)
|
||||
return options
|
||||
|
||||
@api.multi
|
||||
def print_file(self, file_name, report=None, **print_opts):
|
||||
""" Print a file """
|
||||
self.ensure_one()
|
||||
@@ -182,7 +177,6 @@ class PrintingPrinter(models.Model):
|
||||
))
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def set_default(self):
|
||||
if not self:
|
||||
return
|
||||
@@ -192,21 +186,17 @@ class PrintingPrinter(models.Model):
|
||||
self.write({'default': True})
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def unset_default(self):
|
||||
self.write({'default': False})
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def get_default(self):
|
||||
return self.search([('default', '=', True)], limit=1)
|
||||
|
||||
@api.multi
|
||||
def action_cancel_all_jobs(self):
|
||||
self.ensure_one()
|
||||
return self.cancel_all_jobs()
|
||||
|
||||
@api.multi
|
||||
def cancel_all_jobs(self, purge_jobs=False):
|
||||
for printer in self:
|
||||
connection = printer.server_id._open_connection()
|
||||
@@ -218,7 +208,6 @@ class PrintingPrinter(models.Model):
|
||||
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def enable(self):
|
||||
for printer in self:
|
||||
connection = printer.server_id._open_connection()
|
||||
@@ -229,7 +218,6 @@ class PrintingPrinter(models.Model):
|
||||
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def disable(self):
|
||||
for printer in self:
|
||||
connection = printer.server_id._open_connection()
|
||||
|
||||
@@ -38,7 +38,6 @@ class PrintingReportXmlAction(models.Model):
|
||||
""" Reset the tray when the printer is changed """
|
||||
self.printer_tray_id = False
|
||||
|
||||
@api.multi
|
||||
def behaviour(self):
|
||||
if not self:
|
||||
return {}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from odoo import models, fields, api, exceptions, _
|
||||
from odoo import models, fields, exceptions, _
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -32,13 +32,12 @@ class PrintingServer(models.Model):
|
||||
string='Printers List',
|
||||
help='List of printers available on this server.')
|
||||
|
||||
@api.multi
|
||||
def _open_connection(self, raise_on_error=False):
|
||||
self.ensure_one()
|
||||
connection = False
|
||||
try:
|
||||
connection = cups.Connection(host=self.address, port=self.port)
|
||||
except:
|
||||
except Exception:
|
||||
message = _("Failed to connect to the CUPS server on %s:%s. "
|
||||
"Check that the CUPS server is running and that "
|
||||
"you can reach it from the Odoo server.") % (
|
||||
@@ -49,11 +48,9 @@ class PrintingServer(models.Model):
|
||||
|
||||
return connection
|
||||
|
||||
@api.multi
|
||||
def action_update_printers(self):
|
||||
return self.update_printers()
|
||||
|
||||
@api.multi
|
||||
def update_printers(self, domain=None, raise_on_error=False):
|
||||
if domain is None:
|
||||
domain = []
|
||||
@@ -106,7 +103,6 @@ class PrintingServer(models.Model):
|
||||
self = self.search([])
|
||||
return self.update_jobs()
|
||||
|
||||
@api.multi
|
||||
def update_jobs(self, which='all', first_job_id=-1):
|
||||
job_obj = self.env['printing.job']
|
||||
printer_obj = self.env['printing.printer']
|
||||
|
||||
Reference in New Issue
Block a user