Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit f6496a8

Browse files
committed
add location_id to inv_send
1 parent 6b6aef3 commit f6496a8

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

modules/s3db/gis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ def model(self):
320320
widget = S3LocationSelector(show_address=True,
321321
show_map=settings.get_gis_map_selector(),
322322
show_postcode=settings.get_gis_postcode_selector(),
323+
levels=["L1", "L2", "L3", "L4"], #@ToDo: Fix
323324
),
324325
# Alternate LocationSelector for when you don't have the Location Hierarchy available to load
325326
#requires = IS_EMPTY_OR(

modules/s3db/inv.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,8 @@ def model(self):
10951095
not_filter_opts = (True,),
10961096
)),
10971097
),
1098+
self.gis_location_id(label = T("To Location"),
1099+
),
10981100
organisation_id(
10991101
label = T("To Organization"),
11001102
readable = show_org,
@@ -1183,6 +1185,8 @@ def model(self):
11831185
s3_comments(),
11841186
*s3_meta_fields())
11851187

1188+
levels = current.gis.get_relevant_hierarchy_levels()
1189+
11861190
# Filter Widgets
11871191
filter_widgets = [
11881192
S3TextFilter(["sender_id$first_name",
@@ -1194,7 +1198,7 @@ def model(self):
11941198
"recipient_id$first_name",
11951199
"recipient_id$middle_name",
11961200
"recipient_id$last_name",
1197-
],
1201+
] + ["location_id$%s" % level for level in levels],
11981202
label = T("Search"),
11991203
comment = T("Search for an item by text."),
12001204
),
@@ -1204,6 +1208,9 @@ def model(self):
12041208
cols = 2,
12051209
hidden = True,
12061210
),
1211+
S3LocationFilter("location_id",
1212+
levels=levels,
1213+
),
12071214
S3TextFilter("type",
12081215
label = T("Shipment Type"),
12091216
hidden = True,
@@ -1278,6 +1285,7 @@ def model(self):
12781285
"req_ref",
12791286
"sender_id",
12801287
"site_id",
1288+
"location_id",
12811289
"date",
12821290
"recipient_id",
12831291
"delivery_date",
@@ -2407,6 +2415,24 @@ def prep(r):
24072415
else:
24082416
set_send_attr(SHIP_STATUS_IN_PROCESS)
24092417
sendtable.send_ref.readable = False
2418+
script = \
2419+
"""
2420+
$("#inv_send_to_site_id__row").hide();
2421+
$("[id^='inv_send_location_id']").hide();
2422+
$('<div id="facility_or_location_radio" class = "form-row row"><input type="radio" name="site_or_location" value="site"><label style="font-weight: bold;">To Facility</label><input type="radio" name="site_or_location" value="location"><label style="font-weight: bold;">To Location</label></div>'
2423+
).insertBefore( "#inv_send_to_site_id__row" );
2424+
$("input[name=site_or_location]").on( "change", function() {
2425+
if ($("input[name=site_or_location]:checked").val()=="site") {
2426+
$("#inv_send_to_site_id__row").show();
2427+
$("[id^='inv_send_location_id']").hide();
2428+
} else {
2429+
$("#inv_send_to_site_id__row").hide();
2430+
$("[id^='inv_send_location_id']").show();
2431+
}
2432+
2433+
});
2434+
"""
2435+
s3.jquery_ready.append(script)
24102436
return True
24112437

24122438
args = request.args

0 commit comments

Comments
 (0)