Exemplo n.º 1
0
    def write(self, vals):
        ir_attachment = self.env['ir.attachment']
        if 'employee_id' in vals and vals['employee_id']:
            employee_id = vals['employee_id']
        else:
            employee_id = self.employee_id.id

        if 'visa_issue_date' in vals and vals['visa_issue_date']:
            visa_issue_date = vals['visa_issue_date']
        else:
            visa_issue_date = self.visa_issue_date
        if 'visa_expiry_date' in vals and vals['visa_expiry_date']:
            visa_expiry_date = vals['visa_expiry_date']
        else:
            visa_expiry_date = self.visa_expiry_date
        if visa_expiry_date != False:
            if visa_expiry_date < visa_issue_date:
                raise except_orm(
                    _('Warning!'),
                    _("Please select expiry date after issue date (%s)") %
                    (visa_issue_date, ))

        if 'visa_file_name' in vals and vals['visa_file_name']:
            if not 'visa_attachment' in vals:
                raise except_orm(_('Warning!'), _("Please attach visa copy"))
            elif 'visa_attachment' in vals:
                visa_attachment = vals['visa_attachment']
                if visa_attachment:
                    ir_attachment.sudo().create({
                        'name':
                        vals['visa_file_name'],
                        'res_model':
                        'hr.employee',
                        'res_id':
                        employee_id,
                        'datas':
                        visa_attachment,
                        'type':
                        'binary',
                        'datas_fname':
                        vals['visa_file_name'],
                    })
                    ir_attachment.sudo().create({
                        'name':
                        vals['visa_file_name'],
                        'datas_fname':
                        vals['visa_file_name'],
                        'res_model':
                        'visa.details',
                        'res_id':
                        self.id,
                        'datas':
                        visa_attachment,
                        'type':
                        'binary'
                    })
                    vals['visa_attachment'] = None
                    vals['visa_flag'] = True

        return super(visa_details, self).write(vals)
Exemplo n.º 2
0
    def write(self, vals):
        course_obj = self.env['course']
        batch_obj = self.env['batch']

        if 'class_id' in vals or 'promote_to_class' in vals:
            if 'class_id' not in vals:  
                vals['class_id']=self.class_id.id
            if 'promote_to_class'not in vals:
                vals['promote_to_class'] = self.promote_to_class.id
                
            if vals['class_id'] or vals['promote_to_class']:
                course_brw = course_obj.browse(vals['class_id'])
                if course_brw.is_last_course:
                    raise except_orm(_('Warning!'), _("You cannot proceed with promotion process for %s!") % course_brw.name)
                if not course_brw.next_course:
                    raise except_orm(_('Warning!'), _("Next course is not defined!"))
                if course_obj.browse(vals['promote_to_class']).name != course_brw.next_course:
                    raise except_orm(_('Warning!'), _("Promote to class can not be equal to or lower than current class!!"))
                
        if 'batch_id' in vals or 'promote_to_batch' in vals:
            if 'batch_id' not in vals:  
                vals['batch_id']=self.batch_id.id
            if 'promote_to_batch'not in vals:
                vals['promote_to_batch']=self.promote_to_batch.id
                
            if vals['batch_id'] and vals['promote_to_batch']:
                batch_brw = batch_obj.browse(vals['batch_id'])
                if not batch_brw.next_batch:
                    raise except_orm(_('Warning!'), _("Next batch is not defined!"))
                if batch_obj.browse(vals['promote_to_batch']).name != batch_brw.next_batch:
                    raise except_orm(_('Warning!'), _("Promote to batch can not be equal to or lower than current batch!!"))
        return super(promote_student, self).write(vals)
Exemplo n.º 3
0
    def post_cheque(self):
        pdc = self.env['pdc.detail']

        active_ids = self._context['active_ids']
        for active_id in active_ids:
            chk = pdc.browse(active_id)
            #chk.journal_id = self.journal_id
            chk.bank_payment_name = self.bank_name.id
            if chk.state != 'draft':
                raise except_orm(_('Warning!'),
                                 _("You can post only draft cheque"))
            if chk.chk_fee_type == 'reg':
                if chk.journal_entry_id and chk.journal_entry_id.id:
                    #chk.journal_entry_id.button_validate()
                    chk.state = 'posted'
            elif chk.chk_fee_type == 'academic':
                if not chk.voucher_id:
                    raise except_orm(_('Warning!'),
                                     _("No payment linked with this Check"))
                #chk.voucher_id.move_id.button_validate()
                chk.state = 'posted'
            else:
                if chk.journal_entry_id and chk.journal_entry_id.id:
                    #chk.journal_entry_id.button_validate()
                    chk.state = 'posted'
        return True
