-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathhr_job.go
140 lines (124 loc) · 5.04 KB
/
hr_job.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
package odoo
import (
"fmt"
)
// HrJob represents hr.job model.
type HrJob struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
CompanyId *Many2One `xmlrpc:"company_id,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
DepartmentId *Many2One `xmlrpc:"department_id,omptempty"`
Description *String `xmlrpc:"description,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
EmployeeIds *Relation `xmlrpc:"employee_ids,omptempty"`
ExpectedEmployees *Int `xmlrpc:"expected_employees,omptempty"`
Id *Int `xmlrpc:"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"`
NoOfEmployee *Int `xmlrpc:"no_of_employee,omptempty"`
NoOfHiredEmployee *Int `xmlrpc:"no_of_hired_employee,omptempty"`
NoOfRecruitment *Int `xmlrpc:"no_of_recruitment,omptempty"`
Requirements *String `xmlrpc:"requirements,omptempty"`
State *Selection `xmlrpc:"state,omptempty"`
WebsiteMessageIds *Relation `xmlrpc:"website_message_ids,omptempty"`
WriteDate *Time `xmlrpc:"write_date,omptempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}
// HrJobs represents array of hr.job model.
type HrJobs []HrJob
// HrJobModel is the odoo model name.
const HrJobModel = "hr.job"
// Many2One convert HrJob to *Many2One.
func (hj *HrJob) Many2One() *Many2One {
return NewMany2One(hj.Id.Get(), "")
}
// CreateHrJob creates a new hr.job model and returns its id.
func (c *Client) CreateHrJob(hj *HrJob) (int64, error) {
return c.Create(HrJobModel, hj)
}
// UpdateHrJob updates an existing hr.job record.
func (c *Client) UpdateHrJob(hj *HrJob) error {
return c.UpdateHrJobs([]int64{hj.Id.Get()}, hj)
}
// UpdateHrJobs updates existing hr.job records.
// All records (represented by ids) will be updated by hj values.
func (c *Client) UpdateHrJobs(ids []int64, hj *HrJob) error {
return c.Update(HrJobModel, ids, hj)
}
// DeleteHrJob deletes an existing hr.job record.
func (c *Client) DeleteHrJob(id int64) error {
return c.DeleteHrJobs([]int64{id})
}
// DeleteHrJobs deletes existing hr.job records.
func (c *Client) DeleteHrJobs(ids []int64) error {
return c.Delete(HrJobModel, ids)
}
// GetHrJob gets hr.job existing record.
func (c *Client) GetHrJob(id int64) (*HrJob, error) {
hjs, err := c.GetHrJobs([]int64{id})
if err != nil {
return nil, err
}
if hjs != nil && len(*hjs) > 0 {
return &((*hjs)[0]), nil
}
return nil, fmt.Errorf("id %v of hr.job not found", id)
}
// GetHrJobs gets hr.job existing records.
func (c *Client) GetHrJobs(ids []int64) (*HrJobs, error) {
hjs := &HrJobs{}
if err := c.Read(HrJobModel, ids, nil, hjs); err != nil {
return nil, err
}
return hjs, nil
}
// FindHrJob finds hr.job record by querying it with criteria.
func (c *Client) FindHrJob(criteria *Criteria) (*HrJob, error) {
hjs := &HrJobs{}
if err := c.SearchRead(HrJobModel, criteria, NewOptions().Limit(1), hjs); err != nil {
return nil, err
}
if hjs != nil && len(*hjs) > 0 {
return &((*hjs)[0]), nil
}
return nil, fmt.Errorf("no hr.job was found with criteria %v", criteria)
}
// FindHrJobs finds hr.job records by querying it
// and filtering it with criteria and options.
func (c *Client) FindHrJobs(criteria *Criteria, options *Options) (*HrJobs, error) {
hjs := &HrJobs{}
if err := c.SearchRead(HrJobModel, criteria, options, hjs); err != nil {
return nil, err
}
return hjs, nil
}
// FindHrJobIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindHrJobIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(HrJobModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindHrJobId finds record id by querying it with criteria.
func (c *Client) FindHrJobId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(HrJobModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no hr.job was found with criteria %v and options %v", criteria, options)
}