from datetime import datetime, timedelta, date
from dateutil import relativedelta
from hijri_converter import convert
from num2words import num2words
from odoo import api, exceptions, fields, models, _
from odoo.exceptions import ValidationError, Warning
from odoo.tools.translate import _

class Qualification(models.Model):
    _name = "hr.qualification.req"
    _description = "HR Qualification"
    _rec_name = "uni_name"

    uni_name = fields.Many2one(
        comodel_name="empowerment.education.entity", string="University Name", required=True
    )
    # col_name = fields.Many2one(comodel_name="hr.college", string="College Name")
    prg_status = fields.Char(string="Program Status")
    comp_date = fields.Date(string="Completion Date")
    contact_name = fields.Char(string="Contact Name")
    contact_phn = fields.Char(string="Contact Phone No")
    contact_email = fields.Char(string="Contact Email")
    country_name = fields.Many2one(comodel_name="res.country",string="Country")
    qualification_degree = fields.Selection(
        [
            ("weak", _("Weak")),
            ("good", _("Good")),
            ("very_good", _("Very Good")),
            ("excellent", _("Excellent")),
        ]
    )
    qualification_specification_id = fields.Many2one(
        comodel_name="qualification.specification.req",
        domain=[("type", "=", "qualification")],
    )

    # relation field
    qualification_relation_name = fields.Many2one(comodel_name="hr.employee")
    qualification_id = fields.Many2one(comodel_name="hr.qualification.name.req", string="Qualification Name")
    attachment = fields.Binary(string="Attachment")

class QualificationSpecification(models.Model):
    _name = "qualification.specification.req"
    _description = "Qualification Specification"

    name = fields.Char(string="Name")
    type = fields.Selection(
        selection=[("qualification", "Qualification"), ("certificate", "Certificate")],
        string="Type")


class HrQualificationName(models.Model):
    _name = "hr.qualification.name.req"
    _description = "HR Qualification Name"

    name = fields.Char(string="Qualification")
    sequence = fields.Integer(string="Sequence")
    parent_id = fields.Many2one(comodel_name="hr.qualification.name.req", string="Upper Qualification")



class HrEmployeeHistory(models.Model):
    _name = "hr.employee.history.req"
    _description = "HR Employee History"

    employement_history = fields.Many2one(comodel_name="hr.employee")
    name = fields.Char(string="Name",required=True)
    position = fields.Char(string="Position",required=True)
    employeer = fields.Char(string="Employeer",required=True)
    salary = fields.Float(string="Salary",required=True)
    address = fields.Char(string="Address",required=True)
    date_from = fields.Date(string="Date From",)
    date_to = fields.Date(string="Date To",)
    country = fields.Many2one(string="Country",comodel_name="res.country")