def bulk_update_status(self, r, **attr):

        T = current.T
        s3db = current.s3db

        settings = current.deployment_settings
        response = current.response

        output = {"title": T("Update Allowance Status"),
                  }

        status_opts = dict(s3db.dvr_allowance_status_opts)

        # Can not bulk-update from or to status "paid"
        del status_opts[2]

        # Form fields
        formfields = [s3_date("from_date",
                              label = T("Planned From"),
                              set_min = "#allowance_to_date",
                              ),
                      s3_date("to_date",
                              default = "now",
                              label = T("Planned Until"),
                              set_max = "#allowance_from_date",
                              empty = False,
                              ),
                      Field("current_status", "integer",
                            default = 1, # pending
                            label = T("Current Status"),
                            requires = IS_IN_SET(status_opts),
                            ),
                      Field("new_status", "integer",
                            default = 4, # missed
                            label = T("New Status"),
                            requires = IS_IN_SET(status_opts),
                            ),
                      ]

        # Form buttons
        submit_btn = INPUT(_class = "tiny primary button",
                           _name = "submit",
                           _type = "submit",
                           _value = T("Update"),
                           )
        cancel_btn = A(T("Cancel"),
                       _href = r.url(id=None, method=""),
                       _class = "action-lnk",
                       )
        buttons = [submit_btn, cancel_btn]

        # Generate the form and add it to the output
        resourcename = r.resource.name
        formstyle = settings.get_ui_formstyle()
        form = SQLFORM.factory(record = None,
                               showid = False,
                               formstyle = formstyle,
                               table_name = resourcename,
                               buttons = buttons,
                               *formfields)
        output["form"] = form

        # Process the form
        formname = "%s/manage" % resourcename
        if form.accepts(r.post_vars,
                        current.session,
                        formname = formname,
                        onvalidation = self.validate,
                        keepvalues = False,
                        hideerror = False,
                        ):

            formvars = form.vars

            current_status = formvars.current_status
            new_status = formvars.new_status

            table = s3db.dvr_allowance
            query = current.auth.s3_accessible_query("update", table) & \
                    (table.status == current_status) & \
                    (table.deleted != True)
            from_date = formvars.from_date
            if from_date:
                query &= table.date >= from_date
            to_date = formvars.to_date
            if to_date:
                query &= table.date <= to_date

            result = current.db(query).update(status=int(new_status))
            if result:
                response.confirmation = T("%(number)s records updated") % \
                                        {"number": result}
            else:
                response.warning = T("No records found")

        response.view = self._view(r, "update.html")
        return output

    # -------------------------------------------------------------------------
Method to bulk-update status of allowance payments
dataset/ETHPy150Open sahana/eden/modules/s3db/dvr.py/DVRManageAllowance.bulk_update_status