-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathlink_tracker_code.go
120 lines (104 loc) · 4.13 KB
/
link_tracker_code.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
package odoo
import (
"fmt"
)
// LinkTrackerCode represents link.tracker.code model.
type LinkTrackerCode struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Code *String `xmlrpc:"code,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
LinkId *Many2One `xmlrpc:"link_id,omptempty"`
WriteDate *Time `xmlrpc:"write_date,omptempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}
// LinkTrackerCodes represents array of link.tracker.code model.
type LinkTrackerCodes []LinkTrackerCode
// LinkTrackerCodeModel is the odoo model name.
const LinkTrackerCodeModel = "link.tracker.code"
// Many2One convert LinkTrackerCode to *Many2One.
func (ltc *LinkTrackerCode) Many2One() *Many2One {
return NewMany2One(ltc.Id.Get(), "")
}
// CreateLinkTrackerCode creates a new link.tracker.code model and returns its id.
func (c *Client) CreateLinkTrackerCode(ltc *LinkTrackerCode) (int64, error) {
return c.Create(LinkTrackerCodeModel, ltc)
}
// UpdateLinkTrackerCode updates an existing link.tracker.code record.
func (c *Client) UpdateLinkTrackerCode(ltc *LinkTrackerCode) error {
return c.UpdateLinkTrackerCodes([]int64{ltc.Id.Get()}, ltc)
}
// UpdateLinkTrackerCodes updates existing link.tracker.code records.
// All records (represented by ids) will be updated by ltc values.
func (c *Client) UpdateLinkTrackerCodes(ids []int64, ltc *LinkTrackerCode) error {
return c.Update(LinkTrackerCodeModel, ids, ltc)
}
// DeleteLinkTrackerCode deletes an existing link.tracker.code record.
func (c *Client) DeleteLinkTrackerCode(id int64) error {
return c.DeleteLinkTrackerCodes([]int64{id})
}
// DeleteLinkTrackerCodes deletes existing link.tracker.code records.
func (c *Client) DeleteLinkTrackerCodes(ids []int64) error {
return c.Delete(LinkTrackerCodeModel, ids)
}
// GetLinkTrackerCode gets link.tracker.code existing record.
func (c *Client) GetLinkTrackerCode(id int64) (*LinkTrackerCode, error) {
ltcs, err := c.GetLinkTrackerCodes([]int64{id})
if err != nil {
return nil, err
}
if ltcs != nil && len(*ltcs) > 0 {
return &((*ltcs)[0]), nil
}
return nil, fmt.Errorf("id %v of link.tracker.code not found", id)
}
// GetLinkTrackerCodes gets link.tracker.code existing records.
func (c *Client) GetLinkTrackerCodes(ids []int64) (*LinkTrackerCodes, error) {
ltcs := &LinkTrackerCodes{}
if err := c.Read(LinkTrackerCodeModel, ids, nil, ltcs); err != nil {
return nil, err
}
return ltcs, nil
}
// FindLinkTrackerCode finds link.tracker.code record by querying it with criteria.
func (c *Client) FindLinkTrackerCode(criteria *Criteria) (*LinkTrackerCode, error) {
ltcs := &LinkTrackerCodes{}
if err := c.SearchRead(LinkTrackerCodeModel, criteria, NewOptions().Limit(1), ltcs); err != nil {
return nil, err
}
if ltcs != nil && len(*ltcs) > 0 {
return &((*ltcs)[0]), nil
}
return nil, fmt.Errorf("no link.tracker.code was found with criteria %v", criteria)
}
// FindLinkTrackerCodes finds link.tracker.code records by querying it
// and filtering it with criteria and options.
func (c *Client) FindLinkTrackerCodes(criteria *Criteria, options *Options) (*LinkTrackerCodes, error) {
ltcs := &LinkTrackerCodes{}
if err := c.SearchRead(LinkTrackerCodeModel, criteria, options, ltcs); err != nil {
return nil, err
}
return ltcs, nil
}
// FindLinkTrackerCodeIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindLinkTrackerCodeIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(LinkTrackerCodeModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindLinkTrackerCodeId finds record id by querying it with criteria.
func (c *Client) FindLinkTrackerCodeId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(LinkTrackerCodeModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no link.tracker.code was found with criteria %v and options %v", criteria, options)
}