Exemplo n.º 4
0
    def generate_payable_fee_recs(self, flag):
        """
        this method used when student pay Academy fee manualy.
        after fee pay fee status will be changed as
        academy fee unpaid to fee paid.
        ------------------------------------------
        @param self : object pointer
        """
        sequence = 1
        if self.fee_structure_confirm != True:
            raise except_orm(
                _("Warning!"),
                _('Please Confirm the fee structure before paying fee'))
        stud_payble_obj = self.env['student.payble.fee']

        if self.student_id:
            stud_payble_val = {}
            if self.fee_computation_ids:
                for fee_computation_line_rec in self.fee_computation_ids[
                        0].fee_computation_line_ids:
                    if not fee_computation_line_rec.name.property_account_income_id.id:
                        raise except_orm(
                            _("Warning!"),
                            _('Please define property income account for fees %s'
                              ) % fee_computation_line_rec.name.name)
                    stud_payble_rec = stud_payble_obj.search_count([
                        ('month_id', '=',
                         self.fee_computation_ids[0].month_id.id),
                        ('name', '=', fee_computation_line_rec.name.id),
                        ('fee_pay_type', '=',
                         fee_computation_line_rec.fee_payment_type_id.id),
                        ('student_id', '=', self.student_id.id)
                    ])
                    if stud_payble_rec == 0:
                        stud_payble_val = {
                            'name':
                            fee_computation_line_rec.name.id,
                            'student_id':
                            self.student_id.id,
                            'month_id':
                            self.fee_computation_ids[0].month_id.id,
                            'fee_pay_type':
                            fee_computation_line_rec.fee_payment_type_id.id,
                            'cal_amount':
                            0,
                            'total_amount':
                            fee_computation_line_rec.payable_amount,
                            'discount_amount':
                            0,
                        }
                        stud_payble_obj.create(stud_payble_val)
            else:
                raise except_orm(_("Warning!"),
                                 _('Fee computation does not exists'))

        else:
            raise except_orm(_("Warning!"), _('Student Not Found'))
Exemplo n.º 5
0
 def onchange_class(self):
     course_obj = self.env['course']
     if self.class_id:
         if self.class_id.is_last_course:
             raise except_orm(_('Warning!'), _("You cannot proceed with promotion process for %s!")
                              %self.class_id.name)
         if not self.class_id.is_last_course and not self.class_id.next_course:
             raise except_orm(_('Warning!'), _("Next course is not defined!"))
         self.promote_to_class = self.class_id.next_course.id
Exemplo n.º 6
0
    def resend_mail_for_payfort_payment(self,parent,total_amount,order_id,table_date,advance_table,\
                                        voucher,advance_amt,invoice_amt):
        print '==========resend mail for payfort payment==========='
        
                                        
        active_payforts=self.env['payfort.config'].search([('active','=','True')])
        if not active_payforts:
            raise except_orm(_('Warning!'),
            _("Please create Payfort Details First!") )

        if len(active_payforts) > 1:
            raise except_orm(_('Warning!'),
            _("There should be only one payfort record!"))
        charge = 0.0
        payable_amount = total_amount
        if active_payforts.id:
            
            advance_amt += parent.advance_total_recivable + parent.re_reg_total_recivable
            parent_total_recivable = 0.0
            if parent.advance_total_recivable == False and parent.re_reg_total_recivable == False:
                parent_total_recivable = 0.0
            elif parent.advance_total_recivable > 0.0 or parent.re_reg_total_recivable > 0.0:
                parent_total_recivable = parent.advance_total_recivable  + parent.re_reg_total_recivable

             
            if (len(active_payforts) > 1):

                link= link = '/redirect/payment?AMOUNT=%s&ORDERID=%s'%(payable_amount,voucher.voucher_number)

                email_server = self.env['ir.mail_server']
                email_sender = email_server.search([], limit=1)
                ir_model_data = self.env['ir.model.data']
                template_id = ir_model_data.get_object_reference('edsys_edu_fee', 'email_template_academic_fee_payment_reminder')[1]
                template_rec = self.env['mail.template'].browse(template_id)
                body_html = template_rec.body_html
                body_dynamic_html = template_rec.body_html + '<p>Pending Invoice Details:</p>'
                body_dynamic_html += '<table border=%s>'%(2)
                body_dynamic_html += '<tr><td><b>Child Name</b></td><td><b>Invoice number</b></td><td><b>Invoice date</b></td><td><b>Invoice amount</b></td><td><b>Pending amount</b></td></tr>%s'%(table_date)
                body_dynamic_html += '<tr><td><b>Total</b></td><td></td><td></td><td></td><td><b>%s</b></td></tr></table><br/>'%(invoice_amt)
                body_dynamic_html += 'Total advances (if any):<br/>'
                body_dynamic_html += '<table border=%s>'%(2)
                body_dynamic_html += '<tr><td><b>Parent Code</b></td><td><b>Student</b></td><td><b>Advance Value</b></td></tr>%s'%(advance_table)
                body_dynamic_html += '<tr><td>%s</td><td></td><td>%s</td></tr>'%(parent.parent1_id,parent_total_recivable)
                body_dynamic_html += '<tr><td><b>Total advances</b></td><td></td><td><b>%s</b></td></tr></table>'%(advance_amt)
                body_dynamic_html += '<p>Total outstanding payment is AED %s</p></div>'%(payable_amount)
                body_dynamic_html += '<p><a href=%s><button>Click Here</button>to pay Fee</a></p></div>'%(link)
                template_rec.write({'email_from': email_sender.smtp_user,
                                    'email_to': parent.parents_email,
                                    'email_cc': '',
                                    'body_html': body_dynamic_html})
                template_rec.send_mail(voucher.id)
                template_rec.body_html = body_html
