예제 #1
0
    def onchange_service(self, cr, uid, ids, transport_id, context):
        if not transport_id:
            return {}
        student_id = context.get('active_id')
        student = self.pool.get('res.partner').browse(cr, uid, student_id)
        if context.get('academic_year_id'):
            pos_line_obj = self.pool.get('pos.order.line')
            exist = []
            data = []
            transport = self.pool.get('pos.category').browse(cr, uid, transport_id)

            for service in transport.services_ids:
                id = self.pool.get('account.period').search(cr, uid, [
                                    ('code', '=', service.subscription_month),
                                    ('company_id','=',tools.get_default_company(self,cr,uid)),
                                    ('date_stop', '>=', student.date),
                                ])
                data.append(self.pool.get('account.period').browse(cr, uid, id))
            data = sorted( list( set( data ) ),key=lambda data: data[0].date_start )

            for x in self.pool.get('pos.order.line').search(cr, uid, [
                ('product_id.pos_categ_id.zone', '=', transport.zone.id),
                ('student_id', '=', student.id),
                ('subscriber', '=', True)]):
                exist.append(pos_line_obj.browse(cr, uid, x).period_id.id)
            return {'value': {'period_ids': [(6, 0, [x.id not in exist and x.state == 'draft' and x.id for x in data])]}}
        return {}
예제 #2
0
 def default_academic_year(self, cr, uid, context):
     year_obj = self.pool.get('oschool.academic_year')
     year_id = year_obj.search(cr, uid,[
                                      ('state','=', 'current'),
                                         ('company_id','=',tools.get_default_company(self,cr,uid))
                                      ])
     if year_id:
         return  year_id[0]
     else:
         return False
예제 #3
0
    def onchange_club(self, cr, uid, ids, club_id, context):
        if not club_id:
            return {}
        student_id = context.get('active_id')
        student = self.pool.get('res.partner').browse(cr, uid, student_id)
        if context.get('academic_year_id'):
            pos_line_obj = self.pool.get('pos.order.line')
            exist = []
            data = []
            for service in self.pool.get('pos.category').browse(cr, uid, club_id).services_ids:
                id = self.pool.get('account.period').search(cr, uid, [
                    ('code', '=', service.subscription_month),
                    ('company_id','=',tools.get_default_company(self,cr,uid)),
                    ('date_stop', '>=', student.date),
                ])
                data.append(self.pool.get('account.period').browse(cr, uid, id))
            data = sorted( list( set( data ) ),key=lambda data: data[0].date_start )

            for x in self.pool.get('pos.order.line').search(cr, uid, [('product_id.pos_categ_id', '=', club_id), ('student_id', '=', student.id), ('subscriber', '=', True)]):
                exist.append(pos_line_obj.browse(cr, uid, x).period_id.id)
            return {'value': {'period_ids': [(6, 0, [x.id not in exist and x.state == 'draft' and x.id for x in data])]}}
        return {}
예제 #4
0
    def set_context(self, objects, data, ids, report_type=None):
        obj_payment = self.pool.get('oschool.payment.wizard')
        payment_obj = obj_payment.browse(self.cr, self.uid, ids)
        academic_year = payment_obj.academic_year_id
        period_id = payment_obj.period_id
        data = {
            'academic_year': academic_year.name,
            'period_id': period_id.name,
            'study': {}
        }

        student_ids = self.pool.get('res.partner').search(
            self.cr, self.uid,
            [('academic_year_id', '=', academic_year.id),
             ('company_id', '=',
              tools.get_default_company(self, self.cr, self.uid)),
             ('active_student', '=', True)])

        for student in self.pool.get('res.partner').browse(
                self.cr, self.uid, student_ids):
            study_ids = self.pool.get('pos.order.line').search(
                self.cr, self.uid, [
                    ('student_id', '=', student.id),
                    ('period_id', '=', period_id.id),
                    ('type', '=', 'Study'),
                    ('refunded', '=', False),
                    ('qty', '>', 0),
                ])
            if study_ids:
                line = self.pool.get('pos.order.line').browse(
                    self.cr, self.uid, study_ids)
                if not line.order_id:
                    if student.group_id.name not in data['study']:
                        data['study'][student.group_id.name] = {}
                        if student.class_id:
                            data['study'][student.group_id.name][
                                student.class_id.name] = []
                            data['study'][student.group_id.name][
                                student.class_id.name].append(student)
                        else:
                            data['study'][
                                student.group_id.name]['NO_CLASS'] = []
                            data['study'][student.group_id.
                                          name]['NO_CLASS'].append(student)
                    else:
                        if student.class_id:
                            if student.class_id.name not in data['study'][
                                    student.group_id.name]:
                                data['study'][student.group_id.name][
                                    student.class_id.name] = []
                                data['study'][student.group_id.name][
                                    student.class_id.name].append(student)
                            else:
                                data['study'][student.group_id.name][
                                    student.class_id.name].append(student)
                        else:
                            if 'NO_CLASS' not in data['study'][
                                    student.group_id.name]:
                                data['study'][
                                    student.group_id.name]['NO_CLASS'] = []
                                data['study'][student.group_id.
                                              name]['NO_CLASS'].append(student)
                            else:
                                data['study'][student.group_id.
                                              name]['NO_CLASS'].append(student)
            else:
                if student.group_id.name not in data['study']:
                    data['study'][student.group_id.name] = {}
                    if student.class_id:
                        data['study'][student.group_id.name][
                            student.class_id.name] = []
                        data['study'][student.group_id.name][
                            student.class_id.name].append(student)
                    else:
                        data['study'][student.group_id.name]['NO_CLASS'] = []
                        data['study'][
                            student.group_id.name]['NO_CLASS'].append(student)
                else:
                    if student.class_id:
                        if student.class_id.name not in data['study'][
                                student.group_id.name]:
                            data['study'][student.group_id.name][
                                student.class_id.name] = []
                            data['study'][student.group_id.name][
                                student.class_id.name].append(student)
                        else:
                            data['study'][student.group_id.name][
                                student.class_id.name].append(student)
                    else:
                        if 'NO_CLASS' not in data['study'][
                                student.group_id.name]:
                            data['study'][
                                student.group_id.name]['NO_CLASS'] = []
                            data['study'][student.group_id.
                                          name]['NO_CLASS'].append(student)
                        else:
                            data['study'][student.group_id.
                                          name]['NO_CLASS'].append(student)

        return super(payment, self).set_context(objects, data, ids,
                                                report_type)
