Merge PR #233 into 13.0

Signed-off-by pedrobaeza
This commit is contained in:
OCA-git-bot
2020-12-15 17:26:21 +00:00
4 changed files with 21 additions and 1 deletions

View File

@@ -31,6 +31,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",

View File

@@ -61,7 +61,7 @@ class PrintingServer(models.Model):
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

@@ -89,6 +89,18 @@ class TestPrintingServer(TransactionCase):
self.Model.action_update_printers()
self.assertEqual("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

@@ -33,6 +33,13 @@
/>
</header>
<sheet>
<widget
name="web_ribbon"
text="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
/>
<field name="active" invisible="1" />
<div class="oe_title">
<h1>
<field name="name" />