Exemplo n.º 7
0
    def send_re_registration_payment_link(self, parent_record,
                                          child_data_table):
        """
        this method is use to send mail to parent for pay
        re-registration fee.
        :param parent_record: re-registration parent record set
        :param amount: total payable amount
        :return:
        """
        active_payforts = self.env['payfort.config'].search([('active', '=',
                                                              'True')])

        if not active_payforts:
            raise except_orm(_('Warning!'),
                             _("Please create Payfort Details First!"))
        elif len(active_payforts) > 1:
            raise except_orm(_('Warning!'),
                             _("There should be only one payfort record!"))

        amount = parent_record.residual
        total_amount = int(amount)
        link = '/redirect/payment?AMOUNT=%s&ORDERID=%s' % (
            total_amount, parent_record.re_registration_number)
        link_data = ''
        if total_amount > 0.00:
            link_data += '<p><a href=%s><button>Click here</button></a> to pay online</a></p>' % (
                link)

        email_server = self.env['ir.mail_server']
        email_sender = email_server.search([], limit=1)
        ir_model_data = self.env['ir.model.data']
        template_id = ir_model_data.get_object_reference(
            'edsys_edu_re_registration',
            'email_template_re_registration_confirmation')[1]
        template_rec = self.env['mail.template'].browse(template_id)
        body_html = template_rec.body_html
        body_dynamic_html = template_rec.body_html
        body_dynamic_html += '<table border=1><tr><td><b>Student Name</b></td><td><b>Class-Sec</b></td><td><b>Re-registration confirmation</b></td><td><b>Amount for re-registration</b></td></tr>%s</table>' % (
            child_data_table)
        body_dynamic_html += '<p>The total payable amount is AED %s(plus applicable online transaction charges)</p>' % (
            total_amount)
        body_dynamic_html += '%s</div>' % (link_data)
        template_rec.write({
            'email_to': parent_record.name.parents_email,
            'email_from': email_sender.smtp_user,
            'email_cc': '',
            'body_html': body_dynamic_html
        })
        template_rec.send_mail(self.id, force_send=True)
        template_rec.body_html = body_html
Exemplo n.º 8
0
 def _get_journal(self):
     """
     get Payment Method
     -------------------
     :return:
     """
     active_payforts_rec = self.env['payfort.config'].sudo().search([('active', '=', 'True')])
     if len(active_payforts_rec) == 1:
         if active_payforts_rec.journal_id.id:
             return active_payforts_rec.journal_id
         else:
             raise except_orm(_('Warning!'),_("Please set payment method for Payfort ! "))
     else:
         raise except_orm(_('Warning!'),_("Please set Payfort Configration ! "))
Exemplo n.º 9
0
 def send_tc_form_request(self):
     """
     This method is use to select multiple student and create record for TC Process,
     also send mail for TC Form
     ------------------------------------------------------------------------------
     :return:
     """
     tc_obj = self.env['trensfer.certificate']
     for student_rec in self.student_ids:
         tc_ex_rec = tc_obj.search([('name', '=', student_rec.id)])
         if tc_ex_rec.id:
             raise except_orm(
                 _('Warning!'),
                 _("The TC process has already been initiated for %s!") %
                 (student_rec.name))
         tc_data = {
             'student_id': student_rec.student_id,
             'name': student_rec.id,
             'reg_no': student_rec.reg_no,
             'batch_id': student_rec.batch_id.id,
             'course_id': student_rec.course_id.id,
             'student_section_id': student_rec.student_section_id.id,
             'state': 'tc_requested'
         }
         tc_rec = tc_obj.create(tc_data)
         tc_rec.send_mail_for_tc_form()
