forked from skilld-labs/go-odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_followup_report.go
114 lines (98 loc) · 4.13 KB
/
account_followup_report.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
package odoo
import (
"fmt"
)
// AccountFollowupReport represents account.followup.report model.
type AccountFollowupReport struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
}
// AccountFollowupReports represents array of account.followup.report model.
type AccountFollowupReports []AccountFollowupReport
// AccountFollowupReportModel is the odoo model name.
const AccountFollowupReportModel = "account.followup.report"
// Many2One convert AccountFollowupReport to *Many2One.
func (afr *AccountFollowupReport) Many2One() *Many2One {
return NewMany2One(afr.Id.Get(), "")
}
// CreateAccountFollowupReport creates a new account.followup.report model and returns its id.
func (c *Client) CreateAccountFollowupReport(afr *AccountFollowupReport) (int64, error) {
return c.Create(AccountFollowupReportModel, afr)
}
// UpdateAccountFollowupReport updates an existing account.followup.report record.
func (c *Client) UpdateAccountFollowupReport(afr *AccountFollowupReport) error {
return c.UpdateAccountFollowupReports([]int64{afr.Id.Get()}, afr)
}
// UpdateAccountFollowupReports updates existing account.followup.report records.
// All records (represented by ids) will be updated by afr values.
func (c *Client) UpdateAccountFollowupReports(ids []int64, afr *AccountFollowupReport) error {
return c.Update(AccountFollowupReportModel, ids, afr)
}
// DeleteAccountFollowupReport deletes an existing account.followup.report record.
func (c *Client) DeleteAccountFollowupReport(id int64) error {
return c.DeleteAccountFollowupReports([]int64{id})
}
// DeleteAccountFollowupReports deletes existing account.followup.report records.
func (c *Client) DeleteAccountFollowupReports(ids []int64) error {
return c.Delete(AccountFollowupReportModel, ids)
}
// GetAccountFollowupReport gets account.followup.report existing record.
func (c *Client) GetAccountFollowupReport(id int64) (*AccountFollowupReport, error) {
afrs, err := c.GetAccountFollowupReports([]int64{id})
if err != nil {
return nil, err
}
if afrs != nil && len(*afrs) > 0 {
return &((*afrs)[0]), nil
}
return nil, fmt.Errorf("id %v of account.followup.report not found", id)
}
// GetAccountFollowupReports gets account.followup.report existing records.
func (c *Client) GetAccountFollowupReports(ids []int64) (*AccountFollowupReports, error) {
afrs := &AccountFollowupReports{}
if err := c.Read(AccountFollowupReportModel, ids, nil, afrs); err != nil {
return nil, err
}
return afrs, nil
}
// FindAccountFollowupReport finds account.followup.report record by querying it with criteria.
func (c *Client) FindAccountFollowupReport(criteria *Criteria) (*AccountFollowupReport, error) {
afrs := &AccountFollowupReports{}
if err := c.SearchRead(AccountFollowupReportModel, criteria, NewOptions().Limit(1), afrs); err != nil {
return nil, err
}
if afrs != nil && len(*afrs) > 0 {
return &((*afrs)[0]), nil
}
return nil, fmt.Errorf("account.followup.report was not found")
}
// FindAccountFollowupReports finds account.followup.report records by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountFollowupReports(criteria *Criteria, options *Options) (*AccountFollowupReports, error) {
afrs := &AccountFollowupReports{}
if err := c.SearchRead(AccountFollowupReportModel, criteria, options, afrs); err != nil {
return nil, err
}
return afrs, nil
}
// FindAccountFollowupReportIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountFollowupReportIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(AccountFollowupReportModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindAccountFollowupReportId finds record id by querying it with criteria.
func (c *Client) FindAccountFollowupReportId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(AccountFollowupReportModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("account.followup.report was not found")
}