def _compute_student_issue_ids(self):
     for student in self:
         context = self.env.context
         cond = []
         school_id = context.get('school_id', student.current_center_id.id)
         schedule_id = context.get('education_schedule_id', False)
         # group_id = context.get('education_group_id', False)
         if school_id:
             classroom_site = self.env.ref(
                 'issue_education.classroom_school_issue_site')
             cond = [('affect_to', '=', 'student'),
                     ('school_id', '=', school_id)]
             if schedule_id and classroom_site:
                 cond = expression.AND([[('issue_type_id.site_id', '=',
                                          classroom_site.id)], cond])
         issue_types = self.env['school.college.issue.type']
         if cond:
             issue_types = issue_types.search(cond, order='sequence')
         student_issues = self.env['student.issue']
         for issue_type in issue_types:
             student_issue_vals = {
                 'student_id': student.id,
                 'education_schedule_id': schedule_id,
                 'college_issue_type_id': issue_type.id,
             }
             student_issues |= student_issues.create(student_issue_vals)
         student.student_issue_ids = [(6, 0, student_issues.ids)]
Exemple #2
0
 def create_sale_order_for_student(self):
     today = fields.Date.context_today(self)
     date_from = today.replace(month=1, day=1)
     next_year = today.year + 1
     date_to = today.replace(year=next_year, month=12, day=31)
     academic_years = self.env['education.academic_year'].search([
         ('date_start', '>=', date_from),
         ('date_end', '<=', date_to),
     ])
     if not academic_years:
         raise Warning(_('There are no valid academic years'))
     sales = self.env['sale.order']
     futures = self.mapped('future_student_ids').filtered(
         lambda l: l.child_id and not l.sale_order_id and
         l.academic_year_id in academic_years)
     if not futures:
         raise Warning(_('There are not future student to register.'))
     for future in futures:
         vals = future.crm_lead_id._get_vals_for_sale_order(future)
         future.sale_order_id = sales.create(vals)
         future.sale_order_id.onchange_sale_order_template_id()
         future.child_id.educational_category = 'student'
         future.crm_lead_id._put_payer_information_in_sale_order(
             future, future.sale_order_id)
         sales += future.sale_order_id
     action = self.env.ref('sale.action_quotations_with_onboarding')
     action_dict = action.read()[0] if action else {}
     domain = expression.AND([
         [('id', 'in', sales.ids)],
         safe_eval(action.domain or '[]')])
     action_dict.update({
         'domain': domain,
     })
     return action_dict
Exemple #3
0
 def button_open_schedule(self):
     action = self.env.ref('education.action_education_schedule_from_group')
     action_dict = action.read()[0] if action else {}
     domain = expression.AND([
         [('id', 'in', self.mapped('schedule_ids').ids)],
         safe_eval(action.domain or '[]')])
     action_dict.update({
         'domain': domain,
     })
     return action_dict
Exemple #4
0
 def open_calendar_event(self):
     action = self.env.ref('calendar.action_calendar_event')
     action_dict = action.read()[0] if action else {}
     res_model_id = self.env['ir.model']._get_id(self._name)
     domain = expression.AND([
         [('res_id', '=', self.id),
          ('res_model_id', '=', res_model_id)],
         safe_eval(action.domain or '[]')])
     action_dict.update({'domain': domain})
     return action_dict
Exemple #5
0
 def action_view_contracts(self):
     self.ensure_one()
     action = self.env.ref('contract.action_customer_contract')
     action_dict = action.read()[0] if action else {}
     domain = expression.AND([
         [('sale_id', 'in', self.ids)],
         safe_eval(action.domain or '[]')])
     action_dict.update({
         'domain': domain,
     })
     return action_dict
 def button_show_meetings(self):
     self.ensure_one()
     action = self.env.ref('calendar.action_calendar_event')
     action_dict = action.read()[0] if action else {}
     action_dict['context'] = safe_eval(action_dict.get('context', '{}'))
     action_dict['context'].update({
         'search_default_teacher_id': self.id,
         'default_teacher_id': self.id,
     })
     domain = expression.AND([[('teacher_id', 'in', self.ids)],
                              safe_eval(action.domain or '[]')])
     action_dict.update({'domain': domain})
     return action_dict
 def button_show_meetings(self):
     self.ensure_one()
     action = self.env.ref('calendar.action_calendar_event')
     action_dict = action.read()[0] if action else {}
     action_dict['context'] = safe_eval(
         action_dict.get('context', '{}'))
     domain = safe_eval(action.domain or '[]')
     if self.educational_category == 'student':
         action_dict['context'].update({
             'search_default_student_id': self.id,
             'default_student_id': self.id,
         })
         domain = expression.AND([
             [('student_id', 'in', self.ids)], domain])
     elif self.educational_category == 'family':
         action_dict['context'].update({
             'search_default_family_id': self.id,
             'default_family_id': self.id,
         })
         domain = expression.AND([
             [('family_id', 'in', self.ids)], domain])
     action_dict.update({'domain': domain})
     return action_dict
