def _check_dates(self):
     start_date = fields.Date.from_string(self.start_date)
     end_date = fields.Date.from_string(self.end_date)
     if end_date < start_date:
         raise ValidationError('End Date cannot be set before Start Date.')
     elif end_date > (start_date + timedelta(days=6)):
         raise ValidationError("Select date range for a week!")
 def _check_date_time(self):
     if self.start_time < 0 or self.end_time < 0:
         raise ValidationError("Enter proper Time.")
     elif self.start_time > 24 or self.end_time > 24:
         raise ValidationError("Time can't be greater than 24 hours.")
     elif self.start_time >= self.end_time:
         raise ValidationError(
             'End Time cannot be set before or equal to Start Time.')
Exemple #3
0
    def _check_admission_register(self):
        if self.course_from_id == self.course_to_id:
            raise ValidationError("From Course must not be same as To Course!")

        if self.course_from_id.parent_id:
            if self.course_from_id.parent_id != \
                    self.course_to_id.parent_id:
                raise ValidationError(
                    "Can't migrate, As selected courses don't \
                    share same parent course!")
        else:
            raise ValidationError("Can't migrate, Proceed for new admission")
Exemple #4
0
 def _check_admission_register(self):
     start_date = fields.Date.from_string(self.register_id.start_date)
     end_date = fields.Date.from_string(self.register_id.end_date)
     application_date = fields.Date.from_string(self.application_date)
     if application_date < start_date or application_date > end_date:
         raise ValidationError(
             "Application Date should be between Start Date & \
             End Date of Admission Register.")
Exemple #5
0
 def create(self, cr, uid, vals, context=None):
     if not vals:
         raise ValidationError(
             _("""You are trying to create a product without values"""))
     if ('name' in vals):
         if not vals['name']:
             return False
         existingIDs = self.search(cr,
                                   uid, [('name', '=', vals['name'])],
                                   order='engineering_revision',
                                   context=context)
         if 'engineering_code' in vals:
             if vals['engineering_code'] == False:
                 vals['engineering_code'] = vals['name']
         else:
             vals['engineering_code'] = vals['name']
         if existingIDs:
             existingID = existingIDs[len(existingIDs) - 1]
             if ('engineering_revision' in vals):
                 existObj = self.browse(cr,
                                        uid,
                                        existingID,
                                        context=context)
                 if existObj:
                     if vals['engineering_revision'] > existObj.engineering_revision:
                         vals['name'] = existObj.name
                     else:
                         return existingID
             else:
                 return existingID
     try:
         return super(plm_component, self).create(cr,
                                                  uid,
                                                  vals,
                                                  context=context)
     except Exception, ex:
         import psycopg2
         if isinstance(ex, psycopg2.IntegrityError):
             raise ex
         raise ValidationError(
             _(" (%r). It has tried to create with values : (%r).") %
             (ex, vals))
Exemple #6
0
 def print_report(self):
     start_date = fields.Date.from_string(self.start_date)
     end_date = fields.Date.from_string(self.end_date)
     if start_date > end_date:
         raise ValidationError("End Date cannot be set before Start Date.")
     else:
         data = self.read(['course_id', 'start_date', 'end_date'])[0]
         return self.env['report'].get_action(
             self,
             'openeducat_admission.report_admission_analysis',
             data=data)
Exemple #7
0
 def get_barcode(self, type, value, width=350, height=60, hr=1):
     """ genrating image for barcode """
     options = {}
     if width:
         options['width'] = width
     if height:
         options['height'] = height
     if hr:
         options['humanReadable'] = hr
     try:
         ret_val = createBarcodeDrawing(type, value=str(value), **options)
     except Exception, e:
         raise ValidationError('Error in barcode generation', e)
Exemple #8
0
    def enroll_student(self):
        total_admission = self.env['op.admission'].search_count([
            ('register_id', '=', self.register_id.id), ('state', '=', 'done')
        ])
        if self.register_id.max_count:
            if not total_admission < self.register_id.max_count:
                msg = 'Max Admission In Admission Register :- (%s)' % (
                    self.register_id.max_count)
                raise ValidationError(msg)

        vals = self.get_student_vals()
        vals.update({'partner_id': self.partner_id.id})
        self.write({
            'nbr': 1,
            'state': 'done',
            'admission_date': fields.Date.today(),
            'student_id': self.env['op.student'].create(vals).id,
        })
Exemple #9
0
 def _check_birthdate(self):
     if self.birth_date > fields.Date.today():
         raise ValidationError(
             "Birth Date can't be greater than current date!")
Exemple #10
0
 def _check_marks(self):
     if (self.total_marks < 0.0) or (self.total_per < 0.0):
         raise ValidationError("Enter proper marks or percentage!")
Exemple #11
0
 def _check_date_time(self):
     if self.start_time > self.end_time:
         raise ValidationError('End Time cannot be set before Start Time.')
Exemple #12
0
 def _check_marks(self):
     if self.total_marks <= 0.0 or self.min_marks <= 0.0:
         raise ValidationError('Enter proper marks!')
     if self.min_marks > self.total_marks:
         raise ValidationError(
             "Passing Marks can't be greater than Total Marks")
Exemple #13
0
 def check_quantity(self):
     if self.quantity <= 0.0:
         raise ValidationError("Enter proper Quantity in Facilities!")
