from odoo import models, fields, api, _ from odoo.exceptions import ValidationError class ServicesSettings(models.Model): _inherit = 'services.settings' # Inherit existing model linked_to_department = fields.Boolean( string='Linked to Department', help='Link the service to an HR department' ) hr_department_id = fields.Many2one( 'hr.department', string='Linked Department' ) manager_id = fields.Many2one( 'hr.employee', string='Manager', ) service_type = fields.Selection(selection_add=[ ('educational_care', 'خدمة الرعاية التعليمية'), ('bachelor_service', 'خدمة البكالريوس'), ('diploma_service', 'خدمة الدبلوم'), ('bachelor_intercession', 'خدمة شفاعة البكالريوس'), ('diploma_intercession', 'خدمة شفاعة الدبلوم'), ('training_service', 'خدمة التدريب'), ('training_intercession', 'خدمة شفاعة التدريب'), ('funding_service', 'خدمة التمويل'), ('project_funding_intercession', 'خدمة شفاعة تمويل المشاريع'), ('employment_service', 'خدمة التوظيف') ]) class HrDepartment(models.Model): _inherit = 'hr.department' service_link_id = fields.Many2one( 'services.settings', string='خدمة مرتبطة', readonly=True ) class EmpowermentEducationEntity(models.Model): _name = 'empowerment.education.entity' _description = 'Education Entity' name = fields.Char(string='Entity Name', required=True) entity_type = fields.Selection( [('university', 'University'), ('college', 'College'), ('institute', 'Institute'), ('school', 'School')], string='Entity Type', required=True ) study_specialization = fields.Selection( [('bachelor', 'Bachelor'), ('diploma', 'Diploma')], string='Study Specialization', required=True ) specialization_id = fields.Many2one( 'empowerment.study.specialization', string='Study Specialization', domain="[('type', '=', study_specialization)]", ) _sql_constraints = [ ('name_unique', 'unique(name)', 'اسم الجهة يجب أن يكون فريداً!'), ] @api.onchange('entity_type') def _onchange_entity_type(self): if self.entity_type in ['university', 'college']: self.study_specialization = 'bachelor' elif self.entity_type in ['institute', 'school']: self.study_specialization = 'diploma' else: self.study_specialization = False # Reset specialization_id when entity_type changes # self.specialization_id = False class StudySpecialization(models.Model): _name = 'empowerment.study.specialization' _description = 'Study Specialization' type = fields.Selection([ ('bachelor', 'Bachelor'), ('diploma', 'Diploma') ], string='Study Type', required=True) universities_colleges = fields.Char(string='Universities / Colleges') institutes_schools = fields.Char(string='Institute / School Name') class EmpowermentQualificationCourse(models.Model): _name = 'empowerment.qualification.course' _description = 'Qualification Course' name = fields.Char(string='Entity Name', required=True) class EmpowermentTrainingEntity(models.Model): _name = 'empowerment.training.entity' _description = 'Training Entities' name = fields.Char(string='Entity Name', required=True) class EmpowermentProjectFundingType(models.Model): _name = 'empowerment.project.funding.type' _description = 'Project Funding Type' name = fields.Char(string='Entity Name', required=True)