[IMP] base_report_to_printer: archive printers

This commit is contained in:
Jaime Arroyo
2020-10-06 17:32:01 +02:00
parent ab879c3b45
commit 1c6535b3c9
4 changed files with 19 additions and 2 deletions

View File

@@ -32,6 +32,7 @@ class PrintingPrinter(models.Model):
_order = 'name'
name = fields.Char(required=True, index=True)
active = fields.Boolean(default=True)
server_id = fields.Many2one(
comodel_name='printing.server', string='Server', required=True,
help='Server used to access this printer.')

View File

@@ -61,9 +61,8 @@ class PrintingServer(models.Model):
servers = self
if not self:
servers = self.search(domain)
res = True
for server in servers:
for server in servers.with_context(active_test=False):
connection = server._open_connection(raise_on_error=raise_on_error)
if not connection:
server.printer_ids.write({'status': 'server-error'})

View File

@@ -95,6 +95,18 @@ class TestPrintingServer(TransactionCase):
'unavailable', rec_id.status,
)
@mock.patch('%s.cups' % model)
def test_update_archived_printers(self, cups):
""" It should update status even if printer is archived """
rec_id = self.new_printer()
rec_id.toggle_active()
self.server.refresh()
cups.Connection().getPrinters().get.return_value = False
self.Model.action_update_printers()
self.assertEqual(
'unavailable', rec_id.status,
)
@mock.patch('%s.cups' % model)
def test_update_jobs_cron(self, cups):
""" It should get all jobs from CUPS server """

View File

@@ -18,6 +18,11 @@
<button name="action_cancel_all_jobs" type="object" string="Cancel all running jobs" confirm="Are you sure to want to cancel all jobs of this printer?"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button" options='{"terminology": "archive"}'/>
</button>
</div>
<div class="oe_title">
<h1>
<field name="name"/>