-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathmail_mass_mailing_stage.go
120 lines (104 loc) · 4.48 KB
/
mail_mass_mailing_stage.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"
)
// MailMassMailingStage represents mail.mass_mailing.stage model.
type MailMassMailingStage struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
Name *String `xmlrpc:"name,omptempty"`
Sequence *Int `xmlrpc:"sequence,omptempty"`
WriteDate *Time `xmlrpc:"write_date,omptempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}
// MailMassMailingStages represents array of mail.mass_mailing.stage model.
type MailMassMailingStages []MailMassMailingStage
// MailMassMailingStageModel is the odoo model name.
const MailMassMailingStageModel = "mail.mass_mailing.stage"
// Many2One convert MailMassMailingStage to *Many2One.
func (mms *MailMassMailingStage) Many2One() *Many2One {
return NewMany2One(mms.Id.Get(), "")
}
// CreateMailMassMailingStage creates a new mail.mass_mailing.stage model and returns its id.
func (c *Client) CreateMailMassMailingStage(mms *MailMassMailingStage) (int64, error) {
return c.Create(MailMassMailingStageModel, mms)
}
// UpdateMailMassMailingStage updates an existing mail.mass_mailing.stage record.
func (c *Client) UpdateMailMassMailingStage(mms *MailMassMailingStage) error {
return c.UpdateMailMassMailingStages([]int64{mms.Id.Get()}, mms)
}
// UpdateMailMassMailingStages updates existing mail.mass_mailing.stage records.
// All records (represented by ids) will be updated by mms values.
func (c *Client) UpdateMailMassMailingStages(ids []int64, mms *MailMassMailingStage) error {
return c.Update(MailMassMailingStageModel, ids, mms)
}
// DeleteMailMassMailingStage deletes an existing mail.mass_mailing.stage record.
func (c *Client) DeleteMailMassMailingStage(id int64) error {
return c.DeleteMailMassMailingStages([]int64{id})
}
// DeleteMailMassMailingStages deletes existing mail.mass_mailing.stage records.
func (c *Client) DeleteMailMassMailingStages(ids []int64) error {
return c.Delete(MailMassMailingStageModel, ids)
}
// GetMailMassMailingStage gets mail.mass_mailing.stage existing record.
func (c *Client) GetMailMassMailingStage(id int64) (*MailMassMailingStage, error) {
mmss, err := c.GetMailMassMailingStages([]int64{id})
if err != nil {
return nil, err
}
if mmss != nil && len(*mmss) > 0 {
return &((*mmss)[0]), nil
}
return nil, fmt.Errorf("id %v of mail.mass_mailing.stage not found", id)
}
// GetMailMassMailingStages gets mail.mass_mailing.stage existing records.
func (c *Client) GetMailMassMailingStages(ids []int64) (*MailMassMailingStages, error) {
mmss := &MailMassMailingStages{}
if err := c.Read(MailMassMailingStageModel, ids, nil, mmss); err != nil {
return nil, err
}
return mmss, nil
}
// FindMailMassMailingStage finds mail.mass_mailing.stage record by querying it with criteria.
func (c *Client) FindMailMassMailingStage(criteria *Criteria) (*MailMassMailingStage, error) {
mmss := &MailMassMailingStages{}
if err := c.SearchRead(MailMassMailingStageModel, criteria, NewOptions().Limit(1), mmss); err != nil {
return nil, err
}
if mmss != nil && len(*mmss) > 0 {
return &((*mmss)[0]), nil
}
return nil, fmt.Errorf("no mail.mass_mailing.stage was found with criteria %v", criteria)
}
// FindMailMassMailingStages finds mail.mass_mailing.stage records by querying it
// and filtering it with criteria and options.
func (c *Client) FindMailMassMailingStages(criteria *Criteria, options *Options) (*MailMassMailingStages, error) {
mmss := &MailMassMailingStages{}
if err := c.SearchRead(MailMassMailingStageModel, criteria, options, mmss); err != nil {
return nil, err
}
return mmss, nil
}
// FindMailMassMailingStageIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindMailMassMailingStageIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(MailMassMailingStageModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindMailMassMailingStageId finds record id by querying it with criteria.
func (c *Client) FindMailMassMailingStageId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(MailMassMailingStageModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no mail.mass_mailing.stage was found with criteria %v and options %v", criteria, options)
}