Exemple #8
0
 def button_generate_view_issues(self):
     self.ensure_one()
     action = self.env.ref(
         'issue_education_kanban_view.res_partner_education_issue_action')
     action_dict = action.read()[0] if action else {}
     action_dict['context'] = safe_eval(action_dict.get('context', '{}'))
     action_dict['context'].update({
         'education_schedule_id': self.id,
         'school_id': self.center_id.id,
     })
     domain = expression.AND([[('id', 'in', self.student_ids.ids)],
                              safe_eval(action.domain or '[]')])
     action_dict.update({'domain': domain})
     return action_dict
 def button_open_school_claims(self):
     self.ensure_one()
     action = self.env.ref('issue_education.action_school_claim')
     action_dict = action.read()[0] if action else {}
     action_dict['context'] = safe_eval(
         action_dict.get('context', '{}'))
     action_dict['context'].update({
         'default_student_id': self.id,
     })
     domain = expression.AND([
         [('student_id', 'in', self.ids)],
         safe_eval(action.domain or '[]')])
     action_dict.update({'domain': domain})
     return action_dict
Exemple #10
0
 def button_open_students(self):
     action = self.env.ref('base.action_partner_form')
     action_dict = action.read()[0] if action else {}
     domain = expression.AND([
         [('id', 'in', self.mapped('student_ids').ids)],
         safe_eval(action.domain or '[]')
     ])
     context = safe_eval(action.context or '[]')
     context.pop('search_default_customer')
     action_dict.update({
         'display_name': _('Students'),
         'domain': domain,
         'context': context,
     })
     return action_dict
Exemple #11
0
 def button_show_tutored_students(self):
     self.ensure_one()
     self = self.with_context(search_default_teacher_id=self.id,
                              default_teacher_id=self.id)
     action = self.env.ref(
         'hr_school.action_hr_employee_supervised_year_form')
     action_dict = action.read()[0] if action else {}
     action_dict['context'] = safe_eval(action_dict.get('context', '{}'))
     action_dict['context'].update({
         'search_default_teacher_id': self.id,
         'default_teacher_id': self.id
     })
     domain = expression.AND([[('teacher_id', '=', self.id)],
                              safe_eval(action.domain or '[]')])
     action_dict.update({'domain': domain})
     return action_dict
Exemple #12
0
 def button_account_analytic_line_action(self):
     self.ensure_one()
     action = self.env.ref('analytic.account_analytic_line_action_entries')
     action_dict = action.read()[0] if action else {}
     action_dict['context'] = safe_eval(action_dict.get('context', '{}'),
                                        {'datetime': datetime})
     action_dict['context'].update({
         'search_default_claim_id':
         self.id,
         'default_claim_id':
         self.id,
         'default_account_id':
         self.analytic_account_id.id,
     })
     domain = expression.AND([[('account_id', '=',
                                self.analytic_account_id.id)],
                              safe_eval(action.domain or '[]')])
     action_dict.update({'domain': domain})
     return action_dict
 def create_permissions(self):
     permissions = permission_model = self.env['res.partner.permission']
     for student in self.student_ids:
         permissions |= permission_model.create({
             'partner_id':
             student.id,
             'type_id':
             self.type_id.id,
             'start_date':
             self.start_date,
             'end_date':
             self.end_date,
             'description':
             self.description or '',
         })
     action = self.env.ref(
         'contacts_school_permission.action_res_partner_permission')
     action_dict = action.read()[0] if action else {}
     domain = expression.AND([[('id', 'in', permissions.ids)],
                              safe_eval(action.domain or '[]')])
     action_dict.update({'domain': domain})
     return action_dict