-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathmail_followers.go
119 lines (103 loc) · 3.92 KB
/
mail_followers.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
package odoo
import (
"fmt"
)
// MailFollowers represents mail.followers model.
type MailFollowers struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
ChannelId *Many2One `xmlrpc:"channel_id,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
PartnerId *Many2One `xmlrpc:"partner_id,omptempty"`
ResId *Int `xmlrpc:"res_id,omptempty"`
ResModel *String `xmlrpc:"res_model,omptempty"`
SubtypeIds *Relation `xmlrpc:"subtype_ids,omptempty"`
}
// MailFollowerss represents array of mail.followers model.
type MailFollowerss []MailFollowers
// MailFollowersModel is the odoo model name.
const MailFollowersModel = "mail.followers"
// Many2One convert MailFollowers to *Many2One.
func (mf *MailFollowers) Many2One() *Many2One {
return NewMany2One(mf.Id.Get(), "")
}
// CreateMailFollowers creates a new mail.followers model and returns its id.
func (c *Client) CreateMailFollowers(mf *MailFollowers) (int64, error) {
return c.Create(MailFollowersModel, mf)
}
// UpdateMailFollowers updates an existing mail.followers record.
func (c *Client) UpdateMailFollowers(mf *MailFollowers) error {
return c.UpdateMailFollowerss([]int64{mf.Id.Get()}, mf)
}
// UpdateMailFollowerss updates existing mail.followers records.
// All records (represented by ids) will be updated by mf values.
func (c *Client) UpdateMailFollowerss(ids []int64, mf *MailFollowers) error {
return c.Update(MailFollowersModel, ids, mf)
}
// DeleteMailFollowers deletes an existing mail.followers record.
func (c *Client) DeleteMailFollowers(id int64) error {
return c.DeleteMailFollowerss([]int64{id})
}
// DeleteMailFollowerss deletes existing mail.followers records.
func (c *Client) DeleteMailFollowerss(ids []int64) error {
return c.Delete(MailFollowersModel, ids)
}
// GetMailFollowers gets mail.followers existing record.
func (c *Client) GetMailFollowers(id int64) (*MailFollowers, error) {
mfs, err := c.GetMailFollowerss([]int64{id})
if err != nil {
return nil, err
}
if mfs != nil && len(*mfs) > 0 {
return &((*mfs)[0]), nil
}
return nil, fmt.Errorf("id %v of mail.followers not found", id)
}
// GetMailFollowerss gets mail.followers existing records.
func (c *Client) GetMailFollowerss(ids []int64) (*MailFollowerss, error) {
mfs := &MailFollowerss{}
if err := c.Read(MailFollowersModel, ids, nil, mfs); err != nil {
return nil, err
}
return mfs, nil
}
// FindMailFollowers finds mail.followers record by querying it with criteria.
func (c *Client) FindMailFollowers(criteria *Criteria) (*MailFollowers, error) {
mfs := &MailFollowerss{}
if err := c.SearchRead(MailFollowersModel, criteria, NewOptions().Limit(1), mfs); err != nil {
return nil, err
}
if mfs != nil && len(*mfs) > 0 {
return &((*mfs)[0]), nil
}
return nil, fmt.Errorf("no mail.followers was found with criteria %v", criteria)
}
// FindMailFollowerss finds mail.followers records by querying it
// and filtering it with criteria and options.
func (c *Client) FindMailFollowerss(criteria *Criteria, options *Options) (*MailFollowerss, error) {
mfs := &MailFollowerss{}
if err := c.SearchRead(MailFollowersModel, criteria, options, mfs); err != nil {
return nil, err
}
return mfs, nil
}
// FindMailFollowersIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindMailFollowersIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(MailFollowersModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindMailFollowersId finds record id by querying it with criteria.
func (c *Client) FindMailFollowersId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(MailFollowersModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no mail.followers was found with criteria %v and options %v", criteria, options)
}