package models import "odoo-go/pkg/orm" // initResourceCalendar registers resource.calendar — working schedules. // Mirrors: odoo/addons/resource/models/resource.py func initResourceCalendar() { m := orm.NewModel("resource.calendar", orm.ModelOpts{ Description: "Resource Working Time", Order: "name", }) m.AddFields( orm.Char("name", orm.FieldOpts{String: "Name", Required: true}), orm.Boolean("active", orm.FieldOpts{String: "Active", Default: true}), orm.Many2one("company_id", "res.company", orm.FieldOpts{String: "Company"}), orm.Float("hours_per_week", orm.FieldOpts{String: "Hours per Week"}), orm.Char("tz", orm.FieldOpts{String: "Timezone", Default: "Europe/Berlin"}), orm.Boolean("flexible_hours", orm.FieldOpts{String: "Flexible Hours"}), orm.One2many("attendance_ids", "resource.calendar.attendance", "calendar_id", orm.FieldOpts{String: "Attendances"}), ) // resource.calendar.attendance — work time slots orm.NewModel("resource.calendar.attendance", orm.ModelOpts{ Description: "Work Detail", Order: "dayofweek, hour_from", }).AddFields( orm.Char("name", orm.FieldOpts{String: "Name", Required: true}), orm.Selection("dayofweek", []orm.SelectionItem{ {Value: "0", Label: "Monday"}, {Value: "1", Label: "Tuesday"}, {Value: "2", Label: "Wednesday"}, {Value: "3", Label: "Thursday"}, {Value: "4", Label: "Friday"}, {Value: "5", Label: "Saturday"}, {Value: "6", Label: "Sunday"}, }, orm.FieldOpts{String: "Day of Week", Required: true}), orm.Float("hour_from", orm.FieldOpts{String: "Work from", Required: true}), orm.Float("hour_to", orm.FieldOpts{String: "Work to", Required: true}), orm.Many2one("calendar_id", "resource.calendar", orm.FieldOpts{ String: "Calendar", Required: true, OnDelete: orm.OnDeleteCascade, }), ) } // initHREmployee registers the hr.employee model. // Mirrors: odoo/addons/hr/models/hr_employee.py func initHREmployee() { m := orm.NewModel("hr.employee", orm.ModelOpts{ Description: "Employee", Order: "name", }) m.AddFields( orm.Char("name", orm.FieldOpts{String: "Employee Name", Required: true, Index: true}), orm.Many2one("user_id", "res.users", orm.FieldOpts{String: "Related User"}), orm.Many2one("department_id", "hr.department", orm.FieldOpts{String: "Department", Index: true}), orm.Many2one("job_id", "hr.job", orm.FieldOpts{String: "Job Position"}), orm.Char("job_title", orm.FieldOpts{String: "Job Title"}), orm.Many2one("company_id", "res.company", orm.FieldOpts{ String: "Company", Required: true, Index: true, }), orm.Many2one("address_id", "res.partner", orm.FieldOpts{String: "Work Address"}), orm.Char("work_email", orm.FieldOpts{String: "Work Email"}), orm.Char("work_phone", orm.FieldOpts{String: "Work Phone"}), orm.Char("mobile_phone", orm.FieldOpts{String: "Work Mobile"}), orm.Many2one("coach_id", "hr.employee", orm.FieldOpts{String: "Coach"}), orm.Boolean("active", orm.FieldOpts{String: "Active", Default: true}), orm.Many2one("resource_calendar_id", "resource.calendar", orm.FieldOpts{String: "Working Schedule"}), orm.Selection("gender", []orm.SelectionItem{ {Value: "male", Label: "Male"}, {Value: "female", Label: "Female"}, {Value: "other", Label: "Other"}, }, orm.FieldOpts{String: "Gender"}), orm.Date("birthday", orm.FieldOpts{String: "Date of Birth", Groups: "hr.group_hr_user"}), orm.Selection("marital", []orm.SelectionItem{ {Value: "single", Label: "Single"}, {Value: "married", Label: "Married"}, {Value: "cohabitant", Label: "Legal Cohabitant"}, {Value: "widower", Label: "Widower"}, {Value: "divorced", Label: "Divorced"}, }, orm.FieldOpts{String: "Marital Status", Default: "single"}), orm.Char("emergency_contact", orm.FieldOpts{String: "Emergency Contact"}), orm.Char("emergency_phone", orm.FieldOpts{String: "Emergency Phone"}), orm.Selection("certificate", []orm.SelectionItem{ {Value: "graduate", Label: "Graduate"}, {Value: "bachelor", Label: "Bachelor"}, {Value: "master", Label: "Master"}, {Value: "doctor", Label: "Doctor"}, {Value: "other", Label: "Other"}, }, orm.FieldOpts{String: "Certificate Level"}), orm.Char("study_field", orm.FieldOpts{String: "Field of Study"}), orm.Char("visa_no", orm.FieldOpts{String: "Visa No", Groups: "hr.group_hr_user"}), orm.Char("permit_no", orm.FieldOpts{String: "Work Permit No", Groups: "hr.group_hr_user"}), orm.Integer("km_home_work", orm.FieldOpts{String: "Home-Work Distance (km)"}), orm.Binary("image_1920", orm.FieldOpts{String: "Image"}), ) } // initHRDepartment registers the hr.department model. // Mirrors: odoo/addons/hr/models/hr_department.py func initHRDepartment() { m := orm.NewModel("hr.department", orm.ModelOpts{ Description: "HR Department", Order: "name", }) m.AddFields( orm.Char("name", orm.FieldOpts{String: "Department Name", Required: true, Translate: true}), orm.Char("complete_name", orm.FieldOpts{ String: "Complete Name", Compute: "_compute_complete_name", Store: true, }), orm.Many2one("parent_id", "hr.department", orm.FieldOpts{String: "Parent Department", Index: true}), orm.Many2one("manager_id", "hr.employee", orm.FieldOpts{String: "Manager"}), orm.Many2one("company_id", "res.company", orm.FieldOpts{ String: "Company", Required: true, Index: true, }), orm.Boolean("active", orm.FieldOpts{String: "Active", Default: true}), orm.One2many("child_ids", "hr.department", "parent_id", orm.FieldOpts{String: "Child Departments"}), orm.One2many("member_ids", "hr.employee", "department_id", orm.FieldOpts{String: "Members"}), ) } // initHRJob registers the hr.job model. // Mirrors: odoo/addons/hr/models/hr_job.py func initHRJob() { m := orm.NewModel("hr.job", orm.ModelOpts{ Description: "Job Position", Order: "name", }) m.AddFields( orm.Char("name", orm.FieldOpts{String: "Job Position", Required: true, Index: true, Translate: true}), orm.Many2one("department_id", "hr.department", orm.FieldOpts{String: "Department"}), orm.Many2one("company_id", "res.company", orm.FieldOpts{ String: "Company", Required: true, Index: true, }), orm.Integer("expected_employees", orm.FieldOpts{String: "Expected New Employees", Default: 1}), orm.Integer("no_of_hired_employee", orm.FieldOpts{String: "Hired Employees"}), orm.Selection("state", []orm.SelectionItem{ {Value: "recruit", Label: "Recruitment in Progress"}, {Value: "open", Label: "Not Recruiting"}, }, orm.FieldOpts{String: "Status", Required: true, Default: "recruit"}), orm.Text("description", orm.FieldOpts{String: "Job Description"}), ) }