Exemplo n.º 10
0
 def send_payfort_acd_pay_link_computation(self):
     """
     this method used to send payfort link for
     online payment of student acd fee.
     ------------------------------------------
     @param self : object pointer
     @net_amount : calculated amount
     @dis_amount : discount amount on calculated amount
     @total_net_amount : total calculated amount - total discount
     """
     amount_on_link = 0.00
     if self._context.has_key('flag') and self._context.get('flag') == True:
         if self.fee_structure_confirm != True:
             raise except_orm(
                 _("Warning!"),
                 _('Please Confirm the fee structure before sending payment link.'
                   ))
         if self.invoice_id:
             order_id = self.invoice_id.invoice_number
             amount_on_link = self.invoice_id.residual
         elif self.next_year_advance_fee_id:
             order_id = self.next_year_advance_fee_id.order_id
             amount_on_link = self.next_year_advance_fee_id.residual
     else:
         if self.batch_id.current_academic != True:
             # create NYAF if not current academic year
             get_record = self.send_payfort_acd_for_next_year_computation()
             self.next_year_advance_fee_id = get_record.id
             order_id = get_record.order_id
         # generate payble fee records
         payable_fee_recs = self.generate_payable_fee_recs(True)
Exemplo n.º 11
0
 def write(self, vals):
     """
     override write method and
     add validation on write record.
     -------------------------------
     :param vals: dictonary
     :return:
     """
     if 'start_date' not in vals:
         vals['start_date'] = self.start_date
     if 'end_date' not in vals:
         vals['end_date'] = self.end_date
     prev_records = self.search([
         '|', '&', ('start_date', '<=', vals['start_date']),
         ('end_date', '>=', vals['start_date']), '&',
         ('start_date', '<=', vals['end_date']),
         ('end_date', '>=', vals['end_date'])
     ])
     for each in prev_records:
         if each.id != self.id:
             raise except_orm(
                 _("Warning...You are selecting a wrong duration!"),
                 _('This duration is already comes under another academic year'
                   ))
     return super(Batch, self).write(vals)
Exemplo n.º 12
0
 def confirm_labour_card_details(self):
     self.confirm = True
     if self.labour_card_status == 'completed' and not self.labour_card_file_name:
         raise except_orm(_('Warning!'),
                          _("Please attach labour card document"))
     hr_vals = {
         'pro_labour_card_status': self.labour_card_status,
         'pro_labour_card_no': self.permit_card_no,
         'pro_labour_card_start_date': self.permit_issue_date,
         'pro_permit_expiry_date': self.permit_expiry_date,
         'pro_labour_card_file_name': self.labour_card_file_name,
         'pro_labour_card_attachment': self.labour_card_attachment,
         'pro_labour_card_remark': self.labour_remark,
     }
     self.employee_id.write(hr_vals)
     self.flag_cancelled = True
     email_to = self.employee_id.hr_person.email_id
     email_server = self.env['ir.mail_server']
     email_sender = email_server.search([])[0]
     ir_model_data = self.env['ir.model.data']
     template_id = ir_model_data.get_object_reference(
         'edsys_hrm', 'email_template_for_labour_cancellation')[1]
     template_rec = self.env['email.template'].browse(template_id)
     temp = template_rec.write({
         'email_to': email_to,
         'email_from': email_sender.smtp_user
     })
     template_rec.send_mail(self.id, force_send=True)
Exemplo n.º 13
0
 def create(self, vals):
     context = self.env.context
     if 'search_default_state' not in context:
         is_warning = False
         if 'invoice_type' in context:
             if context['invoice_type'] == 'out_refund':
                 is_warning = False
             else:
                 is_warning = True
         if is_warning:
             registration_obj = self.env['registration']
             account_invoice_obj = self.env['account.invoice']
             student_id = vals['partner_id']
             account_invoice_rec = False
             month = False
             if student_id:
                 registration_rec = registration_obj.search([
                     ('student_id', '=', student_id)
                 ])
                 if registration_rec.student_id.fee_computation_ids:
                     #if registration_rec.fee_status == 'academy_fee_unpaid' or registration_rec.fee_status == 'academy_fee_partial_pay' :
                     if registration_rec.student_id.fee_computation_ids[
                             0].status == 'invoice_raised' and registration_rec.fee_status == 'academy_fee_partial_pay':
                         raise except_orm(
                             _("Warning!"),
                             _('Selected student have some partial paid entries in awaiting fee tab'
                               ))
     #raise except_orm(_("Warning!"), _('stop'))
     return super(AccountVoucher, self).create(vals)
