-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54a333e
commit e429767
Showing
1 changed file
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package odoo | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// MailFollowers represents mail.followers model. | ||
type MailFollowers struct { | ||
LastUpdate *Time `xmlrpc:"__last_update,omitempty"` | ||
ChannelId *Many2One `xmlrpc:"channel_id,omitempty"` | ||
DisplayName *String `xmlrpc:"display_name,omitempty"` | ||
Id *Int `xmlrpc:"id,omitempty"` | ||
PartnerId *Many2One `xmlrpc:"partner_id,omitempty"` | ||
ResId *Int `xmlrpc:"res_id,omitempty"` | ||
ResModel *String `xmlrpc:"res_model,omitempty"` | ||
SubtypeIds *Relation `xmlrpc:"subtype_ids,omitempty"` | ||
} | ||
|
||
// 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("mail.followers was not found") | ||
} | ||
|
||
// 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("mail.followers was not found") | ||
} |