package models

import "odoo-go/pkg/orm"

// initIrCron registers ir.cron — Scheduled actions.
// Mirrors: odoo/addons/base/models/ir_cron.py class IrCron
//
// Defines recurring tasks executed by the scheduler.
func initIrCron() {
	m := orm.NewModel("ir.cron", orm.ModelOpts{
		Description: "Scheduled Actions",
		Order:       "name",
	})

	m.AddFields(
		orm.Char("name", orm.FieldOpts{String: "Name", Required: true}),
		orm.Boolean("active", orm.FieldOpts{String: "Active", Default: true}),
		orm.Many2one("user_id", "res.users", orm.FieldOpts{String: "User", Required: true}),
		orm.Integer("interval_number", orm.FieldOpts{String: "Interval Number", Default: 1}),
		orm.Selection("interval_type", []orm.SelectionItem{
			{Value: "minutes", Label: "Minutes"},
			{Value: "hours", Label: "Hours"},
			{Value: "days", Label: "Days"},
			{Value: "weeks", Label: "Weeks"},
			{Value: "months", Label: "Months"},
		}, orm.FieldOpts{String: "Interval Type", Default: "months"}),
		orm.Integer("numbercall", orm.FieldOpts{String: "Number of Calls", Default: -1}),
		orm.Datetime("nextcall", orm.FieldOpts{String: "Next Execution Date", Required: true}),
		orm.Datetime("lastcall", orm.FieldOpts{String: "Last Execution Date"}),
		orm.Integer("priority", orm.FieldOpts{String: "Priority", Default: 5}),
		orm.Char("code", orm.FieldOpts{String: "Python Code"}),
		orm.Many2one("model_id", "ir.model", orm.FieldOpts{String: "Model"}),
	)
}
