-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathhr_holidays.go
154 lines (138 loc) · 6.32 KB
/
hr_holidays.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package odoo
import (
"fmt"
)
// HrHolidays represents hr.holidays model.
type HrHolidays struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
CanReset *Bool `xmlrpc:"can_reset,omptempty"`
CategoryId *Many2One `xmlrpc:"category_id,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
DateFrom *Time `xmlrpc:"date_from,omptempty"`
DateTo *Time `xmlrpc:"date_to,omptempty"`
DepartmentId *Many2One `xmlrpc:"department_id,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
DoubleValidation *Bool `xmlrpc:"double_validation,omptempty"`
EmployeeId *Many2One `xmlrpc:"employee_id,omptempty"`
FirstApproverId *Many2One `xmlrpc:"first_approver_id,omptempty"`
HolidayStatusId *Many2One `xmlrpc:"holiday_status_id,omptempty"`
HolidayType *Selection `xmlrpc:"holiday_type,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
LinkedRequestIds *Relation `xmlrpc:"linked_request_ids,omptempty"`
ManagerId *Many2One `xmlrpc:"manager_id,omptempty"`
MeetingId *Many2One `xmlrpc:"meeting_id,omptempty"`
MessageChannelIds *Relation `xmlrpc:"message_channel_ids,omptempty"`
MessageFollowerIds *Relation `xmlrpc:"message_follower_ids,omptempty"`
MessageIds *Relation `xmlrpc:"message_ids,omptempty"`
MessageIsFollower *Bool `xmlrpc:"message_is_follower,omptempty"`
MessageLastPost *Time `xmlrpc:"message_last_post,omptempty"`
MessageNeedaction *Bool `xmlrpc:"message_needaction,omptempty"`
MessageNeedactionCounter *Int `xmlrpc:"message_needaction_counter,omptempty"`
MessagePartnerIds *Relation `xmlrpc:"message_partner_ids,omptempty"`
MessageUnread *Bool `xmlrpc:"message_unread,omptempty"`
MessageUnreadCounter *Int `xmlrpc:"message_unread_counter,omptempty"`
Name *String `xmlrpc:"name,omptempty"`
Notes *String `xmlrpc:"notes,omptempty"`
NumberOfDays *Float `xmlrpc:"number_of_days,omptempty"`
NumberOfDaysTemp *Float `xmlrpc:"number_of_days_temp,omptempty"`
ParentId *Many2One `xmlrpc:"parent_id,omptempty"`
PayslipStatus *Bool `xmlrpc:"payslip_status,omptempty"`
ReportNote *String `xmlrpc:"report_note,omptempty"`
SecondApproverId *Many2One `xmlrpc:"second_approver_id,omptempty"`
State *Selection `xmlrpc:"state,omptempty"`
TimesheetIds *Relation `xmlrpc:"timesheet_ids,omptempty"`
Type *Selection `xmlrpc:"type,omptempty"`
UserId *Many2One `xmlrpc:"user_id,omptempty"`
WebsiteMessageIds *Relation `xmlrpc:"website_message_ids,omptempty"`
WriteDate *Time `xmlrpc:"write_date,omptempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}
// HrHolidayss represents array of hr.holidays model.
type HrHolidayss []HrHolidays
// HrHolidaysModel is the odoo model name.
const HrHolidaysModel = "hr.holidays"
// Many2One convert HrHolidays to *Many2One.
func (hh *HrHolidays) Many2One() *Many2One {
return NewMany2One(hh.Id.Get(), "")
}
// CreateHrHolidays creates a new hr.holidays model and returns its id.
func (c *Client) CreateHrHolidays(hh *HrHolidays) (int64, error) {
return c.Create(HrHolidaysModel, hh)
}
// UpdateHrHolidays updates an existing hr.holidays record.
func (c *Client) UpdateHrHolidays(hh *HrHolidays) error {
return c.UpdateHrHolidayss([]int64{hh.Id.Get()}, hh)
}
// UpdateHrHolidayss updates existing hr.holidays records.
// All records (represented by ids) will be updated by hh values.
func (c *Client) UpdateHrHolidayss(ids []int64, hh *HrHolidays) error {
return c.Update(HrHolidaysModel, ids, hh)
}
// DeleteHrHolidays deletes an existing hr.holidays record.
func (c *Client) DeleteHrHolidays(id int64) error {
return c.DeleteHrHolidayss([]int64{id})
}
// DeleteHrHolidayss deletes existing hr.holidays records.
func (c *Client) DeleteHrHolidayss(ids []int64) error {
return c.Delete(HrHolidaysModel, ids)
}
// GetHrHolidays gets hr.holidays existing record.
func (c *Client) GetHrHolidays(id int64) (*HrHolidays, error) {
hhs, err := c.GetHrHolidayss([]int64{id})
if err != nil {
return nil, err
}
if hhs != nil && len(*hhs) > 0 {
return &((*hhs)[0]), nil
}
return nil, fmt.Errorf("id %v of hr.holidays not found", id)
}
// GetHrHolidayss gets hr.holidays existing records.
func (c *Client) GetHrHolidayss(ids []int64) (*HrHolidayss, error) {
hhs := &HrHolidayss{}
if err := c.Read(HrHolidaysModel, ids, nil, hhs); err != nil {
return nil, err
}
return hhs, nil
}
// FindHrHolidays finds hr.holidays record by querying it with criteria.
func (c *Client) FindHrHolidays(criteria *Criteria) (*HrHolidays, error) {
hhs := &HrHolidayss{}
if err := c.SearchRead(HrHolidaysModel, criteria, NewOptions().Limit(1), hhs); err != nil {
return nil, err
}
if hhs != nil && len(*hhs) > 0 {
return &((*hhs)[0]), nil
}
return nil, fmt.Errorf("no hr.holidays was found with criteria %v", criteria)
}
// FindHrHolidayss finds hr.holidays records by querying it
// and filtering it with criteria and options.
func (c *Client) FindHrHolidayss(criteria *Criteria, options *Options) (*HrHolidayss, error) {
hhs := &HrHolidayss{}
if err := c.SearchRead(HrHolidaysModel, criteria, options, hhs); err != nil {
return nil, err
}
return hhs, nil
}
// FindHrHolidaysIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindHrHolidaysIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(HrHolidaysModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindHrHolidaysId finds record id by querying it with criteria.
func (c *Client) FindHrHolidaysId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(HrHolidaysModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no hr.holidays was found with criteria %v and options %v", criteria, options)
}