Exemplo n.º 14
0
 def resend_tc_form_link(self):
     """
     this method is use to resend request for
     TC form link.
     :return:
     """
     active_ids = self._context['active_ids']
     tc_obj = self.env['trensfer.certificate']
     for tc_student_rec in tc_obj.browse(active_ids):
         if tc_student_rec.tc_form_filled == True:
             raise except_orm(
                 _("Warning!"),
                 _(' Already Transfer Certificate form is filled by the student %s.'
                   ) % (tc_student_rec.name.name))
         if tc_student_rec.tc_form_filled != True:
             email_server = self.env['ir.mail_server']
             email_sender = email_server.search([])
             ir_model_data = self.env['ir.model.data']
             template_id = ir_model_data.get_object_reference(
                 'edsys_transfer_certificate',
                 'email_template_resend_tc_form_email')[1]
             template_rec = self.env['mail.template'].browse(template_id)
             template_rec.write({
                 'email_to':
                 tc_student_rec.name.parents1_id.parents_email,
                 'email_from':
                 email_sender.smtp_user,
                 'email_cc':
                 ''
             })
             template_rec.send_mail(tc_student_rec.id, force_send=True)
             tc_student_rec.write({
                 'last_date_of_tc_request_form':
                 datetime.now(),
             })
Exemplo n.º 15
0
    def default_get(self, fields):
        total_amount = 0.00
        dis_amount = 0.00
        res = super(show_fee_wiz, self).default_get(fields)
        active_id = self._context['active_id']
        brw_reg = self.env['registration'].browse(active_id)
        if brw_reg.fee_status == 'reg_fee_pay':
            raise except_orm(_("Warning!"),
                             _('Registration fees are already paid!'))
        elif brw_reg.fee_status == 'academy_fee_pay':
            raise except_orm(_("Warning!"),
                             _('Academic fees are already paid!'))
        if brw_reg.state == 'reg':
            amount = 0
            for each in brw_reg.reg_fee_line:
                amount = amount + each.amount
            res['total_fee'] = amount
            res['label_change'] = False

        if brw_reg.state == 'awaiting_fee':

            if brw_reg.fee_structure_confirm != True:
                raise except_orm(
                    _("Warning!"),
                    _('Please Confirm the fee structure before paying fee'))

            if not brw_reg.invoice_id:
                if not brw_reg.next_year_advance_fee_id:
                    if brw_reg.fee_computation_ids:
                        res['total_fee'] = brw_reg.fee_computation_ids[
                            0].invoice_amount
                        res['total_remaining'] = brw_reg.fee_computation_ids[
                            0].invoice_amount
                        res['label_change'] = True
                else:
                    if brw_reg.next_year_advance_fee_id.residual > 0:
                        res['total_fee'] = brw_reg.next_year_advance_fee_id.residual
                        res['label_change'] = True
                        res['total_remaining'] = brw_reg.next_year_advance_fee_id.residual
                    else:
                        brw_reg.next_year_advance_fee_id.state = 'fee_paid'
                        brw_reg.fee_status = 'academy_fee_pay'
            else:
                res['total_fee'] = brw_reg.invoice_id.residual
                res['label_change'] = True
                res['total_remaining'] = brw_reg.invoice_id.residual
        return res
Exemplo n.º 16
0
    def come_tc_expected_to_waiting_fee(self):
        fees_structure_obj = self.env['fees.structure']
        child_data_table = ''
        for re_reg_stud_rec in self:
            fee_line_id_list = []
            fee_record = fees_structure_obj.search(
                [('academic_year_id', '=',
                  re_reg_stud_rec.next_year_batch_id.id),
                 ('course_id', '=', re_reg_stud_rec.next_year_course_id.id),
                 ('type', '=', 're_reg')],
                limit=1)
            if not fee_record.id:
                raise except_orm(_('Warning!'),
                                 _("Re-Registration Fee is Not Define !"))
            for fee_line_rec in fee_record.fee_line_ids:
                fee_line_id_list.append(fee_line_rec.id)
            re_reg_stud_rec.write({
                'confirm':
                True,
                're_reg_parents':
                re_reg_stud_rec.parents_re_reg.id,
                'state':
                'awaiting_re_registration_fee',
                'fee_status':
                're_unpaid',
            })
            for fee_line_id in fee_line_id_list:
                re_reg_stud_rec.fees_line_ids = [(4, fee_line_id)]


