Skip to content

[FW][REF] academic: add current year filter to student group validation #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions academic/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,36 @@ def _check_unique_main_group_per_year(self):
porque, al usar un campo many2many, la validación no se activaba al agregar un estudiante
directamente desde un grupo.
"""
current_year = date.today().year
for partner in self:
<<<<<<< HEAD
domain = [("student_ids", "=", partner.id), ("subject_id", "=", False)]
grouped_data = self.env["academic.group"].read_group(domain, ["year"], ["year"])
duplicate_years = [group["year"] for group in grouped_data if group["year_count"] > 1]
||||||| parent of 74204d1 (temp)
domain = [
('student_ids', '=', partner.id),
('subject_id', '=', False)
]
grouped_data = self.env['academic.group'].read_group(
domain,
['year'],
['year']
)
duplicate_years = [group['year'] for group in grouped_data if group['year_count'] > 1]
=======
domain = [
('student_ids', '=', partner.id),
('subject_id', '=', False),
('year', '>=', current_year)
]
grouped_data = self.env['academic.group'].read_group(
domain,
['year'],
['year']
)
duplicate_years = [group['year'] for group in grouped_data if group['year_count'] > 1]
>>>>>>> 74204d1 (temp)
if duplicate_years:
raise ValidationError(
_(
Expand Down
Loading