Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of git://github.com/michaelhowden/eden

& move order of update_location_tree before stats_rebuild_aggregates
  • Loading branch information...
commit a1ee30c2a7b43678cc5376bd3e0c127ff0f0de67 2 parents 44e26ba + 1ce5488
@flavour authored
View
2  VERSION
@@ -1 +1 @@
-f282c4c (2012-10-03 11:08:31)
+44e26ba (2012-10-03 12:12:55)
View
7 controllers/inv.py
@@ -1194,7 +1194,7 @@ def set_track_attr(status):
tracktable.recv_bin.writable = True
def prep(r):
- record = recvtable[r.id]
+ record = r.record
if (record and
(record.status != SHIP_STATUS_IN_PROCESS and
record.status != SHIP_STATUS_SENT)):
@@ -1206,7 +1206,7 @@ def prep(r):
editable=False,
deletable=False,
)
- if r.component:
+ if r.component and r.component.name == "track_item":
# Set the track_item attributes
# Can only create or delete track items for a recv record if the status is preparing
if r.method == "create" or r.method == "delete":
@@ -1222,6 +1222,9 @@ def prep(r):
if r.record and r.record.status == SHIP_STATUS_IN_PROCESS:
s3.crud_strings.inv_recv.title_update = \
s3.crud_strings.inv_recv.title_display = T("Process Received Shipment")
+
+ # Default the Supplier/Donor to the Org sending the shipment
+ tracktable.supply_org_id.default = record.organisation_id
else:
# Set the recv attributes
if r.id:
View
15 models/zzz_1st_run.py
@@ -390,13 +390,6 @@
# Restore table protection
s3mgr.PROTECTED = protected
- # Update stats_aggregate (disabled during prepop)
- if has_module("stats"):
- start = datetime.datetime.now()
- s3db.stats_rebuild_aggregates()
- end = datetime.datetime.now()
- print >> sys.stdout, "Statistics data aggregation completed in %s" % (end - start)
-
# Restore Auth
auth.override = False
@@ -406,6 +399,14 @@
end = datetime.datetime.now()
print >> sys.stdout, "Location Tree update completed in %s" % (end - start)
+ # Update stats_aggregate (disabled during prepop)
+ # - needs to be done after locations
+ if has_module("stats"):
+ start = datetime.datetime.now()
+ s3db.stats_rebuild_aggregates()
+ end = datetime.datetime.now()
+ print >> sys.stdout, "Statistics data aggregation completed in %s" % (end - start)
+
grandTotalEnd = datetime.datetime.now()
duration = grandTotalEnd - grandTotalStart
try:
View
32 modules/eden/asset.py
@@ -155,6 +155,15 @@ def model(self):
widget = None,
script = None, # No Item Pack Filter
),
+ organisation_id(script = SCRIPT('''
+$(document).ready(function(){
+ S3FilterFieldChange({
+ 'FilterField':'organisation_id',
+ 'Field':'site_id',
+ 'FieldResource':'site',
+ 'FieldPrefix':'org',
+ })
+})'''),),
# This is a component, so needs to be a super_link
# - can't override field name, ondelete or requires
super_link("site_id", "org_site",
@@ -171,13 +180,17 @@ def model(self):
# T("Enter some characters to bring up a list of possible matches"))),
represent = self.org_site_represent
),
- organisation_id(),
Field("sn",
label = T("Serial Number")),
- # @ToDo: Switch to using org_organisation filtered to suppliers
- #supplier_id(),
+ organisation_id(name = "supply_org_id",
+ label = T("Supplier/Donor"),
+ ondelete = "SET NULL"),
+ # @ToDo: Remove after data is migrated
Field("supplier",
- label = T("Supplier")),
+ label = T("Supplier"),
+ readable = False,
+ writable = False,
+ ),
s3_date("purchase_date",
label = T("Purchase Date")
),
@@ -312,9 +325,9 @@ def model(self):
methods=["count", "list"],
defaults=Storage(
aggregate="count",
- cols="L1",
- fact="number",
- rows="item_id$item_category_id"
+ cols="asset.L1",
+ fact="asset.number",
+ rows="asset.item_id$item_category_id"
)
),
list_fields=["id",
@@ -565,9 +578,8 @@ def asset_onaccept(form):
# Update asset realm_entity and components' realm_entity
auth.set_realm_entity(atable, vars, force_update=True)
- #auth.set_component_realm_entity(atable, vars,
- #update_components = ["log", "presence"]
- #)
+ auth.set_component_realm_entity(atable, vars,
+ update_components = ["log", "presence"])
site_id = vars.get("site_id", None)
if site_id:
View
37 modules/eden/hrm.py
@@ -126,7 +126,16 @@ def model(self):
widget = None,
#widget=S3OrganisationAutocompleteWidget(
# default_from_profile=True),
- empty=False
+ empty=False,
+ script = SCRIPT('''
+$(document).ready(function(){
+ S3FilterFieldChange({
+ 'FilterField':'organisation_id',
+ 'Field':'site_id',
+ 'FieldResource':'site',
+ 'FieldPrefix':'org',
+ })
+})'''),
),
self.super_link("site_id", "org_site",
label=T("Office/Warehouse/Facility"),
@@ -456,9 +465,9 @@ def model(self):
cols=report_fields,
facts=report_fields,
methods=["count", "list"],
- defaults=Storage(rows="organisation_id",
- cols="course",
- fact="person_id",
+ defaults=Storage(rows="human_resource.organisation_id",
+ cols="human_resource.course",
+ fact="human_resource.person_id",
aggregate="count")
),
create_next = hrm_url,
@@ -1892,9 +1901,9 @@ def model(self):
cols=report_fields,
facts=report_fields,
methods=["count", "list"],
- defaults=Storage(rows="course_id",
- cols="month",
- fact="person_id",
+ defaults=Storage(rows="hrm_training.course_id",
+ cols="hrm_training.month",
+ fact="hrm_training.person_id",
aggregate="count"),
),
list_fields = [
@@ -3253,11 +3262,11 @@ def hrm_human_resource_onaccept(form):
# Affiliation, record ownership and component ownership
s3db.pr_update_affiliations(htable, record)
- #auth.s3_set_record_owner(htable, record, force_update=True)
- #auth.set_component_realm_entity(htable, vars,
- #update_components = ["presence"])
+ auth.set_realm_entity(htable, record, force_update=True)
+ auth.set_component_realm_entity(htable, vars,
+ update_components = ["presence"])
- # realm_entity for the pr_person record
+ # Realm_entity for the pr_person record
ptable = s3db.pr_person
person_id = record.person_id
person = Storage(id = person_id)
@@ -3269,9 +3278,9 @@ def hrm_human_resource_onaccept(form):
auth.set_realm_entity(ptable, person,
entity = entity,
force_update = True)
- #auth.set_component_realm_entity(ptable, person,
- #entity = entity,
- #update_components = ["presence"])
+ auth.set_component_realm_entity(ptable, person,
+ entity = entity,
+ update_components = ["presence"])
site_id = record.site_id
site_contact = record.site_contact
View
340 modules/eden/inv.py
@@ -341,25 +341,25 @@ def inv_warehouse_onaccept(form):
# Affiliation, record ownership and component ownership
s3db.pr_update_affiliations(wtable, vars)
- #auth.s3_set_record_owner(wtable, vars, force_update=True)
- #auth.set_component_realm_entity(wtable, vars,
- #update_components = ["contact_emergency",
- #"physical_description",
- #"config",
- #"image",
- #"req",
- #"send",
- #"human_resource_site",
- #"note",
- #"contact",
- #"role",
- #"asset",
- #"commit",
- #"inv_item",
- #"document",
- #"recv",
- #"address",
- #])
+ auth.set_realm_entity(wtable, vars, force_update=True)
+ auth.set_component_realm_entity(wtable, vars,
+ update_components = ["contact_emergency",
+ "physical_description",
+ "config",
+ "image",
+ "req",
+ "send",
+ "human_resource_site",
+ "note",
+ "contact",
+ "role",
+ "asset",
+ "commit",
+ "inv_item",
+ "document",
+ "recv",
+ "address",
+ ])
# ---------------------------------------------------------------------
@staticmethod
@@ -421,15 +421,12 @@ def model(self):
db = current.db
auth = current.auth
- org_id = self.org_organisation_id
+ organisation_id = self.org_organisation_id
messages = current.messages
NONE = messages.NONE
UNKNOWN_OPT = messages.UNKNOWN_OPT
- s3_date_format = current.deployment_settings.get_L10n_date_format()
- s3_date_represent = lambda dt: S3DateTime.date_represent(dt, utc=True)
-
inv_source_type = { 0: None,
1: T("Donated"),
2: T("Procured"),
@@ -481,12 +478,8 @@ def model(self):
represent = lambda opt: \
inv_item_status_opts.get(opt, UNKNOWN_OPT),
default = 0,),
- Field("expiry_date", "date",
- label = T("Expiry Date"),
- requires = IS_NULL_OR(IS_DATE(format=s3_date_format)),
- represent = s3_date_represent,
- widget = S3DateWidget()
- ),
+ s3_date("expiry_date",
+ label = T("Expiry Date")),
Field("pack_value", "double",
label = T("Value per Pack"),
represent=lambda v, row=None: \
@@ -499,12 +492,14 @@ def model(self):
Field("item_source_no", "string", length=16,
label = itn_label,
),
- org_id(name = "owner_org_id",
- label = T("Organization/Department"),
- ondelete = "SET NULL"), # which org owns this item
- org_id(name = "supply_org_id",
- label = T("Supplier/Donor"),
- ondelete = "SET NULL"), # original donating org
+ # Organisation that owns this item
+ organisation_id(name = "owner_org_id",
+ label = T("Organization/Department"),
+ ondelete = "SET NULL"),
+ # Original donating Organisation
+ organisation_id(name = "supply_org_id",
+ label = T("Supplier/Donor"),
+ ondelete = "SET NULL"),
Field("source_type", "integer",
label = T("Type"),
requires = IS_NULL_OR(IS_IN_SET(inv_source_type)),
@@ -631,9 +626,9 @@ def model(self):
cols=["site_id", "owner_org_id", "supply_org_id", "currency"],
facts=["quantity", (T("Total Value"), "total_value"),],
methods=["sum"],
- defaults=Storage(rows="item_id",
- cols="site_id",
- fact="quantity",
+ defaults=Storage(rows="inv_item.item_id",
+ cols="inv_item.site_id",
+ fact="inv_item.quantity",
aggregate="sum"),
groupby=self.inv_inv_item.site_id,
hide_comments=True,
@@ -894,7 +889,7 @@ def model(self):
settings = current.deployment_settings
person_id = self.pr_person_id
- org_id = self.org_organisation_id
+ organisation_id = self.org_organisation_id
item_id = self.supply_item_id
inv_item_id = self.inv_item_id
item_pack_id = self.supply_item_pack_id
@@ -918,8 +913,6 @@ def model(self):
permitted_facilities = auth.permitted_facilities
user = auth.user
- s3_date_format = settings.get_L10n_date_format()
- s3_date_represent = lambda dt: S3DateTime.date_represent(dt, utc=True)
s3_string_represent = lambda str: str if str else NONE
send_ref = S3ReusableField("send_ref",
@@ -942,13 +935,6 @@ def model(self):
#
tablename = "inv_send"
table = define_table(tablename,
- send_ref(),
- req_ref(),
- person_id(name = "sender_id",
- label = T("Sent By"),
- default = auth.s3_logged_in_person(),
- ondelete = "SET NULL",
- comment = self.pr_person_comment(child="sender_id")),
# This is a component, so needs to be a super_link
# - can't override field name, ondelete or requires
self.super_link("site_id", "org_site",
@@ -966,36 +952,43 @@ def model(self):
represent = org_site_represent,
#widget = S3SiteAutocompleteWidget(),
),
- Field("date", "date",
- label = T("Date Sent"),
- writable = False,
- requires = IS_NULL_OR(IS_DATE(format=s3_date_format)),
- represent = s3_date_represent,
- widget = S3DateWidget()
- ),
- person_id(name = "recipient_id",
- label = T("To Person"),
- ondelete = "SET NULL",
- comment = self.pr_person_comment(child="recipient_id")),
- Field("delivery_date", "date",
- label = T("Est. Delivery Date"),
- requires = IS_NULL_OR(IS_DATE(format=s3_date_format)),
- represent = s3_date_represent,
- widget = S3DateWidget()
+ Field("type", "integer",
+ requires = IS_IN_SET(send_type_opts),
+ represent = lambda opt: send_type_opts.get(opt, UNKNOWN_OPT),
+ label = T("Shipment Type"),
+ default = 0,
),
# This is a reference, not a super-link, so we can override
Field("to_site_id", self.org_site,
label = T("To Warehouse/Facility/Office"),
- requires = IS_ONE_OF(db, "org_site.site_id",
+ requires = IS_NULL_OR(IS_ONE_OF(db, "org_site.site_id",
lambda id: \
org_site_represent(id, show_link = False),
sort=True,
not_filterby = "obsolete",
not_filter_opts = [True],
- ),
+ )),
ondelete = "SET NULL",
represent = org_site_represent
- ),
+ ),
+ organisation_id(label = T("To Organisation")),
+ s3_date(label = T("Date Sent"),
+ writable = False),
+ s3_date("delivery_date",
+ label = T("Estimated Delivery Date"),
+ writable = False),
+ send_ref(),
+ req_ref(),
+ person_id(name = "sender_id",
+ label = T("Sent By"),
+ default = auth.s3_logged_in_person(),
+ ondelete = "SET NULL",
+ comment = self.pr_person_comment(child="sender_id")),
+
+ person_id(name = "recipient_id",
+ label = T("To Person"),
+ ondelete = "SET NULL",
+ comment = self.pr_person_comment(child="recipient_id")),
Field("status", "integer",
requires = IS_NULL_OR(IS_IN_SET(shipment_status)),
represent = lambda opt: shipment_status.get(opt, UNKNOWN_OPT),
@@ -1003,12 +996,6 @@ def model(self):
label = T("Status"),
writable = False,
),
- Field("type", "integer",
- requires = IS_NULL_OR(IS_IN_SET(send_type_opts)),
- represent = lambda opt: send_type_opts.get(opt, UNKNOWN_OPT),
- label = T("Shipment Type"),
- default = 0,
- ),
Field("transport_type",
label = T("Type of Transport"),
represent = s3_string_represent,
@@ -1099,6 +1086,7 @@ def model(self):
"comments"
],
onaccept = self.inv_send_onaccept,
+ onvalidation = self.inv_send_onvalidation,
create_next = send_item_url,
update_next = send_item_url,
orderby=~table.date,
@@ -1135,31 +1123,14 @@ def model(self):
represent = org_site_represent,
#widget = S3SiteAutocompleteWidget(),
),
- Field("eta", "date",
- label = T("Date Expected"),
- writable = False,
- requires = IS_NULL_OR(IS_DATE(format=s3_date_format)),
- represent = s3_date_represent,
- widget = S3DateWidget()
- ),
- Field("date", "date",
- label = T("Date Received"),
- requires = IS_NULL_OR(IS_DATE(format=s3_date_format)),
- represent = s3_date_represent,
- widget = S3DateWidget(),
- comment = DIV(_class="tooltip",
- _title="%s|%s" % (T("Date Received"),
- T("Will be filled automatically when the Shipment has been Received"))
- )
- ),
Field("type", "integer",
requires = IS_IN_SET(recv_type_opts),
represent = lambda opt: \
recv_type_opts.get(opt, UNKNOWN_OPT),
- label = T("Type"),
+ label = T("Shipment Type"),
default = 0,
),
- org_id( label = T("Organisation/Supplier")
+ organisation_id( label = T("Organisation/Supplier")
),
# This is a reference, not a super-link, so we can override
Field("from_site_id", "reference org_site",
@@ -1176,6 +1147,14 @@ def model(self):
),
represent = org_site_represent
),
+ s3_date("eta",
+ label = T("Date Expected"),
+ writable = False),
+ s3_date(label = T("Date Received"),
+ comment = DIV(_class="tooltip",
+ _title="%s|%s" % (T("Date Received"),
+ T("Will be filled automatically when the Shipment has been Received"))),
+ ),
send_ref(),
recv_ref(),
purchase_ref(),
@@ -1376,22 +1355,22 @@ def model(self):
tablename = "inv_kit"
table = define_table(tablename,
Field("site_id", "reference org_site",
- label = T("By Warehouse/Facility/Office"),
- requires = IS_ONE_OF(db, "org_site.site_id",
- lambda id: \
+ label = T("By Warehouse/Facility/Office"),
+ requires = IS_ONE_OF(db, "org_site.site_id",
+ lambda id: \
org_site_represent(id, show_link = False),
- #filterby = "site_id",
- #filter_opts = auth.permitted_facilities(redirect_on_error=False),
- instance_types = auth.org_site_types,
- updateable = True,
- sort=True,
- ),
- default = user.site_id if is_logged_in() else None,
- readable = True,
- writable = True,
- widget = S3SiteAutocompleteWidget(),
- represent = org_site_represent
- ),
+ #filterby = "site_id",
+ #filter_opts = auth.permitted_facilities(redirect_on_error=False),
+ instance_types = auth.org_site_types,
+ updateable = True,
+ sort=True,
+ ),
+ default = user.site_id if is_logged_in() else None,
+ readable = True,
+ writable = True,
+ widget = S3SiteAutocompleteWidget(),
+ represent = org_site_represent
+ ),
item_id(label = T("Kit"),
requires = IS_ONE_OF(db, "supply_item.id",
self.supply_item_represent,
@@ -1414,17 +1393,11 @@ def model(self):
represent = lambda v, row=None: \
IS_FLOAT_AMOUNT.represent(v, precision=2)
),
- Field("date", "date",
- label = T("Date"),
- requires = IS_NULL_OR(IS_DATE(format=s3_date_format)),
- represent = s3_date_represent,
- widget = S3DateWidget(),
- comment = DIV(_class="tooltip",
- _title="%s|%s" % \
+ s3_date(comment = DIV(_class="tooltip",
+ _title="%s|%s" % \
(T("Date Repacked"),
- T("Will be filled automatically when the Item has been Repacked"))
- )
- ),
+ T("Will be filled automatically when the Item has been Repacked")))
+ ),
req_ref(writable = True),
person_id(name = "repacked_id",
label = T("Repacked By"),
@@ -1470,11 +1443,12 @@ def model(self):
tablename = "inv_track_item"
table = define_table(tablename,
- org_id(name = "track_org_id",
- label = T("Shipping Organization"),
- ondelete = "SET NULL",
- readable = False,
- writable = False),
+ organisation_id(name = "track_org_id",
+ label = T("Shipping Organization"),
+ ondelete = "SET NULL",
+ readable = False,
+ writable = False
+ ),
inv_item_id(name="send_inv_item_id",
ondelete = "RESTRICT",
script = SCRIPT('''
@@ -1508,12 +1482,8 @@ def model(self):
Field("pack_value", "double",
label = T("Value per Pack")),
s3_currency(),
- Field("expiry_date", "date",
- label = T("Expiry Date"),
- requires = IS_NULL_OR(IS_DATE(format=s3_date_format)),
- represent = s3_date_represent,
- widget = S3DateWidget()
- ),
+ s3_date("expiry_date",
+ label = T("Expiry Date")),
# The bin at origin
Field("bin", length=16,
label = T("Bin"),
@@ -1540,13 +1510,13 @@ def model(self):
label = itn_label,
represent = s3_string_represent),
# original donating org
- org_id(name = "supply_org_id",
- label = T("Supplier/Donor"),
- ondelete = "SET NULL"),
+ organisation_id(name = "supply_org_id",
+ label = T("Supplier/Donor"),
+ ondelete = "SET NULL"),
# which org owns this item
- org_id(name = "owner_org_id",
- label = T("Organization/Department"),
- ondelete = "SET NULL"),
+ organisation_id(name = "owner_org_id",
+ label = T("Organization/Department"),
+ ondelete = "SET NULL"),
Field("inv_item_status", "integer",
label = T("Item Status"),
requires = IS_NULL_OR(IS_IN_SET(inv_item_status_opts)),
@@ -1672,23 +1642,18 @@ def inv_send_represent(id, show_link=True):
table.to_site_id,
limitby=(0, 1)).first()
- send_ref_string = table.send_ref.represent( row.send_ref,
- show_link = False)
- to_string = table.to_site_id.represent( row.to_site_id,
- show_link = False)
- date_string = table.date.represent( row.date )
+ send_ref_string = table.send_ref.represent(row.send_ref,
+ show_link = False)
+ to_string = table.to_site_id.represent(row.to_site_id,
+ show_link = False)
+ date_string = table.date.represent(row.date)
represent = "%s (To: %s on %s)" % (send_ref_string,
to_string,
- date_string
- )
+ date_string)
if show_link:
return A(represent,
- _href = URL(c="inv",
- f = "send",
- args = [id]
- )
- )
+ _href = URL(c="inv", f = "send", args = [id]))
else:
return represent
else:
@@ -1813,27 +1778,22 @@ def inv_recv_represent(id, show_link=True):
table.organisation_id,
limitby=(0, 1)).first()
- recv_ref_string = table.send_ref.represent( row.recv_ref,
- show_link = False)
+ recv_ref_string = table.send_ref.represent(row.recv_ref,
+ show_link = False)
if row.from_site_id:
- from_string = table.from_site_id.represent( row.from_site_id,
- show_link = False)
+ from_string = table.from_site_id.represent(row.from_site_id,
+ show_link = False)
else:
- from_string = table.organisation_id.represent( row.organisation_id,
- show_link = False)
- date_string = table.date.represent( row.date )
+ from_string = table.organisation_id.represent(row.organisation_id,
+ show_link = False)
+ date_string = table.date.represent(row.date)
represent = "%s (From: %s on %s)" % (recv_ref_string,
from_string,
- date_string
- )
+ date_string)
if show_link:
return A(represent,
- _href = URL(c="inv",
- f = "recv",
- args = [id]
- )
- )
+ _href = URL(c="inv", f = "recv", args = [id]))
else:
return represent
else:
@@ -1845,6 +1805,7 @@ def inv_recv_onaccept(form):
"""
When a inv recv record is created then create the recv_ref.
"""
+
db = current.db
rtable = db.inv_recv
# If the recv_ref is None then set it up
@@ -1861,6 +1822,20 @@ def inv_recv_onaccept(form):
# -------------------------------------------------------------------------
@staticmethod
+ def inv_send_onvalidation(form):
+ """
+ Check that either organisation_id or to_site_id are filled according to the type
+ """
+
+ vars = form.vars
+ if not vars.to_site_id and not vars.organisation_id:
+ error = T("Please enter a Warehouse/Facility/Office OR an Organisation")
+ errors = form.errors
+ errors.to_site_id = error
+ errors.organisation_id = error
+
+ # -------------------------------------------------------------------------
+ @staticmethod
def inv_recv_onvalidation(form):
"""
Check that either organisation_id or from_site_id are filled according to the type
@@ -3044,7 +3019,7 @@ def model(self):
auth = current.auth
person_id = self.pr_person_id
- org_id = self.org_organisation_id
+ organisation_id = self.org_organisation_id
org_site_represent = self.org_site_represent
item_id = self.supply_item_id
inv_item_id = self.inv_item_id
@@ -3055,9 +3030,6 @@ def model(self):
crud_strings = current.response.s3.crud_strings
define_table = self.define_table
- s3_date_format = current.deployment_settings.get_L10n_date_format()
- s3_date_represent = lambda dt: S3DateTime.date_represent(dt, utc=True)
-
# ---------------------------------------------------------------------
# Adjustments
#
@@ -3090,20 +3062,18 @@ def model(self):
sort = True,
),
represent=org_site_represent),
- Field("adjustment_date", "date",
- label = T("Date of adjustment"),
- default = current.request.utcnow,
- writable = False,
- represent = s3_date_represent,
- widget = S3DateWidget()
- ),
+ s3_date("adjustment_date",
+ label = T("Date of adjustment"),
+ default = "now",
+ writable = False
+ ),
Field("status", "integer",
requires = IS_NULL_OR(IS_IN_SET(adjust_status)),
represent = lambda opt: \
adjust_status.get(opt, UNKNOWN_OPT),
default = 0,
label = T("Status of adjustment"),
- writable = False,
+ writable = False
),
Field("category", "integer",
requires = IS_NULL_OR(IS_IN_SET(adjust_type)),
@@ -3205,24 +3175,22 @@ def model(self):
represent = lambda opt: \
inv_item_status_opts.get(opt, UNKNOWN_OPT),
default = 0,),
- Field("expiry_date", "date",
- label = T("Expiry Date"),
- requires = IS_NULL_OR(IS_DATE(format=s3_date_format)),
- represent = s3_date_represent,
- widget = S3DateWidget()
- ),
+ s3_date("expiry_date",
+ label = T("Expiry Date")),
Field("bin", "string", length=16,
label = T("Bin"),
# @ToDo:
#widget = S3InvBinWidget("inv_adj_item")
),
- org_id(name = "old_owner_org_id",
- label = T("Current owning Organization"),
- ondelete = "SET NULL",
- writable = False), # which org owned this item
- org_id(name = "new_owner_org_id",
- label = T("Transfer ownership to Organization"),
- ondelete = "SET NULL"), # which org owns this item
+ # Organisation that owned this item before
+ organisation_id(name = "old_owner_org_id",
+ label = T("Current owning Organization"),
+ ondelete = "SET NULL",
+ writable = False),
+ # Organisation that owns this item now
+ organisation_id(name = "new_owner_org_id",
+ label = T("Transfer ownership to Organization"),
+ ondelete = "SET NULL"),
adj_id(),
s3_comments(),
*s3_meta_fields()
@@ -3316,7 +3284,7 @@ def inv_adj_onaccept(form):
bin = inv_item.bin,
old_owner_org_id = inv_item.owner_org_id,
new_owner_org_id = inv_item.owner_org_id,
- )
+ )
# ---------------------------------------------------------------------
@staticmethod
View
10 modules/eden/member.py
@@ -338,8 +338,8 @@ def member_onaccept(form):
# Affiliation, record ownership and component ownership
s3db.pr_update_affiliations(mtable, record)
- #auth.s3_set_record_owner(mtable, record, force_update=True)
- #auth.set_component_realm_entity(mtable, record)
+ auth.set_realm_entity(mtable, record, force_update=True)
+ auth.set_component_realm_entity(mtable, record)
# realm_entity for the pr_person record
person_id = record.person_id
@@ -352,9 +352,9 @@ def member_onaccept(form):
auth.set_realm_entity(ptable, person,
entity = entity,
force_update = True)
- #auth.set_component_realm_entity(ptable, person,
- # entity = entity,
- # update_components = [])
+ auth.set_component_realm_entity(ptable, person,
+ entity = entity,
+ update_components = [])
# Update the location ID from the Home Address
View
37 modules/eden/org.py
@@ -1996,25 +1996,24 @@ def org_office_onaccept(form):
# Affiliation, record ownership and component ownership
s3db.pr_update_affiliations(otable, vars)
- #auth.s3_set_record_owner(otable, vars, force_update=True)
- #auth.set_component_realm_entity(otable, vars,
- #update_components = ["contact_emergency",
- #"physical_description",
- #"config",
- #"image",
- #"req",
- #"send",
- #"human_resource_site",
- #"note",
- #"contact",
- #"role",
- #"asset",
- #"commit",
- #"inv_item",
- #"document",
- #"recv",
- #"address",
- #])
+ auth.set_realm_entity(otable, vars, force_update=True)
+ auth.set_component_realm_entity(otable, vars,
+ update_components = ["contact_emergency",
+ "config",
+ "image",
+ "req",
+ "send",
+ "human_resource_site",
+ "note",
+ "contact",
+ "role",
+ "asset",
+ "commit",
+ "inv_item",
+ "document",
+ "recv",
+ "address",
+ ])
if current.deployment_settings.get_org_summary():
View
62 modules/eden/project.py
@@ -534,9 +534,9 @@ def model(self):
cols=report_fields,
facts=report_fields,
defaults=Storage(
- rows="multi_hazard_id",
- cols="countries_id",
- fact="multi_theme_id",
+ rows="project.multi_hazard_id",
+ cols="project.countries_id",
+ fact="project.multi_theme_id",
aggregate="count",
totals=True
)
@@ -753,19 +753,19 @@ def project_project_onaccept(form):
vars = form.vars
# Update asset realm_entity and components' realm_entity
auth.set_realm_entity(ptable, vars, force_update=True)
- #auth.set_component_realm_entity(ptable, vars,
- #update_components = ["human_resource",
- #"task",
- #"organisation",
- #"activity",
- #"annual_budget",
- #"beneficiary",
- #"location",
- #"milestone",
- #"theme_percentage",
- #"document",
- #"image",
- #])
+ auth.set_component_realm_entity(ptable, vars,
+ update_components = ["human_resource",
+ "task",
+ "organisation",
+ "activity",
+ "annual_budget",
+ "beneficiary",
+ "location",
+ "milestone",
+ "theme_percentage",
+ "document",
+ "image",
+ ])
lead_role = current.deployment_settings.get_project_organisation_lead_role()
@@ -1370,9 +1370,9 @@ def model(self):
cols=report_fields,
facts=report_fields,
defaults=Storage(
- rows="L1",
- cols="project_id",
- fact="multi_activity_type_id",
+ rows="location.L1",
+ cols="location.project_id",
+ fact="location.multi_activity_type_id",
aggregate="list",
totals=True
)
@@ -1693,9 +1693,9 @@ def beneficiary_L1_opts():
cols=report_fields,
facts=["number"],
methods=["sum"],
- defaults=Storage( rows="project_id",
- cols="beneficiary_type_id",
- fact="number",
+ defaults=Storage( rows="beneficiary.project_id",
+ cols="beneficiary.beneficiary_type_id",
+ fact="beneficiary.number",
aggregate="sum",
totals=True
)
@@ -1787,9 +1787,9 @@ def beneficiary_L1_opts():
cols = report_fields,
facts = report_fields,
#methods = ["sum"],
- defaults = Storage( rows = "organisation_id",
- cols ="currency",
- fact = "amount",
+ defaults = Storage( rows = "organisation.organisation_id",
+ cols ="organisation.currency",
+ fact = "organisation.amount",
aggregate = "sum",
totals = False
)
@@ -2187,9 +2187,9 @@ def model(self):
cols=report_fields,
facts=report_fields,
defaults=Storage(
- rows="project_id",
- cols="name",
- fact="time_actual",
+ rows="activity.project_id",
+ cols="activity.name",
+ fact="activity.time_actual",
aggregate="sum",
totals=True
)
@@ -3323,9 +3323,9 @@ def model(self):
cols = report_fields,
facts = report_fields,
defaults = Storage(
- rows = "project",
- cols = "person_id",
- fact = "hours",
+ rows = "time.project",
+ cols = "time.person_id",
+ fact = "time.hours",
aggregate = "sum",
totals = True
),
View
77 modules/s3/s3aaa.py
@@ -3716,50 +3716,39 @@ def get_realm_entity(self, table, record, entity=0):
return realm_entity
# -------------------------------------------------------------------------
- #def set_component_realm_entity(self, table, record, entity=0,
- #force_update=True,
- #update_components=[]):
- #"""
- #Update the realm entity for a record and it's components
-
- #@param table: the table
- #@param record: the record (as Row or dict)
- #@param entity: the entity (pe_id)
- #"""
-
- #s3db = current.s3db
-
- #if not entity:
- #entity = self.get_realm_entity(table, record)
-
- ## Find Record Components
- #components = s3db.get_components(table)
-
- ## Update Components
- #for component in update_components:
- #c = components[component]
- #if not c:
- #continue
-
-
- ## @ToDo: Replace with:
- ##join = c.get_join()
- ##query = join & (table._id == record.id)
- ## But this requires a resource
- #if c.linktable:
- #query = (c.linktable[c.lkey] == record.id) & \
- #(c.linktable[c.rkey] == c.table[c.fkey])
- #rows = current.db(query).select(c.table.id)
- #else:
- #rows = (c.table[c.fkey] == record.id)
-
- #self.set_realm_entity(c.table, rows, entity,
- #force_update=force_update)
-
- ## @ToDo: Check if we need to update component Super Links
-
- ## Update Super Links
- #s3db.update_super(table, record)
+ def set_component_realm_entity(self, table, record, entity=0,
+ force_update=True,
+ update_components=[]):
+ """
+ Update the realm entity for a record and it's components
+
+ @param table: the table
+ @param record: the record (as Row or dict)
+ @param entity: the entity (pe_id)
+ """
+
+ s3db = current.s3db
+
+ if not entity:
+ entity = self.get_realm_entity(table, record)
+
+ # Find Record Components
+ resource = s3db.resource(table, components = update_components)
+ components = resource.components
+
+ # Update Components
+ for component in components:
+ c = components[component]
+ if not c:
+ continue
+ query = c.get_join() & (table._id == record.id)
+ rows = current.db(query).select(c.table.id)
+ self.set_realm_entity(c.table, rows, entity,
+ force_update=force_update)
+ # @ToDo: Check if we need to update component Super Links
+
+ # Update Super Links
+ s3db.update_super(table, record)
# -------------------------------------------------------------------------
def update_shared_fields(self, table, record, **data):
View
2  private/templates/IFRC/config.py
@@ -272,7 +272,7 @@ def ifrc_realm_entity(table, row):
# -----------------------------------------------------------------------------
# Request Managemetn
settings.req.req_type = ["Stock"]
-#settings.req.use_commit = False
+settings.req.use_commit = False
#settings.inv.collapse_tabs = True
# =============================================================================
Please sign in to comment.
Something went wrong with that request. Please try again.