[FIX] base_report_to_printer: update printers wizard

- Add access rules to the wizard
- Set a fallback name for the printers and respect the user custom ones

TT45159
This commit is contained in:
David
2023-09-20 11:19:15 +02:00
parent 8a21ba8261
commit 1d45dac7ef
5 changed files with 13 additions and 4 deletions

View File

@@ -70,7 +70,7 @@ class PrintingPrinter(models.Model):
def _prepare_update_from_cups(self, cups_connection, cups_printer):
mapping = {3: "available", 4: "printing", 5: "error"}
cups_vals = {
"name": cups_printer["printer-info"],
"name": self.name or cups_printer["printer-info"],
"model": cups_printer.get("printer-make-and-model", False),
"location": cups_printer.get("printer-location", False),
"uri": cups_printer.get("device-uri", False),

View File

@@ -121,6 +121,11 @@ class PrintingServer(models.Model):
printer_values["server_id"] = server.id
updated_printers.append(name)
# We want to keep any existing customized name over existing printer
# We want also to rely in the system name as a fallback to avoid
# empty names.
if not printer_values.get("name") and not printer.name:
printer_values["name"] = name
if not printer:
printer_values["system_name"] = name
printer.create(printer_values)