예제 #5
0
    def set_context(self, objects, data, ids, report_type=None):
        obj_payment = self.pool.get('oschool.payment.wizard')
        payment_obj = obj_payment.browse(self.cr, self.uid, ids)
        academic_year = payment_obj.academic_year_id
        period_id = payment_obj.period_id
        data = {'academic_year': academic_year.name,
                'period_id':period_id.name,
                'study':{}}

        student_ids = self.pool.get('res.partner').search(self.cr, self.uid,[
            ('academic_year_id','=',academic_year.id),
            ('company_id','=',tools.get_default_company(self,self.cr,self.uid)),
            ('active_student','=',True)
        ])

        for student in self.pool.get('res.partner').browse(self.cr,self.uid,student_ids):
            study_ids = self.pool.get('pos.order.line').search(self.cr, self.uid,[
                ('student_id','=',student.id),
                ('period_id','=',period_id.id),
                ('type','=','Study'),
                ('refunded','=',False),
                ('qty','>',0),
            ])
            if study_ids:
                line = self.pool.get('pos.order.line').browse(self.cr,self.uid,study_ids)
                if not line.order_id:
                    if student.group_id.name not in data['study']:
                        data['study'][student.group_id.name] = {}
                        if student.class_id:
                            data['study'][student.group_id.name][student.class_id.name] = []
                            data['study'][student.group_id.name][student.class_id.name].append(student)
                        else:
                            data['study'][student.group_id.name]['NO_CLASS'] = []
                            data['study'][student.group_id.name]['NO_CLASS'].append(student)
                    else:
                        if student.class_id:
                            if student.class_id.name not in data['study'][student.group_id.name]:
                                data['study'][student.group_id.name][student.class_id.name] = []
                                data['study'][student.group_id.name][student.class_id.name].append(student)
                            else:
                                data['study'][student.group_id.name][student.class_id.name].append(student)
                        else:
                            if 'NO_CLASS' not in data['study'][student.group_id.name]:
                                data['study'][student.group_id.name]['NO_CLASS'] = []
                                data['study'][student.group_id.name]['NO_CLASS'].append(student)
                            else:
                                data['study'][student.group_id.name]['NO_CLASS'].append(student)
            else:
                if student.group_id.name not in data['study']:
                    data['study'][student.group_id.name] = {}
                    if student.class_id:
                        data['study'][student.group_id.name][student.class_id.name] = []
                        data['study'][student.group_id.name][student.class_id.name].append(student)
                    else:
                        data['study'][student.group_id.name]['NO_CLASS'] = []
                        data['study'][student.group_id.name]['NO_CLASS'].append(student)
                else:
                    if student.class_id:
                        if student.class_id.name not in data['study'][student.group_id.name]:
                            data['study'][student.group_id.name][student.class_id.name] = []
                            data['study'][student.group_id.name][student.class_id.name].append(student)
                        else:
                            data['study'][student.group_id.name][student.class_id.name].append(student)
                    else:
                        if 'NO_CLASS' not in data['study'][student.group_id.name]:
                            data['study'][student.group_id.name]['NO_CLASS'] = []
                            data['study'][student.group_id.name]['NO_CLASS'].append(student)
                        else:
                            data['study'][student.group_id.name]['NO_CLASS'].append(student)
            
        return super(payment, self).set_context(objects, data, ids, report_type)