Skip to content

Commit

Permalink
Nepal Template Customisation
Browse files Browse the repository at this point in the history
Inv
* Fix Beneficiary Column on Release Report (=To not From)
* Distribution Report
* Locations in Filters
General
* If the site is only configed for one country, use the hierarchy for that country
* Setting for get_supply_autocomplete
* Fix in creating hrm
  • Loading branch information
michaelhowden committed May 8, 2015
1 parent 41e18bb commit 8c87ce0
Show file tree
Hide file tree
Showing 41 changed files with 4,283 additions and 129 deletions.
29 changes: 28 additions & 1 deletion controllers/inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ def track_item():
#"send_id",
#"req_item_id",
(T("Date Released"), "send_id$date"),
(T("Beneficiary"), "send_id$site_id"),
(T("Beneficiary"), "send_id$to_site_id"),
(settings.get_inv_send_shortname(), "send_id$send_ref"),
(settings.get_req_shortname(), "send_id$req_ref"),
(T("Items/Description"), "item_id"),
Expand Down Expand Up @@ -1460,6 +1460,33 @@ def track_item():
]
)
s3.filter = (FS("expiry_date") != None)
elif report == "dist":
# Summary of Releases
s3.crud_strings["inv_track_item"] = Storage(title_list = T("Distribution Report"))

level_fields = ["send_id$to_site_id$location_id$%s" % level for
level in current.gis.get_relevant_hierarchy_levels()]

s3db.configure("inv_track_item",
list_fields = ["id",
#"send_id",
#"req_item_id",
(T("Date Sent"), "send_id$date"),
(s3db.inv_send.to_site_id.label, "send_id$to_site_id")] +
level_fields +
[(settings.get_inv_send_shortname(), "send_id$send_ref"),
(settings.get_req_shortname(), "send_id$req_ref"),
(T("Items"), "item_id"),
(T("Source"), "supply_org_id"),
(T("Unit"), "item_pack_id"),
(T("Quantity"), "quantity"),
(T("Unit Cost"), "pack_value"),
(T("Total Cost"), "total_value"),
],
orderby = "inv_send.date dsc",
sort = True
)
s3.filter = (FS("send_id$type") == 21)

output = s3_rest_controller(rheader = s3db.inv_rheader)
return output
Expand Down
11 changes: 10 additions & 1 deletion modules/s3/s3gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,7 @@ def get_location_hierarchy(self, level=None, location=None):
db = current.db
s3db = current.s3db
table = s3db.gis_hierarchy
ltable = s3db.gis_location

fields = (table.uuid,
table.L1,
Expand All @@ -1536,7 +1537,15 @@ def get_location_hierarchy(self, level=None, location=None):
table.L5,
)

query = (table.uuid == "SITE_DEFAULT")
countries = current.deployment_settings.get_gis_countries()
if len(countries) == 1:
#If the site is only configed for one country, use the hierarchy for that country
query = (table.location_id == ltable.id) & \
(ltable.level == "L0") & \
(ltable.name == self.get_country(countries[0],key_type="code"))
else:
query = (table.uuid == "SITE_DEFAULT")

if not location:
config = GIS.get_config()
location = config.region_location_id
Expand Down
3 changes: 2 additions & 1 deletion modules/s3/s3query.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,8 @@ def __init__(self, resource, selector, label=None):
# Fall back to the field label
if label is None:
fname = self.fname
if fname in ["L1", "L2", "L3", "L3", "L4", "L5"]:
# Does this really belong here? Better on gis_location fields
if fname in ("L1", "L2", "L3", "L3", "L4", "L5"):
try:
label = current.gis.get_location_hierarchy(fname)
except:
Expand Down
5 changes: 5 additions & 0 deletions modules/s3cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3482,6 +3482,11 @@ def get_req_restrict_on_complete(self):
# -------------------------------------------------------------------------
# Supply
#
def get_supply_autocomplete(self):
"""
Whether supply fields should use an Autocomplete instead of a dropdown
"""
return self.supply.get("autocomplete", False)
def get_supply_catalog_default(self):
return self.inv.get("catalog_default", "Default")

Expand Down
2 changes: 1 addition & 1 deletion modules/s3db/hrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5165,7 +5165,7 @@ def hrm_human_resource_onaccept(form):
ltable.insert(human_resource_id=id,
job_title_id=job_title_id,
main=True,
start_date=request.utcnow,
date=request.utcnow,
)

data = Storage()
Expand Down
25 changes: 22 additions & 3 deletions modules/s3db/inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,9 @@ def model(self):
#send_type_opts.update(self.inv_item_status_opts)
send_type_opts.update(settings.get_inv_send_types())

