def model(self):

        T = current.T
        configure = self.configure
        define_table = self.define_table
        add_components = self.add_components

        s3 = current.response.s3
        crud_strings = s3.crud_strings

        db = current.db

        # ---------------------------------------------------------------------
        # Bundles
        #
        tablename = "budget_bundle"
        define_table(tablename,
                     Field("name", length=128, notnull=True, unique=True,
                           label = T("Name"),
                           #requires = [IS_NOT_EMPTY(),
                           #            IS_NOT_ONE_OF(db, "%s.name" % tablename),
                           #            ],
                           ),
                     Field("description",
                           label = T("Description"),
                           ),
                     Field("total_unit_cost", "double",
                           default = 0.0,
                           label = T("One time cost"),
                           writable = False,
                           ),
                     Field("total_monthly_cost", "double",
                           default = 0.0,
                           label = T("Recurring cost"),
                           writable = False,
                           ),
                     s3_comments(),
                     *s3_meta_fields())

        # CRUD Strings
        ADD_BUNDLE = T("Create Bundle")
        crud_strings[tablename] = Storage(
            label_create = ADD_BUNDLE,
            title_display = T("Bundle Details"),
            title_list = T("Bundles"),
            title_update = T("Edit Bundle"),
            label_list_button = T("List Bundles"),
            label_delete_button = T("Delete Bundle"),
            msg_record_created = T("Bundle added"),
            msg_record_modified = T("Bundle updated"),
            msg_record_deleted = T("Bundle deleted"),
            msg_list_empty = T("No Bundles currently registered"),
        )

        # Configuration
        configure(tablename,
                  onaccept = self.budget_bundle_onaccept,
                  )

        # Components
        add_components(tablename,
                       # Items
                       budget_item = {"link": "budget_bundle_item",
                                      "joinby": "bundle_id",
                                      "key": "item_id",
                                      "actuate": "link",
                                      },
                       # Kits
                       budget_kit = {"link": "budget_bundle_kit",
                                     "joinby": "bundle_id",
                                     "key": "kit_id",
                                     "actuate": "link",
                                     },
                       )

        # Represent
        budget_bundle_represent = S3Represent(lookup=tablename,
                                             fields=["name"])

        # Reusable Field
        budget_bundle_id = S3ReusableField("bundle_id", tablename % "reference %s",
            label = T("Bundle"),
            ondelete = "RESTRICT",
            represent = budget_bundle_represent,
            requires = IS_ONE_OF(db, "budget_bundle.id",
                                 budget_bundle_represent,
                                 ),
            comment = S3PopupLink(
                c = "budget",
                f = "bundle",
                label = ADD_BUNDLE,
                title = T("Bundle"),
                tooltip = T("You can create a new bundle by clicking link '%s'.") % ADD_BUNDLE
                ),
            )

        # ---------------------------------------------------------------------
        # Bundle<>Kit Many2Many
        #
        tablename = "budget_bundle_kit"
        define_table(tablename,
                     budget_bundle_id(),
                     self.budget_kit_id(),
                     Field("quantity", "integer", notnull=True,
                           default = 1,
                           label = T("Quantity"),
                           requires = IS_NOT_EMPTY(),
                           ),
                     Field("minutes", "integer", notnull=True,
                           default = 0,
                           label = T("Minutes per Month"),
                           requires = IS_NOT_EMPTY(),
                           ),
                     Field("megabytes", "integer", notnull=True,
                           default = 0,
                           label = T("Megabytes per Month"),
                           requires = IS_NOT_EMPTY(),
                           ),
                     *s3_meta_fields())

        # CRUD Strings
        crud_strings[tablename] = Storage(
            label_create = T("Add Kit"),
            title_display = T("Kit Details"),
            title_list = T("Kits"),
            title_update = T("Edit Kit"),
            label_list_button = T("List Kits"),
            label_delete_button = T("Remove Kit"),
            msg_record_created = T("Kit added"),
            msg_record_modified = T("Kit updated"),
            msg_record_deleted = T("Kit removed"),
            msg_list_empty = T("No Kits currently registered in this bundle"),
        )

        # Configuration
        configure(tablename,
                  onaccept = self.budget_bundle_kit_onaccept,
                  ondelete = self.budget_bundle_kit_ondelete,
                  )

        # ---------------------------------------------------------------------
        # Bundle<>Item Many2Many
        #
        tablename = "budget_bundle_item"
        define_table(tablename,
                     budget_bundle_id(),
                     self.budget_item_id(),
                     Field("quantity", "integer", notnull=True,
                           default = 1,
                           requires = IS_NOT_EMPTY(),
                           label = T("Quantity"),
                           ),
                     Field("minutes", "integer", notnull=True,
                           default = 0,
                           requires = IS_NOT_EMPTY(),
                           label = T("Minutes per Month"),
                           ),
                     Field("megabytes", "integer", notnull=True,
                           default = 0,
                           requires = IS_NOT_EMPTY(),
                           label = T("Megabytes per Month"),
                           ),
                     *s3_meta_fields())

        # CRUD Strings
        crud_strings[tablename] = Storage(
            label_create = T("Add Item"),
            title_display = T("Item Details"),
            title_list = T("Items"),
            title_update = T("Edit Item"),
            label_list_button = T("List Items"),
            label_delete_button = T("Remove Item"),
            msg_record_created = T("Item added"),
            msg_record_modified = T("Item updated"),
            msg_record_deleted = T("Item removed"),
            msg_list_empty = T("No Items currently registered in this bundle"),
        )

        # Configuration
        configure(tablename,
                  onaccept = self.budget_bundle_item_onaccept,
                  ondelete = self.budget_bundle_item_ondelete,
                  )

        # ---------------------------------------------------------------------
        # Budget<>Bundle Many2Many
        #
        tablename = "budget_budget_bundle"
        define_table(tablename,
                     # This is a component, so needs to be a super_link
                     # - can't override field name, ondelete or requires
                     self.super_link("budget_entity_id", "budget_entity"),
                     self.budget_location_id(),
                     budget_bundle_id(),
                     Field("quantity", "integer", notnull=True,
                           default = 1,
                           label = T("Quantity"),
                           requires = IS_NOT_EMPTY(),
                           ),
                     Field("months", "integer", notnull=True,
                           default = 3,
                           label = T("Months"),
                           requires = IS_NOT_EMPTY(),
                           ),
                     *s3_meta_fields())

        # CRUD Strings
        crud_strings[tablename] = Storage(
            label_create = T("Add Bundle"),
            title_display = T("Bundle Details"),
            title_list = T("Budget Bundles"),
            title_update = T("Edit Bundle"),
            label_list_button = T("List Bundles"),
            label_delete_button = T("Remove Bundle"),
            msg_record_created = T("Bundle added"),
            msg_record_modified = T("Bundle updated"),
            msg_record_deleted = T("Bundle removed"),
            msg_list_empty = T("No Bundles currently registered in this Budget"),
        )

        # Configuration
        configure(tablename,
                  onaccept = self.budget_budget_bundle_onaccept,
                  ondelete = self.budget_budget_bundle_ondelete,
                  )

        # ---------------------------------------------------------------------
        # Pass names back to global scope (s3.*)
        #
        return dict(budget_bundle_id = budget_bundle_id,
                    )

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3db/budget.py/S3BudgetBundleModel.model/swapped operands of `%`