def inv_item():

    # If this url has a viewing track items then redirect to track_movement
    viewing = get_vars.get("viewing", None)
    if viewing:
        tn, id = viewing.split(".", 1)
        if tn == "inv_track_item":
            table = s3db.inv_track_item
            record = db(table.id == id).select(table.item_id,
                                               limitby=(0, 1)).first()
            redirect(URL(c = "inv",
                         f = "track_movement",
                         args = [],
                         vars = {"viewing" : "%s.%s" % ("inv_inv_item", record.item_id)}
                         ))

    tablename = "inv_inv_item"
    # Load model to be able to override CRUD string(s)
    table = s3db[tablename]

    # Limit site_id to sites the user has permissions for
    auth.permitted_facilities(table=table,
                              error_msg=T("You do not have permission for any site to add an inventory item."))

    s3.crud_strings[tablename].msg_list_empty = T("No Stock currently registered")

    report = get_vars.get("report")
    if report == "mon":
            s3.crud_strings[tablename].update(dict(
                title_list = T("Monetization Report"),
                subtitle_list = T("Monetization Details"),
                #msg_list_empty = T("No Stock currently registered"),
              ))
            s3db.configure(tablename,
                           list_fields = ["id",
                                          (T("Donor"), "supply_org_id"),
                                          (T("Items/Description"), "item_id"),
                                          (T("Quantity"), "quantity"),
                                          (T("Unit"), "item_pack_id"),
                                          (T("Unit Value"), "pack_value"),
                                          (T("Total Value"), "total_value"),
                                          (T("Remarks"), "comments"),
                                          "status",
                                          ]
                           )
    else:
        s3db.configure(tablename,
                       insertable = settings.get_inv_direct_stock_edits(),
                       list_fields = ["id",
                                      "site_id",
                                      "item_id",
                                      "item_id$code",
                                      "item_id$item_category_id",
                                      "quantity",
                                      "pack_value",
                                      #(T("Total Value"), "total_value"),
                                      ]
                       )

    if len(request.args) > 1 and request.args[1] == "track_item":
        # remove CRUD generated buttons in the tabs
        s3db.configure("inv_track_item",
                       create=False,
                       listadd=False,
                       editable=False,
                       deletable=False,
                       )
    else:
        s3.filter = (table.quantity != 0)

    def prep(r):
        if r.method != "report":
            s3.dataTable_group = 1
        return True
    s3.prep = prep

    # Import pre-process
    def import_prep(data):
        """
            Deletes all Stock records of the organisation/branch
            before processing a new data import
        """
        resource, tree = data
        xml = current.xml
        tag = xml.TAG
        att = xml.ATTRIBUTE
        if s3.importerReplace:
            if tree is not None:
                root = tree.getroot()
                expr = "/%s/%s[@%s='org_organisation']/%s[@%s='name']" % \
                       (tag.root, tag.resource, att.name, tag.data, att.field)
                orgs = root.xpath(expr)
                otable = s3db.org_organisation
                stable = s3db.org_site
                itable = s3db.inv_inv_item
                for org in orgs:
                    org_name = org.get("value", None) or org.text
                    if org_name:
                        try:
                            org_name = json.loads(xml.xml_decode(org_name))
                        except:
                            pass
                    if org_name:
                        query = (otable.name == org_name) & \
                                (stable.organisation_id == otable.id) & \
                                (itable.site_id == stable.id)
                        resource = s3db.resource("inv_inv_item", filter=query)
                        # Use cascade=True so that the deletion gets
                        # rolled back if the import fails:
                        resource.delete(format="xml", cascade=True)
            resource.skip_import = True
    s3.import_prep = import_prep
    # Upload for configuration (add replace option)
    s3.importerPrep = lambda: dict(ReplaceOption=T("Remove existing data before import"))

    output = s3_rest_controller(#csv_extra_fields = [dict(label="Organisation",
                                #                         field=s3db.org_organisation_id(comment=None))
                                #                    ],
                                pdf_paper_alignment = "Landscape",
                                pdf_table_autogrow = "B",
                                pdf_groupby = "site_id, item_id",
                                pdf_orderby = "expiry_date, supply_org_id",
                                rheader=s3db.inv_rheader,
                                )

    if "add_btn" in output and not settings.get_inv_direct_stock_edits():
        del output["add_btn"]

    return output

# -----------------------------------------------------------------------------
L{UNIXPasswordDatabase} with no arguments has checks the C{pwd} database
dataset/ETHPy150Open sahana/eden/controllers/inv.py/inv_item--crossover with--dataset/ETHPy150Open nlloyd/SubliminalCollaborator/libs/twisted/conch/test/test_checkers.py/UNIXPasswordDatabaseTests.test_defaultCheckers