self.org_facility # Load model + crud_strings
ADD_FACILITY = crud_strings.org_facility.label_create

site_types = auth.org_site_types
tablename = "inv_send"
define_table(tablename,
Expand Down Expand Up @@ -1094,6 +1097,10 @@ def model(self):
not_filterby = "obsolete",
not_filter_opts = (True,),
)),
comment = S3AddResourceLink(c="org",
f="facility",
label=ADD_FACILITY,
title=ADD_FACILITY)
),
organisation_id(
label = T("To Organization"),
Expand Down Expand Up @@ -1183,6 +1190,8 @@ def model(self):
s3_comments(),
*s3_meta_fields())

levels = current.gis.get_relevant_hierarchy_levels()

# Filter Widgets
filter_widgets = [
S3TextFilter(["sender_id$first_name",
Expand All @@ -1194,7 +1203,7 @@ def model(self):
"recipient_id$first_name",
"recipient_id$middle_name",
"recipient_id$last_name",
],
] + ["location_id$%s" % level for level in levels],
label = T("Search"),
comment = T("Search for an item by text."),
),
Expand All @@ -1204,6 +1213,9 @@ def model(self):
cols = 2,
hidden = True,
),
S3LocationFilter("to_site_id$location_id",
levels=levels,
),
S3TextFilter("type",
label = T("Shipment Type"),
hidden = True,
Expand Down Expand Up @@ -1875,6 +1887,12 @@ def model(self):
label = T("Search"),
#comment = recv_search_comment,
),
S3OptionsFilter("send_id$site_id"),
S3LocationFilter("send_id$to_site_id$location_id",
#hidden=True,
label=T("Sent to Location"),
levels=levels,
),
S3DateFilter("send_id$date",
label = T("Sent date"),
hidden = True,
Expand Down Expand Up @@ -2142,7 +2160,8 @@ def inv_send_controller(cls):
s3 = response.s3

# Limit site_id to sites the user has permissions for
error_msg = T("You do not have permission for any facility to send a shipment.")
error_msg = T("You do not have permission for any %s to send a shipment.") % \
current.deployment_settings.get_inv_facility_label()
current.auth.permitted_facilities(table=sendtable, error_msg=error_msg)

# Set Validator for checking against the number of items in the warehouse
Expand Down Expand Up @@ -2534,7 +2553,7 @@ def inv_send_process():
site_id = send_record.to_site_id,
comments = send_record.comments,
status = SHIP_STATUS_SENT,
type = 1, # 1:"Another Inventory"
type = 11, # 11:"Another Inventory"
)

# Change the status for all track items in this shipment to In transit
Expand Down
6 changes: 5 additions & 1 deletion modules/s3db/supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@ def model(self):
supply_item_represent = supply_ItemRepresent(show_link=True)

# Reusable Field
if settings.get_supply_autocomplete():
default_widget = S3AutocompleteWidget("supply", "item"),
else:
default_widget = None
supply_item_id = S3ReusableField("item_id",
"reference %s" % tablename, # 'item_id' for backwards-compatibility
label = T("Item"),
Expand All @@ -434,7 +438,7 @@ def model(self):
supply_item_represent,
sort=True),
sortby = "name",
widget = S3AutocompleteWidget("supply", "item"),
widget = default_widget,
comment=S3AddResourceLink(c="supply",
f="item",
label=ADD_ITEM,
Expand Down
2 changes: 2 additions & 0 deletions modules/s3db/vol.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ def prep(r):
list_fields.append((T("Trainings"),"person_id$training.course_id"))
if settings.get_hrm_use_certificates():
list_fields.append((T("Certificates"),"person_id$certification.certificate_id"))
if r.representation == "xls":
list_fields.append("person_id$comments")

# Volunteer Programme and Active-status
report_options = get_config("report_options")
Expand Down
2 changes: 2 additions & 0 deletions modules/s3menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,8 @@ def inv():
vars=dict(report="inc")),
M("Summary of Releases", c="inv", f="track_item",
vars=dict(report="rel")),
M("Distribution Report", c="inv", f="track_item",
vars=dict(report="dist")),
),
M(inv_recv_list, c="inv", f="recv", translate=False)( # Already T()
M("Create", m="create"),
Expand Down
3 changes: 3 additions & 0 deletions modules/templates/IFRC/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ def currency_default(default):
# Activity types for experience record
settings.hrm.activity_types = {"rdrt": "RDRT Mission"}

# -----------------------------------------------------------------------------
# Supply / Inventory / Warehouse
settings.supply.autocomplete = True
# =============================================================================
# Template Modules
# Comment/uncomment modules here to disable/enable them
Expand Down
Loading

0 comments on commit 8c87ce0

Please sign in to comment.