mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
@@ -242,3 +242,18 @@ class PrintingPrinter(models.Model):
|
|||||||
self.mapped("server_id").update_printers()
|
self.mapped("server_id").update_printers()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def print_test_page(self):
|
||||||
|
for printer in self:
|
||||||
|
connection = printer.server_id._open_connection()
|
||||||
|
if printer.model == "Local Raw Printer":
|
||||||
|
fd, file_name = mkstemp()
|
||||||
|
try:
|
||||||
|
os.write(fd, b"TEST")
|
||||||
|
finally:
|
||||||
|
os.close(fd)
|
||||||
|
connection.printTestPage(printer.system_name, file=file_name)
|
||||||
|
else:
|
||||||
|
connection.printTestPage(printer.system_name)
|
||||||
|
|
||||||
|
self.mapped("server_id").update_jobs(which="completed")
|
||||||
|
|||||||
@@ -173,3 +173,10 @@ class TestPrintingPrinter(TransactionCase):
|
|||||||
printer = self.new_record()
|
printer = self.new_record()
|
||||||
printer.disable()
|
printer.disable()
|
||||||
cups.Connection().disablePrinter.assert_called_once_with(printer.system_name)
|
cups.Connection().disablePrinter.assert_called_once_with(printer.system_name)
|
||||||
|
|
||||||
|
@mock.patch("%s.cups" % server_model)
|
||||||
|
def test_print_test_page(self, cups):
|
||||||
|
""" It should print a test page """
|
||||||
|
printer = self.new_record()
|
||||||
|
printer.print_test_page()
|
||||||
|
cups.Connection().printTestPage.assert_called_once_with(printer.system_name)
|
||||||
|
|||||||
@@ -31,6 +31,12 @@
|
|||||||
string="Cancel all running jobs"
|
string="Cancel all running jobs"
|
||||||
confirm="Are you sure to want to cancel all jobs of this printer?"
|
confirm="Are you sure to want to cancel all jobs of this printer?"
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
name="print_test_page"
|
||||||
|
type="object"
|
||||||
|
string="Print Test Page"
|
||||||
|
confirm="Are you sure to want to print a test page?"
|
||||||
|
/>
|
||||||
</header>
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
<widget
|
<widget
|
||||||
|
|||||||
Reference in New Issue
Block a user