Exemple #14
0
 def check_dates(self):
     issued_date = fields.Date.from_string(self.issued_date)
     submission_date = fields.Date.from_string(self.submission_date)
     if issued_date > submission_date:
         raise ValidationError(
             "Submission Date cannot be set before Issue Date.")
Exemple #15
0
 def check_capacity(self):
     if self.students_per_room <= 0:
         raise ValidationError("Enter proper Student Per Room")
 def check_no_of_admission(self):
     if (self.min_count < 0) or (self.max_count < 0):
         raise ValidationError("No of Admission should be positive!")
     if self.min_count > self.max_count:
         raise ValidationError(
             "Min Admission can't be greater than Max Admission")
Exemple #17
0
 def check_details(self):
     if self.allow_book < 0 or self.duration < 0.0 or \
             self.penalty_amt_per_day < 0.0:
         raise ValidationError('Enter proper value')
Exemple #18
0
 def _check_student_capacity(self):
     if len(self.student_ids) > self.students_per_room:
         raise ValidationError('Room capacity Over')
Exemple #19
0
 def _check_date(self):
     if self.issued_date > self.return_date:
         raise ValidationError(
             'Return Date cannot be set before Issued Date.')
Exemple #20
0
 def _check_marks(self):
     if self.marks < 0.0:
         raise ValidationError("Enter proper marks!")
Exemple #21
0
 def check_capacity(self):
     if self.capacity <= 0:
         raise ValidationError('Enter proper Capacity.')
Exemple #22
0
 def check_capacity(self):
     if self.capacity < 0:
         raise ValidationError('Enter proper Capacity')
     elif self.capacity > self.classroom_id.capacity:
         raise ValidationError('Capacity over Classroom capacity!')
Exemple #23
0
 def _check_date(self):
     if self.date_from > self.date_to:
         raise ValidationError('To Date cannot be set before From Date.')
 def check_amount(self):
     if self.amount <= 0:
         raise ValidationError('Enter proper Amount')
 def check_dates(self):
     start_date = fields.Date.from_string(self.start_date)
     end_date = fields.Date.from_string(self.end_date)
     if start_date > end_date:
         raise ValidationError("End Date cannot be set before Start Date.")
Exemple #26
0
 def _check_date_time(self):
     if self.start_date > self.end_date:
         raise ValidationError(
             'End Date cannot be set before Start Date.')
Exemple #27
0
 def _check_marks(self):
     if (self.total_pass < 0.0) or (self.total_failed < 0.0):
         raise ValidationError('Enter proper pass or fail!')
Exemple #28
0
 def _check_marks(self):
     if (self.marks < 0.0) or (self.per < 0.0) or \
             (self.total_marks < 0.0) or (self.per > 100.0):
         raise ValidationError("Enter proper Marks or Percentage!")
     elif self.marks > self.total_marks:
         raise ValidationError("Marks can't be greater than Total Marks")
Exemple #29
0
    def extract_data(self, model, **kwargs):

        data = {
            'record': {},        # Values to create record
            'attachments': [],  # Attached files
            'custom': '',        # Custom fields values
        }

        authorized_fields = model.sudo()._get_form_writable_fields()
        error_fields = []

        for field_name, field_value in kwargs.items():
            # If the value of the field if a file
            if hasattr(field_value, 'filename'):
                # Undo file upload field name indexing
                field_name = field_name.rsplit('[', 1)[0]

                # If it's an actual binary field, convert the input file
                # If it's not, we'll use attachments instead
                if field_name in authorized_fields and authorized_fields[field_name]['type'] == 'binary':
                    data['record'][field_name] = base64.b64encode(field_value.read())
                else:
                    field_value.field_name = field_name
                    data['attachments'].append(field_value)

            # If it's a known field
            elif field_name in authorized_fields:
                try:
                    input_filter = self._input_filters[authorized_fields[field_name]['type']]
                    data['record'][field_name] = input_filter(self, field_name, field_value)
                except ValueError:
                    error_fields.append(field_name)

            # If it's a custom field
            elif field_name != 'context':
                data['custom'] += "%s : %s\n" % (field_name.decode('utf-8'), field_value)

        # Add metadata if enabled
        environ = request.httprequest.headers.environ
        if(request.website.website_form_enable_metadata):
            data['meta'] += "%s : %s\n%s : %s\n%s : %s\n%s : %s\n" % (
                "IP"                , environ.get("REMOTE_ADDR"),
                "USER_AGENT"        , environ.get("HTTP_USER_AGENT"),
                "ACCEPT_LANGUAGE"   , environ.get("HTTP_ACCEPT_LANGUAGE"),
                "REFERER"           , environ.get("HTTP_REFERER")
            )

        # This function can be defined on any model to provide
        # a model-specific filtering of the record values
        # Example:
        # def website_form_input_filter(self, values):
        #     values['name'] = '%s\'s Application' % values['partner_name']
        #     return values
        dest_model = request.env[model.model]
        if hasattr(dest_model, "website_form_input_filter"):
            data['record'] = dest_model.website_form_input_filter(request, data['record'])

        missing_required_fields = [label for label, field in authorized_fields.iteritems() if field['required'] and not label in data['record']]
        if any(error_fields):
            raise ValidationError(error_fields + missing_required_fields)

        return data
Exemple #30
0
 def check_height_weight(self):
     if self.height <= 0.0 or self.weight <= 0.0:
         raise ValidationError("Enter proper height and weight!")