From 052db34beb0ffd327b35bc4e3109a597098beb7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominic=20K=C3=B6nig?= Date: Sun, 28 Nov 2021 22:20:41 +0100 Subject: [PATCH] Datatable fix, fix RLPPTM regression issue --- VERSION | 2 +- modules/core/ui/datatable.py | 13 ++++----- modules/s3db/fin.py | 20 ++++++++------ modules/templates/RLPPTM/config.py | 42 +++++++++++++----------------- 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/VERSION b/VERSION index 8f1029300a..795688665c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -nursix-dev-5204-g51871e552 (2021-11-28 20:05:00) +nursix-dev-5205-ge8207503e (2021-11-28 22:20:41) diff --git a/modules/core/ui/datatable.py b/modules/core/ui/datatable.py index 6ab0116c01..0a879c701c 100644 --- a/modules/core/ui/datatable.py +++ b/modules/core/ui/datatable.py @@ -742,12 +742,6 @@ def export_formats(base_url = None, EXPORT = T("Export in %(format)s format") for fmt in export_formats: - if fmt in default_formats: - url = formats.get(fmt, default_url) - else: - url = formats.get(fmt) - if not url: - continue title = None if isinstance(fmt, tuple): @@ -757,6 +751,13 @@ def export_formats(base_url = None, else: css = "" + if fmt in default_formats: + url = formats.get(fmt, default_url) + else: + url = formats.get(fmt) + if not url: + continue + css_class = "dt-export export_%s" % fmt if css: css_class = "%s %s" % (css_class, css) diff --git a/modules/s3db/fin.py b/modules/s3db/fin.py index b016df67df..2755355366 100644 --- a/modules/s3db/fin.py +++ b/modules/s3db/fin.py @@ -349,11 +349,11 @@ def model(self): billing_status = (("SCHEDULED", T("Scheduled")), ("ABORTED", T("Aborted")), ) - status_repr = dict(billing_status) + billing_status_opts = dict(billing_status) # Additional statuses that cannot be entered or imported - status_repr["IN PROGRESS"] = T("In Progress") - status_repr["COMPLETE"] = T("Completed") + billing_status_opts["IN PROGRESS"] = T("In Progress") + billing_status_opts["COMPLETE"] = T("Completed") tablename = "fin_voucher_billing" define_table(tablename, @@ -370,7 +370,7 @@ def model(self): requires = IS_IN_SET(billing_status, zero = None, ), - represent = represent_option(status_repr), + represent = S3Represent(options=billing_status_opts), writable = False, # Only writable while scheduled ), Field("vouchers_total", "integer", @@ -677,12 +677,12 @@ def model(self): #("INVOICED", T("Invoiced")), #("PAID", T("Paid")), ) - status_repr = dict(claim_status) + claim_status_opts = dict(claim_status) # Additional statuses that cannot be entered or imported - status_repr["INVOICED"] = T("Invoiced") + claim_status_opts["INVOICED"] = T("Invoiced") paid_label = settings.get_fin_voucher_claim_paid_label() - status_repr["PAID"] = T(paid_label) if paid_label else T("Paid") + claim_status_opts["PAID"] = T(paid_label) if paid_label else T("Paid") tablename = "fin_voucher_claim" define_table(tablename, @@ -767,7 +767,7 @@ def model(self): requires = IS_IN_SET(claim_status, zero = None, ), - represent = represent_option(dict(status_repr)), + represent = represent_option(claim_status_opts), writable = False, ), @@ -1188,6 +1188,8 @@ def model(self): # Pass names back to global scope (s3.*) # return {"fin_voucher_invoice_status": dict(invoice_status), + "fin_voucher_claim_status_opts": claim_status_opts, + "fin_voucher_billing_status_opts": billing_status_opts, } # ------------------------------------------------------------------------- @@ -1196,6 +1198,8 @@ def defaults(): """ Safe defaults for names in case the module is disabled """ return {"fin_voucher_invoice_status": {}, + "fin_voucher_claim_status_opts": {}, + "fin_voucher_billing_status_opts": {}, } # ------------------------------------------------------------------------- diff --git a/modules/templates/RLPPTM/config.py b/modules/templates/RLPPTM/config.py index 6699be554e..280dff14f1 100644 --- a/modules/templates/RLPPTM/config.py +++ b/modules/templates/RLPPTM/config.py @@ -1702,19 +1702,16 @@ def customise_fin_voucher_billing_resource(r, tablename): table = current.s3db.fin_voucher_billing # Color-coded representation of billing process status - from core import S3PriorityRepresent field = table.status - try: - status_opts = field.represent.options - except AttributeError: - pass - else: - field.represent = S3PriorityRepresent(status_opts, - {"SCHEDULED": "lightblue", - "IN PROGRESS": "amber", - "ABORTED": "black", - "COMPLETE": "green", - }).represent + + from core import S3PriorityRepresent + status_opts = s3db.fin_voucher_billing_status_opts + field.represent = S3PriorityRepresent(status_opts, + {"SCHEDULED": "lightblue", + "IN PROGRESS": "amber", + "ABORTED": "black", + "COMPLETE": "green", + }).represent # Custom onaccept to maintain realm-assignment of invoices # when accountant organisation changes @@ -1836,19 +1833,16 @@ def customise_fin_voucher_claim_resource(r, tablename): field.readable = field.writable = False # Color-coded representation of claim status - from core import S3PriorityRepresent field = table.status - try: - status_opts = field.represent.options - except AttributeError: - pass - else: - field.represent = S3PriorityRepresent(status_opts, - {"NEW": "lightblue", - "CONFIRMED": "blue", - "INVOICED": "amber", - "PAID": "green", - }).represent + + from core import S3PriorityRepresent + status_opts = s3db.fin_voucher_claim_status_opts + field.represent = S3PriorityRepresent(status_opts, + {"NEW": "lightblue", + "CONFIRMED": "blue", + "INVOICED": "amber", + "PAID": "green", + }).represent # Custom list fields list_fields = [#"refno",