Skip to content

Commit e429767

Browse files
committed
add new model: mail.followers
1 parent 54a333e commit e429767

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

mail_followers.go

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
package odoo
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// MailFollowers represents mail.followers model.
8+
type MailFollowers struct {
9+
LastUpdate *Time `xmlrpc:"__last_update,omitempty"`
10+
ChannelId *Many2One `xmlrpc:"channel_id,omitempty"`
11+
DisplayName *String `xmlrpc:"display_name,omitempty"`
12+
Id *Int `xmlrpc:"id,omitempty"`
13+
PartnerId *Many2One `xmlrpc:"partner_id,omitempty"`
14+
ResId *Int `xmlrpc:"res_id,omitempty"`
15+
ResModel *String `xmlrpc:"res_model,omitempty"`
16+
SubtypeIds *Relation `xmlrpc:"subtype_ids,omitempty"`
17+
}
18+
19+
// MailFollowerss represents array of mail.followers model.
20+
type MailFollowerss []MailFollowers
21+
22+
// MailFollowersModel is the odoo model name.
23+
const MailFollowersModel = "mail.followers"
24+
25+
// Many2One convert MailFollowers to *Many2One.
26+
func (mf *MailFollowers) Many2One() *Many2One {
27+
return NewMany2One(mf.Id.Get(), "")
28+
}
29+
30+
// CreateMailFollowers creates a new mail.followers model and returns its id.
31+
func (c *Client) CreateMailFollowers(mf *MailFollowers) (int64, error) {
32+
return c.Create(MailFollowersModel, mf)
33+
}
34+
35+
// UpdateMailFollowers updates an existing mail.followers record.
36+
func (c *Client) UpdateMailFollowers(mf *MailFollowers) error {
37+
return c.UpdateMailFollowerss([]int64{mf.Id.Get()}, mf)
38+
}
39+
40+
// UpdateMailFollowerss updates existing mail.followers records.
41+
// All records (represented by ids) will be updated by mf values.
42+
func (c *Client) UpdateMailFollowerss(ids []int64, mf *MailFollowers) error {
43+
return c.Update(MailFollowersModel, ids, mf)
44+
}
45+
46+
// DeleteMailFollowers deletes an existing mail.followers record.
47+
func (c *Client) DeleteMailFollowers(id int64) error {
48+
return c.DeleteMailFollowerss([]int64{id})
49+
}
50+
51+
// DeleteMailFollowerss deletes existing mail.followers records.
52+
func (c *Client) DeleteMailFollowerss(ids []int64) error {
53+
return c.Delete(MailFollowersModel, ids)
54+
}
55+
56+
// GetMailFollowers gets mail.followers existing record.
57+
func (c *Client) GetMailFollowers(id int64) (*MailFollowers, error) {
58+
mfs, err := c.GetMailFollowerss([]int64{id})
59+
if err != nil {
60+
return nil, err
61+
}
62+
if mfs != nil && len(*mfs) > 0 {
63+
return &((*mfs)[0]), nil
64+
}
65+
return nil, fmt.Errorf("id %v of mail.followers not found", id)
66+
}
67+
68+
// GetMailFollowerss gets mail.followers existing records.
69+
func (c *Client) GetMailFollowerss(ids []int64) (*MailFollowerss, error) {
70+
mfs := &MailFollowerss{}
71+
if err := c.Read(MailFollowersModel, ids, nil, mfs); err != nil {
72+
return nil, err
73+
}
74+
return mfs, nil
75+
}
76+
77+
// FindMailFollowers finds mail.followers record by querying it with criteria.
78+
func (c *Client) FindMailFollowers(criteria *Criteria) (*MailFollowers, error) {
79+
mfs := &MailFollowerss{}
80+
if err := c.SearchRead(MailFollowersModel, criteria, NewOptions().Limit(1), mfs); err != nil {
81+
return nil, err
82+
}
83+
if mfs != nil && len(*mfs) > 0 {
84+
return &((*mfs)[0]), nil
85+
}
86+
return nil, fmt.Errorf("mail.followers was not found")
87+
}
88+
89+
// FindMailFollowerss finds mail.followers records by querying it
90+
// and filtering it with criteria and options.
91+
func (c *Client) FindMailFollowerss(criteria *Criteria, options *Options) (*MailFollowerss, error) {
92+
mfs := &MailFollowerss{}
93+
if err := c.SearchRead(MailFollowersModel, criteria, options, mfs); err != nil {
94+
return nil, err
95+
}
96+
return mfs, nil
97+
}
98+
99+
// FindMailFollowersIds finds records ids by querying it
100+
// and filtering it with criteria and options.
101+
func (c *Client) FindMailFollowersIds(criteria *Criteria, options *Options) ([]int64, error) {
102+
ids, err := c.Search(MailFollowersModel, criteria, options)
103+
if err != nil {
104+
return []int64{}, err
105+
}
106+
return ids, nil
107+
}
108+
109+
// FindMailFollowersId finds record id by querying it with criteria.
110+
func (c *Client) FindMailFollowersId(criteria *Criteria, options *Options) (int64, error) {
111+
ids, err := c.Search(MailFollowersModel, criteria, options)
112+
if err != nil {
113+
return -1, err
114+
}
115+
if len(ids) > 0 {
116+
return ids[0], nil
117+
}
118+
return -1, fmt.Errorf("mail.followers was not found")
119+
}

0 commit comments

Comments
 (0)