-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathweb_tour_tour.go
116 lines (100 loc) · 3.63 KB
/
web_tour_tour.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
package odoo
import (
"fmt"
)
// WebTourTour represents web_tour.tour model.
type WebTourTour struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
Name *String `xmlrpc:"name,omptempty"`
UserId *Many2One `xmlrpc:"user_id,omptempty"`
}
// WebTourTours represents array of web_tour.tour model.
type WebTourTours []WebTourTour
// WebTourTourModel is the odoo model name.
const WebTourTourModel = "web_tour.tour"
// Many2One convert WebTourTour to *Many2One.
func (wt *WebTourTour) Many2One() *Many2One {
return NewMany2One(wt.Id.Get(), "")
}
// CreateWebTourTour creates a new web_tour.tour model and returns its id.
func (c *Client) CreateWebTourTour(wt *WebTourTour) (int64, error) {
return c.Create(WebTourTourModel, wt)
}
// UpdateWebTourTour updates an existing web_tour.tour record.
func (c *Client) UpdateWebTourTour(wt *WebTourTour) error {
return c.UpdateWebTourTours([]int64{wt.Id.Get()}, wt)
}
// UpdateWebTourTours updates existing web_tour.tour records.
// All records (represented by ids) will be updated by wt values.
func (c *Client) UpdateWebTourTours(ids []int64, wt *WebTourTour) error {
return c.Update(WebTourTourModel, ids, wt)
}
// DeleteWebTourTour deletes an existing web_tour.tour record.
func (c *Client) DeleteWebTourTour(id int64) error {
return c.DeleteWebTourTours([]int64{id})
}
// DeleteWebTourTours deletes existing web_tour.tour records.
func (c *Client) DeleteWebTourTours(ids []int64) error {
return c.Delete(WebTourTourModel, ids)
}
// GetWebTourTour gets web_tour.tour existing record.
func (c *Client) GetWebTourTour(id int64) (*WebTourTour, error) {
wts, err := c.GetWebTourTours([]int64{id})
if err != nil {
return nil, err
}
if wts != nil && len(*wts) > 0 {
return &((*wts)[0]), nil
}
return nil, fmt.Errorf("id %v of web_tour.tour not found", id)
}
// GetWebTourTours gets web_tour.tour existing records.
func (c *Client) GetWebTourTours(ids []int64) (*WebTourTours, error) {
wts := &WebTourTours{}
if err := c.Read(WebTourTourModel, ids, nil, wts); err != nil {
return nil, err
}
return wts, nil
}
// FindWebTourTour finds web_tour.tour record by querying it with criteria.
func (c *Client) FindWebTourTour(criteria *Criteria) (*WebTourTour, error) {
wts := &WebTourTours{}
if err := c.SearchRead(WebTourTourModel, criteria, NewOptions().Limit(1), wts); err != nil {
return nil, err
}
if wts != nil && len(*wts) > 0 {
return &((*wts)[0]), nil
}
return nil, fmt.Errorf("no web_tour.tour was found with criteria %v", criteria)
}
// FindWebTourTours finds web_tour.tour records by querying it
// and filtering it with criteria and options.
func (c *Client) FindWebTourTours(criteria *Criteria, options *Options) (*WebTourTours, error) {
wts := &WebTourTours{}
if err := c.SearchRead(WebTourTourModel, criteria, options, wts); err != nil {
return nil, err
}
return wts, nil
}
// FindWebTourTourIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindWebTourTourIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(WebTourTourModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindWebTourTourId finds record id by querying it with criteria.
func (c *Client) FindWebTourTourId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(WebTourTourModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no web_tour.tour was found with criteria %v and options %v", criteria, options)
}