def model(self):

        db = current.db
        T = current.T
        s3 = current.response.s3

        settings = current.deployment_settings

        crud_strings = s3.crud_strings

        define_table = self.define_table
        configure = self.configure
        add_components = self.add_components
        set_method = self.set_method

        # ---------------------------------------------------------------------
        tablename = "work_job_type"
        define_table(tablename,
                     Field("name",
                           label = T("Title"),
                           requires = IS_NOT_EMPTY(),
                           ),
                     s3_comments(),
                     *s3_meta_fields())

        # CRUD strings
        crud_strings[tablename] = Storage(
            label_create = T("Create Job Type"),
            title_display = T("Job Type Details"),
            title_list = T("Job Types"),
            title_update = T("Edit Job Type"),
            label_list_button = T("List Job Types"),
            msg_record_created = T("Job Type added"),
            msg_record_modified = T("Job Type updated"),
            msg_record_deleted = T("Job Type deleted"),
            msg_list_empty = T("No Job Types currently registered")
        )

        # Reusable field
        represent = S3Represent(lookup=tablename)
        job_type_id = S3ReusableField("job_type_id", "reference %s" % tablename,
                                      label = T("Job Type"),
                                      represent = represent,
                                      requires = IS_EMPTY_OR(IS_ONE_OF(
                                                        db, "work_job_type.id",
                                                        represent,
                                                        )),
                                      sortby = "name",
                                      comment = S3PopupLink(c="work",
                                                            f="job_type",
                                                            tooltip=T("Create a new job type"),
                                                            ),
                                      )

        # ---------------------------------------------------------------------
        # Job Priorities
        #
        job_priority = {1: T("Urgent"),
                        2: T("High"),
                        3: T("Normal"),
                        4: T("Low"),
                        }

        # ---------------------------------------------------------------------
        # Job Statuses
        #
        job_status = (("OPEN", T("Open")),
                      ("STARTED", T("Started")),
                      ("ONHOLD", T("On Hold")),
                      ("COMPLETED", T("Completed")),
                      ("CANCELLED", T("Cancelled")),
                      )

        # ---------------------------------------------------------------------
        # Job
        #
        tablename = "work_job"
        define_table(tablename,
                     job_type_id(),
                     Field("name",
                           label = T("Title"),
                           requires = IS_NOT_EMPTY(),
                           ),
                     Field("details", "text",
                           label = T("Details"),
                           represent = s3_text_represent,
                           ),
                     Field("priority", "integer",
                           default = 3, # normal priority
                           requires = IS_IN_SET(job_priority, zero=None),
                           represent = S3Represent(options=job_priority),
                           ),
                     Field("status",
                           default = "OPEN",
                           requires = IS_IN_SET(job_status, zero=None, sort=False),
                           represent = S3Represent(options=dict(job_status)),
                           ),
                     self.super_link("site_id", "org_site",
                                     label = T("Place"),
                                     orderby = "org_site.name",
                                     readable = True,
                                     writable = True,
                                     represent = self.org_site_represent,
                                     ),
                     s3_datetime("start_date"),
                     Field("duration", "double",
                           label = T("Hours Planned"),
                           requires = IS_EMPTY_OR(IS_FLOAT_IN_RANGE(0, None)),
                           ),
                     Field("workers_min", "integer",
                           default = 1,
                           label = T("Helpers needed"),
                           requires = IS_INT_IN_RANGE(1, None),
                           ),
                     # @todo: onvalidation to check max>=min
                     Field("workers_max", "integer",
                           label = T("Helpers needed (max)"),
                           requires = IS_EMPTY_OR(IS_INT_IN_RANGE(1, None)),
                           ),
                     Field("workers_assigned", "integer",
                           default = 0,
                           label = T("Helpers assigned"),
                           requires = IS_INT_IN_RANGE(0, None),
                           writable = False,
                           ),
                     s3_comments(),
                     *s3_meta_fields())

        # CRUD strings
        crud_strings[tablename] = Storage(
            label_create = T("Create Job"),
            title_display = T("Job Details"),
            title_list = T("Jobs"),
            title_update = T("Edit Job"),
            label_list_button = T("List Jobs"),
            msg_record_created = T("Job added"),
            msg_record_modified = T("Job updated"),
            msg_record_deleted = T("Job deleted"),
            msg_list_empty = T("No Jobs currently registered")
        )

        # Filter widgets
        filter_widgets = [S3TextFilter(["name",
                                        "details",
                                        "job_type_id$name",
                                        "site_id$name",
                                        ],
                                        label = T("Search"),
                                       ),
                          S3OptionsFilter("job_type_id"),
                          S3OptionsFilter("status"),
                          S3OptionsFilter("site_id",
                                          hidden = True,
                                          ),
                          S3DateFilter("start_date",
                                       hidden = True,
                                       ),
                          ]

        # List fields
        list_fields = ["priority",
                       "job_type_id",
                       "name",
                       "site_id",
                       "start_date",
                       "duration",
                       "status",
                       "workers_min",
                       "workers_assigned",
                       ]

        # Table configuration
        configure(tablename,
                  filter_widgets = filter_widgets,
                  list_fields = list_fields,
                  list_layout = work_JobListLayout(),
                  )

        # Custom methods
        set_method("work", "job",
                   method = "signup",
                   action = work_SignUp,
                   )
        set_method("work", "job",
                   method = "cancel",
                   action = work_SignUp,
                   )

        # Components
        add_components(tablename,
                       work_assignment = "job_id",
                       )

        # Reusable field
        represent = S3Represent(lookup=tablename, show_link=True)
        job_id = S3ReusableField("job_id", tablename % "reference %s",
                                 label = T("Job"),
                                 represent = represent,
                                 requires = IS_ONE_OF(db, "work_job.id",
                                                      represent,
                                                      ),
                                 sortby = "name",
                                 comment = S3PopupLink(c="work",
                                                       f="job",
                                                       tooltip=T("Create a new job"),
                                                       ),
                                 )

        # ---------------------------------------------------------------------
        # Linktable person<=>job
        #
        auth = current.auth
        tablename = "work_assignment"
        define_table(tablename,
                     job_id(),
                     self.pr_person_id(),
                     *s3_meta_fields())

        # CRUD strings
        crud_strings[tablename] = Storage(
            label_create = T("Create Assignment"),
            title_display = T("Assignment Details"),
            title_list = T("Assignments"),
            title_update = T("Edit Assignment"),
            label_list_button = T("List Assignments"),
            msg_record_created = T("Assignment added"),
            msg_record_modified = T("Assignment updated"),
            msg_record_deleted = T("Assignment deleted"),
            msg_list_empty = T("No Assignments currently registered")
        )

        # Table configuration
        configure(tablename,
                  onaccept = self.assignment_onaccept,
                  ondelete = self.assignment_ondelete,
                  onvalidation = self.assignment_onvalidation,
                  )

        # ---------------------------------------------------------------------
        # Pass names back to global scope (s3.*)
        return {"work_job_id": job_id,
                }

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