#             # if student have already paid advance amount
#             student_advance_paid = re_reg_stud_rec.name.credit
#             if student_advance_paid < 0.00:
#                 student_advance_paid = abs(student_advance_paid)
#                 s_payble_amount = 0.00
#                 is_full_paid = False
#                 if re_reg_stud_rec.residual > student_advance_paid:
#                     s_payble_amount = student_advance_paid
#                 else:
#                     s_payble_amount = re_reg_stud_rec.residual
#                     is_full_paid = True
#                 if s_payble_amount > 0:
# #                     self.re_reg_parents.re_reg_fee_reconcile_stud_advance(re_reg_partner_rec=re_reg_stud_rec,
# #                                                                           amount=s_payble_amount)
#                     re_reg_stud_rec.total_paid_amount = s_payble_amount
#                     if is_full_paid:
#                         re_reg_stud_rec.write({
#                             'fee_status': 're_Paid',
#                             're_reg_next_academic_year': 'yes', })
#                     else:
#                         re_reg_stud_rec.fee_status = 're_partially_paid'
            child_data_table += '<tr><td>%s</td><td>%s</td><td>Yes</td><td>%s</td></tr>' % (
                re_reg_stud_rec.name.name,
                re_reg_stud_rec.next_year_course_id.name,
                re_reg_stud_rec.total_amount)
            # send mail for fee reminder
            re_reg_stud_rec.parents_re_reg.send_re_registration_payment_link(
                parent_record=re_reg_stud_rec.parents_re_reg,
                child_data_table=child_data_table)
Exemplo n.º 17
0
 def write(self, vals):
     if 'discount_persentage' in vals and vals['discount_persentage']:
         if vals['discount_persentage'] > 100.0:
             raise except_orm(_('Warning!'),
                              _("please enter valid discount(%)."))
     if 'discount_type' in vals and vals['discount_type']:
         if vals['discount_type'] == 'amount':
             vals['discount_persentage'] = 0.00
         if vals['discount_type'] == 'persentage':
             vals['discount_amount'] = 0.00
     if 'update_discount' not in vals:
         if 'discount_amount' in vals or 'discount_persentage' in vals:
             raise except_orm(
                 _('Warning!'),
                 _("You can not update discount direcaly from hear, use update button"
                   ))
     return super(Discount_Category_line, self).write(vals)
Exemplo n.º 18
0
 def write(self,vals):
     if 'name' in vals:
         old_rec=self.search([('name','=',vals['name'])])
         if len(old_rec) != 0:
             raise except_orm(_('Warning!'),
                 _("Payment Type %s is already exist") % (vals['name']))
     
     return super(fee_payment_type,self).write(vals)
Exemplo n.º 19
0
    def create(self,vals):
        old_rec=self.search([('type','=',vals['type']),('course_id','=',vals['course_id']),('academic_year_id','=',vals['academic_year_id'])])

        if len(old_rec) != 0:
           raise except_orm(_('Warning!'),
                _("Fee structute already exist"))

        return super(Fees_Structure,self).create(vals)
Exemplo n.º 20
0
    def create(self, vals):
        course_obj = self.env['course']
        batch_obj = self.env['batch']
        course_brw = course_obj.browse(vals['class_id'])
        batch_brw = batch_obj.browse(vals['batch_id'])

        records = self.search([('class_id', '=', vals['class_id']), ('batch_id', '=', vals['batch_id'])])
        for rec in records:
            if len(list(rec.student_section_ids)) == 0:
                raise except_orm(_('Warning!'),
                            _("Record is already exist for same!"))
            elif rec.student_section_ids in vals['section_ids'][0][2]:
                raise except_orm(_('Warning!'),
                    _("Record is already exist for same!"))

        if 'class_id' in vals and 'promote_to_class' in vals:
            if vals['class_id'] and vals['promote_to_class']:
                if course_brw.is_last_course:
                    raise except_orm(_('Warning!'), _("You cannot proceed with promotion process for %s!")%course_brw.name)
                if not course_brw.next_course:
                    raise except_orm(_('Warning!'), _("Next course is not defined!"))
                if course_obj.browse(vals['promote_to_class']).id != course_brw.next_course.id:
                    raise except_orm(_('Warning!'),
                        _("promote to class can not be equal to or lower than current class!!"))
                
        if 'batch_id' in vals and 'promote_to_batch' in vals:
            if vals['batch_id'] and vals['promote_to_batch']:
                if not batch_brw.next_batch:
                    raise except_orm(_('Warning!'), _("Next batch is not defined!"))
                if batch_obj.browse(vals['promote_to_batch']).id != batch_brw.next_batch.id:
                    raise except_orm(_('Warning!'), 
                        _("promote to batch can not be equal to or lower than current batch!!"))
        return super(promote_student, self).create(vals)
