forked from skilld-labs/go-odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount_aged_receivable.go
113 lines (97 loc) · 4.19 KB
/
account_aged_receivable.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
package odoo
// AccountAgedReceivable represents account.aged.receivable model.
type AccountAgedReceivable struct {
LastUpdate *Time `xmlrpc:"__last_update,omitempty"`
DisplayName *String `xmlrpc:"display_name,omitempty"`
Id *Int `xmlrpc:"id,omitempty"`
}
// AccountAgedReceivables represents array of account.aged.receivable model.
type AccountAgedReceivables []AccountAgedReceivable
// AccountAgedReceivableModel is the odoo model name.
const AccountAgedReceivableModel = "account.aged.receivable"
// Many2One convert AccountAgedReceivable to *Many2One.
func (aar *AccountAgedReceivable) Many2One() *Many2One {
return NewMany2One(aar.Id.Get(), "")
}
// CreateAccountAgedReceivable creates a new account.aged.receivable model and returns its id.
func (c *Client) CreateAccountAgedReceivable(aar *AccountAgedReceivable) (int64, error) {
ids, err := c.CreateAccountAgedReceivables([]*AccountAgedReceivable{aar})
if err != nil {
return -1, err
}
if len(ids) == 0 {
return -1, nil
}
return ids[0], nil
}
// CreateAccountAgedReceivable creates a new account.aged.receivable model and returns its id.
func (c *Client) CreateAccountAgedReceivables(aars []*AccountAgedReceivable) ([]int64, error) {
var vv []interface{}
for _, v := range aars {
vv = append(vv, v)
}
return c.Create(AccountAgedReceivableModel, vv, nil)
}
// UpdateAccountAgedReceivable updates an existing account.aged.receivable record.
func (c *Client) UpdateAccountAgedReceivable(aar *AccountAgedReceivable) error {
return c.UpdateAccountAgedReceivables([]int64{aar.Id.Get()}, aar)
}
// UpdateAccountAgedReceivables updates existing account.aged.receivable records.
// All records (represented by ids) will be updated by aar values.
func (c *Client) UpdateAccountAgedReceivables(ids []int64, aar *AccountAgedReceivable) error {
return c.Update(AccountAgedReceivableModel, ids, aar, nil)
}
// DeleteAccountAgedReceivable deletes an existing account.aged.receivable record.
func (c *Client) DeleteAccountAgedReceivable(id int64) error {
return c.DeleteAccountAgedReceivables([]int64{id})
}
// DeleteAccountAgedReceivables deletes existing account.aged.receivable records.
func (c *Client) DeleteAccountAgedReceivables(ids []int64) error {
return c.Delete(AccountAgedReceivableModel, ids)
}
// GetAccountAgedReceivable gets account.aged.receivable existing record.
func (c *Client) GetAccountAgedReceivable(id int64) (*AccountAgedReceivable, error) {
aars, err := c.GetAccountAgedReceivables([]int64{id})
if err != nil {
return nil, err
}
return &((*aars)[0]), nil
}
// GetAccountAgedReceivables gets account.aged.receivable existing records.
func (c *Client) GetAccountAgedReceivables(ids []int64) (*AccountAgedReceivables, error) {
aars := &AccountAgedReceivables{}
if err := c.Read(AccountAgedReceivableModel, ids, nil, aars); err != nil {
return nil, err
}
return aars, nil
}
// FindAccountAgedReceivable finds account.aged.receivable record by querying it with criteria.
func (c *Client) FindAccountAgedReceivable(criteria *Criteria) (*AccountAgedReceivable, error) {
aars := &AccountAgedReceivables{}
if err := c.SearchRead(AccountAgedReceivableModel, criteria, NewOptions().Limit(1), aars); err != nil {
return nil, err
}
return &((*aars)[0]), nil
}
// FindAccountAgedReceivables finds account.aged.receivable records by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountAgedReceivables(criteria *Criteria, options *Options) (*AccountAgedReceivables, error) {
aars := &AccountAgedReceivables{}
if err := c.SearchRead(AccountAgedReceivableModel, criteria, options, aars); err != nil {
return nil, err
}
return aars, nil
}
// FindAccountAgedReceivableIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountAgedReceivableIds(criteria *Criteria, options *Options) ([]int64, error) {
return c.Search(AccountAgedReceivableModel, criteria, options)
}
// FindAccountAgedReceivableId finds record id by querying it with criteria.
func (c *Client) FindAccountAgedReceivableId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(AccountAgedReceivableModel, criteria, options)
if err != nil {
return -1, err
}
return ids[0], nil
}