Skip to content

Commit

Permalink
Datatable fix, fix RLPPTM regression issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nursix committed Nov 28, 2021
1 parent e820750 commit 052db34
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nursix-dev-5204-g51871e552 (2021-11-28 20:05:00)
nursix-dev-5205-ge8207503e (2021-11-28 22:20:41)
13 changes: 7 additions & 6 deletions modules/core/ui/datatable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand Down
20 changes: 12 additions & 8 deletions modules/s3db/fin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
),

Expand Down Expand Up @@ -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,
}

# -------------------------------------------------------------------------
Expand All @@ -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": {},
}

# -------------------------------------------------------------------------
Expand Down
42 changes: 18 additions & 24 deletions modules/templates/RLPPTM/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 052db34

Please sign in to comment.