package models

import "odoo-go/pkg/orm"

// initHrSkill registers hr.skill.type, hr.skill, hr.employee.skill and hr.resume.line.
// Mirrors: odoo/addons/hr_skills/models/hr_skill.py
func initHrSkill() {
	orm.NewModel("hr.skill.type", orm.ModelOpts{
		Description: "Skill Type",
		Order:       "name",
	}).AddFields(
		orm.Char("name", orm.FieldOpts{String: "Name", Required: true}),
		orm.One2many("skill_ids", "hr.skill", "skill_type_id", orm.FieldOpts{String: "Skills"}),
	)

	orm.NewModel("hr.skill", orm.ModelOpts{
		Description: "Skill",
		Order:       "name",
	}).AddFields(
		orm.Char("name", orm.FieldOpts{String: "Name", Required: true}),
		orm.Many2one("skill_type_id", "hr.skill.type", orm.FieldOpts{String: "Skill Type", Required: true}),
	)

	orm.NewModel("hr.employee.skill", orm.ModelOpts{
		Description: "Employee Skill",
	}).AddFields(
		orm.Many2one("employee_id", "hr.employee", orm.FieldOpts{String: "Employee", Required: true, OnDelete: orm.OnDeleteCascade}),
		orm.Many2one("skill_id", "hr.skill", orm.FieldOpts{String: "Skill", Required: true}),
		orm.Many2one("skill_type_id", "hr.skill.type", orm.FieldOpts{String: "Skill Type"}),
		orm.Selection("skill_level", []orm.SelectionItem{
			{Value: "beginner", Label: "Beginner"},
			{Value: "intermediate", Label: "Intermediate"},
			{Value: "advanced", Label: "Advanced"},
			{Value: "expert", Label: "Expert"},
		}, orm.FieldOpts{String: "Level", Default: "beginner"}),
	)

	orm.NewModel("hr.resume.line", orm.ModelOpts{
		Description: "Resume Line",
		Order:       "date_start desc",
	}).AddFields(
		orm.Many2one("employee_id", "hr.employee", orm.FieldOpts{String: "Employee", Required: true, OnDelete: orm.OnDeleteCascade}),
		orm.Char("name", orm.FieldOpts{String: "Name", Required: true}),
		orm.Date("date_start", orm.FieldOpts{String: "Start Date", Required: true}),
		orm.Date("date_end", orm.FieldOpts{String: "End Date"}),
		orm.Text("description", orm.FieldOpts{String: "Description"}),
		orm.Selection("line_type_id", []orm.SelectionItem{
			{Value: "experience", Label: "Experience"},
			{Value: "education", Label: "Education"},
			{Value: "certification", Label: "Certification"},
		}, orm.FieldOpts{String: "Type", Default: "experience"}),
	)
}
