mirror of
https://github.com/OCA/report-print-send.git
synced 2025-02-16 07:11:31 +02:00
[IMP] base_report_to_printer: archive printers
This commit is contained in:
@@ -32,6 +32,7 @@ class PrintingPrinter(models.Model):
|
|||||||
_order = 'name'
|
_order = 'name'
|
||||||
|
|
||||||
name = fields.Char(required=True, index=True)
|
name = fields.Char(required=True, index=True)
|
||||||
|
active = fields.Boolean(default=True)
|
||||||
server_id = fields.Many2one(
|
server_id = fields.Many2one(
|
||||||
comodel_name='printing.server', string='Server', required=True,
|
comodel_name='printing.server', string='Server', required=True,
|
||||||
help='Server used to access this printer.')
|
help='Server used to access this printer.')
|
||||||
|
|||||||
@@ -61,9 +61,8 @@ class PrintingServer(models.Model):
|
|||||||
servers = self
|
servers = self
|
||||||
if not self:
|
if not self:
|
||||||
servers = self.search(domain)
|
servers = self.search(domain)
|
||||||
|
|
||||||
res = True
|
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)
|
connection = server._open_connection(raise_on_error=raise_on_error)
|
||||||
if not connection:
|
if not connection:
|
||||||
server.printer_ids.write({'status': 'server-error'})
|
server.printer_ids.write({'status': 'server-error'})
|
||||||
|
|||||||
@@ -95,6 +95,18 @@ class TestPrintingServer(TransactionCase):
|
|||||||
'unavailable', rec_id.status,
|
'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)
|
@mock.patch('%s.cups' % model)
|
||||||
def test_update_jobs_cron(self, cups):
|
def test_update_jobs_cron(self, cups):
|
||||||
""" It should get all jobs from CUPS server """
|
""" It should get all jobs from CUPS server """
|
||||||
|
|||||||
@@ -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?"/>
|
<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>
|
</header>
|
||||||
<sheet>
|
<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">
|
<div class="oe_title">
|
||||||
<h1>
|
<h1>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user