Exemplo n.º 21
0
 def onchange_promote_batch(self):
     fees_obj = self.env['fees.structure']
     if self.promote_to_batch:
         fees_data = fees_obj.search([('type', '=', 'academic'), ('course_id', '=', self.promote_to_class.id),
                                     ('academic_year_id', '=', self.promote_to_batch.id)])
         if not fees_data:
             raise except_orm(_('Warning!'),
                              _("Fee Structure is not defined for class %s and academic year %s!")
                              % (self.promote_to_class.name, self.promote_to_batch.name))
Exemplo n.º 22
0
    def write(self, vals):
        ir_attachment = self.env['ir.attachment']
        if 'emirates_expiry_date' in vals and vals['emirates_expiry_date']:
            emirates_expiry_date = vals['emirates_expiry_date']
        else:
            emirates_expiry_date = self.emirates_expiry_date

        if 'emirates_start_date' in vals and vals['emirates_start_date']:
            emirates_start_date = vals['emirates_start_date']
        else:
            emirates_start_date = self.emirates_start_date

        if 'employee_id' in vals and vals['employee_id']:
            employee_id = vals['employee_id']
        else:
            employee_id = self.employee_id.id

        if 'emirates_card_file_name' in vals and vals[
                'emirates_card_file_name']:
            if not 'emirates_card_file_name' in vals:
                raise except_orm(_('Warning!'),
                                 _("Please attach Emirates ID copy"))
            elif 'emirates_id_attachment' in vals:
                emirates_id_attachment = vals['emirates_id_attachment']
                if emirates_id_attachment:
                    ir_attachment.sudo().create({
                        'name':
                        vals['emirates_card_file_name'],
                        'res_model':
                        'hr.employee',
                        'res_id':
                        employee_id,
                        'datas':
                        emirates_id_attachment,
                        'type':
                        'binary',
                        'datas_fname':
                        vals['emirates_card_file_name'],
                    })
                    ir_attachment.sudo().create({
                        'name':
                        vals['emirates_card_file_name'],
                        'datas_fname':
                        vals['emirates_card_file_name'],
                        'res_model':
                        'emirates.id.details',
                        'res_id':
                        self.id,
                        'datas':
                        emirates_id_attachment,
                        'type':
                        'binary'
                    })
                    vals['emirates_id_attachment'] = None
                    vals['labour_flag'] = True
        return super(emirates_id_details, self).write(vals)
Exemplo n.º 23
0
    def create(self, vals):
        result = super(account_move, self).create(vals)

        if 'cheque_expiry_date' in vals and vals['cheque_expiry_date']:
            current_date = date.today()
            current_date = datetime.strptime(str(current_date), "%Y-%m-%d")
            comp_date = datetime.strptime(vals['cheque_expiry_date'],
                                          "%Y-%m-%d")
            chk_date = datetime.strptime(vals['cheque_date'], "%Y-%m-%d")
            if comp_date < current_date:
                raise except_orm(
                    _('Warning!'),
                    _("Cheque Expiry Date should be after current date!"))
            if chk_date > comp_date:
                raise except_orm(
                    _('Warning!'),
                    _("Cheque Expiry Date should be after cheque date!"))

        return result
Exemplo n.º 24
0
 def unlink(self):
     for student in self:
         if student.state == 'draft':
             continue
         elif student.state == 'promote':
             student.student_id.promoted = False
             continue
         else:
             raise except_orm(_('Warning!'),_("You can not delete this record"))
     return super(promote_student_line, self).unlink()
Exemplo n.º 25
0
    def write(self, vals):
        if 'update_amount' not in vals and 'amount' in vals:
            vals['amount'] = self.amount
            raise except_orm(_('Warning!'),
                    _("You can not update amount directly from hear !, please use Update Amount and Update button"))

        # discount change then discount amount calculation
        if 'discount' in vals:
            if vals['discount'] > 100.0 or vals['discount'] < 0.0:
                raise except_orm(_('Warning!'),_("please enter valid discount(%)."))
            else:
                if self.amount > 0.0 and 'discount_amount' not in vals:
                    vals['discount_amount'] = (self.amount * vals['discount'])/100

        # discount amount change then discount calculation
        if 'discount_amount' in vals and vals['discount_amount'] >= 0.0:
            if self.amount > 0.0 and 'discount' not in vals:
                vals['discount'] = (vals['discount_amount']*100)/self.amount

        return super(Fees_Line, self).write(vals)
