40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
from odoo.tests.common import TransactionCase
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
class TestAcademicYear(TransactionCase):
|
|
|
|
def setUp(self):
|
|
super().setUp()
|
|
self.company = self.env.company
|
|
|
|
def test_academic_year_date_validation(self):
|
|
with self.assertRaises(ValidationError):
|
|
self.env['education.academic.year'].create({
|
|
'name': '2025-2026',
|
|
'code': 'AY2025',
|
|
'start_date': '2026-06-01',
|
|
'end_date': '2025-06-01',
|
|
'company_id': self.company.id,
|
|
})
|
|
|
|
def test_single_current_year_per_company(self):
|
|
self.env['education.academic.year'].create({
|
|
'name': '2024-2025',
|
|
'code': 'AY2024',
|
|
'start_date': '2024-06-01',
|
|
'end_date': '2025-06-01',
|
|
'company_id': self.company.id,
|
|
'current_year': True,
|
|
})
|
|
|
|
with self.assertRaises(ValidationError):
|
|
self.env['education.academic.year'].create({
|
|
'name': '2025-2026',
|
|
'code': 'AY2025',
|
|
'start_date': '2025-06-01',
|
|
'end_date': '2026-06-01',
|
|
'company_id': self.company.id,
|
|
'current_year': True,
|
|
})
|