~erobererunc/sahana-eden/tropo_xforms

« back to all changes in this revision

Viewing changes to models/rms.py

  • Committer: Michael
  • Date: 2010-12-16 13:45:28 UTC
  • mfrom: (1479.1.91 eden)
  • Revision ID: ero@gmail.com-20101216134528-7x3m6m3fk9uc9i69
mergeĀ fromĀ trunk...

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
module = "rms"
8
8
if deployment_settings.has_module(module):
 
9
    # NB Current this module depends on HMS, CR & Project
9
10
 
10
11
    # -------------------------------
11
12
    # Load lists/dictionaries for drop down menus
48
49
                            Field("datetime", "datetime"),  # 'timestamp' is a reserved word in Postgres
49
50
                            location_id(),
50
51
                            person_id("requestor_person_id"),
51
 
                            hospital_id(),    # @ToDo Check if the module is enabled for adding FK: check CR for an example
52
 
                            shelter_id(),     # @ToDo Check if the module is enabled for adding FK: check CR for an example
 
52
                            hospital_id(),    # @ToDo: Check if the HMS module is enabled for adding FK: check CR for an example
 
53
                            shelter_id(),     # @ToDo: Check if the CR module is enabled for adding FK: check CR for an example
53
54
                            organisation_id(),
54
55
                            inventory_store_id("from_inventory_store_id"),
55
56
                            Field("type", "integer"),
56
57
                            Field("priority", "integer"),
57
58
                            Field("message", "text"),
58
 
                            activity_id(),
 
59
                            activity_id(),     # @ToDo: Check if the Project module is enabled for adding FK: check CR for an example
59
60
                            #Field("verified", "boolean"),
60
61
                            #Field("verified_details"),
61
62
                            #Field("actionable", "boolean"),
218
219
                wc = "%"
219
220
                _l = "%s%s%s" % (wc, l, wc)
220
221
 
 
222
                # We want to do case-insensitive searches
 
223
                # (default anyway on MySQL/SQLite, but not PostgreSQL)
 
224
                _l = _l.lower()
 
225
 
221
226
                # build query
222
227
                for f in search_fields:
223
228
                    if query:
224
 
                        query = (db.rms_req[f].like(_l)) | query
 
229
                        query = (db.rms_req[f].lower().like(_l)) | query
225
230
                    else:
226
 
                        query = (db.rms_req[f].like(_l))
 
231
                        query = (db.rms_req[f].lower().like(_l))
227
232
 
228
233
                # undeleted records only
229
234
                query = (db.rms_req.deleted == False) & (query)
339
344
    tablename = "%s_%s" % (module, resourcename)
340
345
    table = db.define_table(tablename,
341
346
                            request_id(),
342
 
                            item_id(),
 
347
                            item_id(empty=False),
343
348
                            Field("quantity", "double"),
344
349
                            comments(),
345
350
                            migrate=migrate, *s3_meta_fields())
346
 
 
347
351
    # CRUD strings
348
352
    ADD_REQUEST_ITEM = T("Add Request Item")
349
353
    LIST_REQUEST_ITEMS = T("List Request Items")
363
367
        msg_record_deleted = T("Request Item deleted"),
364
368
        msg_list_empty = T("No Items currently requested"))
365
369
 
 
370
    table.item_id.requires = IS_ONE_OF(db, "supply_item.id", "%(name)s") 
 
371
    #table.quantity.requires = IS_NOT_EMPTY() 
 
372
 
366
373
    # Items as component of Locations
367
374
    s3xrc.model.add_component(module, resourcename,
368
375
                              multiple=True,