Exemplo n.º 26
0
    def write(self, vals):
        """
        -----------------
        :param vals:
        :return:
        """
        if ('start_date' in vals) or ('end_date' in vals):

            batch_id = self.batch_id.id
            batch_brw = self.env['batch'].browse(batch_id)

            batch_start_date = batch_brw.start_date
            batch_stop_date = batch_brw.end_date

            if 'start_date' in vals:
                start_date = vals['start_date']
            else:
                start_date = self.start_date
            if 'end_date' in vals:
                stop_date = vals['end_date']
            else:
                stop_date = self.end_date
            if start_date >= batch_start_date and start_date <= batch_stop_date and stop_date >= batch_start_date and stop_date <= batch_stop_date and start_date < stop_date:
                pass
            else:
                raise except_orm(
                    _('Warning!'),
                    _("Start date and End date of Term should be inbetween Duration of Acadamic Year"
                      ))
            prev_terms = self.search([('batch_id', '=', batch_id)])
            for each in prev_terms:
                if each.id != self.id:
                    if (start_date >= each.start_date and start_date <=
                            each.end_date) or (stop_date >= each.start_date
                                               and stop_date <= each.end_date):
                        raise except_orm(
                            _('Warning!'),
                            _("Your Dates already comes under %s term") %
                            (each.name, ))

        return super(acd_term, self).write(vals)
    def resend_tc_fee_payment_link(self):
        """
        this method is use to resend TC Fee Payment link.
        ---------------------------------------------------
        :return:
        """
        active_ids = self._context['active_ids']
        tc_obj = self.env['trensfer.certificate']
        for tc_student_rec in tc_obj.browse(active_ids):
            if tc_student_rec.state != 'final_fee_awaited':
                raise except_orm(
                    _('Warning!'),
                    _("Fee Payment Link Reminder send only in Final Fee Awaited State !"
                      ))

            if tc_student_rec.credit == 0.00 and tc_student_rec.parent_credit == 0.00:
                raise except_orm(
                    _('Warning!'),
                    _("You can not send Fee Payment Link with 0.00 amount !"))
            else:
                tc_student_rec.send_mail_payfort_payment_link()
Exemplo n.º 28
0
 def unlink(self):
     """
     This Method is call, when we delete record.
     ------------------------------------------
     :return:
     """
     # add validation for record delation time
     for each in self:
         if each.type=='required' and each.reg_form_id:
             raise except_orm(_('Warning!'),
                 _("You cant delete the required fees lines!"))
     res=super(Fees_Line,self).unlink()
     return res
Exemplo n.º 29
0
 def create(self, vals):
     """
     apply validation : only one record for TC fee structure.
     ---------------------------------------------------------
     :param vals: data dictonary
     :return:
     """
     res = super(TCFeeStructure,self).create(vals)
     exist_record = self.search([])
     if len(exist_record) > 1:
         raise except_orm(_('Warning!'),
                 _("You Can not Create More than One Record !"))
     return res
Exemplo n.º 30
0
    def create(self, vals):
        """
        ------------------
        :param vals:
        :return:
        """
        batch_brw = self.env['batch'].browse(vals['batch_id'])
        batch_start_date = batch_brw.start_date
        batch_stop_date = batch_brw.end_date

        start_date = vals['start_date']
        stop_date = vals['end_date']
        if start_date >= batch_start_date and start_date <= batch_stop_date and stop_date >= batch_start_date and stop_date <= batch_stop_date and start_date < stop_date:
            pass
        else:
            raise except_orm(
                _('Warning!'),
                _("Start date and End date of Term should be inbetween Duration of Acadamic Year"
                  ))

        prev_terms = self.search([('batch_id', '=', vals['batch_id'])])
        if len(prev_terms) == 0:
            vals['seq'] = 1
        else:
            len1 = 0
            len1 = len(prev_terms)
            vals['seq'] = prev_terms[len1 - 1].seq + 1

        for each in prev_terms:
            if (start_date >= each.start_date and start_date <= each.end_date
                ) or (stop_date >= each.start_date
                      and stop_date <= each.end_date):
                raise except_orm(
                    _('Warning!'),
                    _("Your Dates already comes under %s term") %
                    (each.name, ))

        return super(acd_term, self).create(vals)