<commit_before># Copyright 2019 <NAME> - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import _, api, fields, models
from odoo.models import expression
from odoo.tools.safe_eval import safe_eval
from datetime import timedelta


class HrEmployeeSupervisedYear(models.Model):
    _inherit = 'hr.employee.supervised.year'

    center_id = fields.Many2one(
        comodel_name='res.partner', string='Education Center',
        compute='_compute_education_info', store=True)
    course_id = fields.Many2one(
        comodel_name='education.course', string='Education Course',
        compute='_compute_education_info', store=True)
    meeting_ids = fields.One2many(
        comodel_name='calendar.event', inverse_name='supervised_year_id',
        string='Meetings')
    count_meetings = fields.Integer(
        string='# Tutoring meetings', compute='_compute_count_meetings')
    substitution_ids = fields.One2many(
        string='Substitutions', inverse_name='supervised_year_id',
        comodel_name='hr.employee.supervised.year.substitution')

    @api.depends('student_id', 'student_id.student_group_ids',
                 'student_id.student_group_ids.group_type_id',
                 'student_id.student_group_ids.group_type_id.type',
                 'student_id.student_group_ids.center_id',
                 'student_id.student_group_ids.course_id', 'school_year_id')
    def _compute_education_info(self):
        for year in self:
            groups = year.student_id.student_group_ids.filtered(
                lambda g: g.group_type_id.type == 'official' and
                g.academic_year_id == year.school_year_id
            )
            year.center_id = groups[:1].center_id
            year.course_id = groups[:1].course_id

    @api.depends('meeting_ids')
    def _compute_count_meetings(self):
        for year in self:
            year.count_meetings = (len(year.meeting_ids))

    @api.multi<commit_msg>[IMP] calendar_school: add compute sudo (#967)<commit_after># Copyright 2019 <NAME> - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import _, api, fields, models
from odoo.models import expression
from odoo.tools.safe_eval import safe_eval
from datetime import timedelta


class HrEmployeeSupervisedYear(models.Model):
    _inherit = 'hr.employee.supervised.year'

    center_id = fields.Many2one(
        comodel_name='res.partner', string='Education Center',
        compute='_compute_education_info', store=True, compute_sudo=True)
    course_id = fields.Many2one(
        comodel_name='education.course', string='Education Course',
        compute='_compute_education_info', store=True, compute_sudo=True)
    meeting_ids = fields.One2many(
        comodel_name='calendar.event', inverse_name='supervised_year_id',
        string='Meetings')
    count_meetings = fields.Integer(
        string='# Tutoring meetings', compute='_compute_count_meetings')
    substitution_ids = fields.One2many(
        string='Substitutions', inverse_name='supervised_year_id',
        comodel_name='hr.employee.supervised.year.substitution')

    @api.depends('student_id', 'student_id.student_group_ids',
                 'student_id.student_group_ids.group_type_id',
                 'student_id.student_group_ids.group_type_id.type',
                 'student_id.student_group_ids.center_id',
                 'student_id.student_group_ids.course_id', 'school_year_id')
    def _compute_education_info(self):
        for year in self:
            groups = year.student_id.student_group_ids.filtered(
                lambda g: g.group_type_id.type == 'official' and
                g.academic_year_id == year.school_year_id
            )
            year.center_id = groups[:1].center_id
            year.course_id = groups[:1].course_id

    @api.depends('meeting_ids')
    def _compute_count_meetings(self):
        for year in self:
            year.count_meetings = (len(year.meeting_ids))

    @api.multi
{'fraction_non_alphanumeric': 0.10502625656414104, 'fraction_numerical': 0.007251812953238309, 'mean_word_length': 3.23728813559322, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2886669', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1226, 'n_words': 200}