forked from skilld-labs/go-odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_aged_partner.go
114 lines (98 loc) · 3.94 KB
/
account_aged_partner.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"
)
// AccountAgedPartner represents account.aged.partner model.
type AccountAgedPartner struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
}
// AccountAgedPartners represents array of account.aged.partner model.
type AccountAgedPartners []AccountAgedPartner
// AccountAgedPartnerModel is the odoo model name.
const AccountAgedPartnerModel = "account.aged.partner"
// Many2One convert AccountAgedPartner to *Many2One.
func (aap *AccountAgedPartner) Many2One() *Many2One {
return NewMany2One(aap.Id.Get(), "")
}
// CreateAccountAgedPartner creates a new account.aged.partner model and returns its id.
func (c *Client) CreateAccountAgedPartner(aap *AccountAgedPartner) (int64, error) {
return c.Create(AccountAgedPartnerModel, aap)
}
// UpdateAccountAgedPartner updates an existing account.aged.partner record.
func (c *Client) UpdateAccountAgedPartner(aap *AccountAgedPartner) error {
return c.UpdateAccountAgedPartners([]int64{aap.Id.Get()}, aap)
}
// UpdateAccountAgedPartners updates existing account.aged.partner records.
// All records (represented by ids) will be updated by aap values.
func (c *Client) UpdateAccountAgedPartners(ids []int64, aap *AccountAgedPartner) error {
return c.Update(AccountAgedPartnerModel, ids, aap)
}
// DeleteAccountAgedPartner deletes an existing account.aged.partner record.
func (c *Client) DeleteAccountAgedPartner(id int64) error {
return c.DeleteAccountAgedPartners([]int64{id})
}
// DeleteAccountAgedPartners deletes existing account.aged.partner records.
func (c *Client) DeleteAccountAgedPartners(ids []int64) error {
return c.Delete(AccountAgedPartnerModel, ids)
}
// GetAccountAgedPartner gets account.aged.partner existing record.
func (c *Client) GetAccountAgedPartner(id int64) (*AccountAgedPartner, error) {
aaps, err := c.GetAccountAgedPartners([]int64{id})
if err != nil {
return nil, err
}
if aaps != nil && len(*aaps) > 0 {
return &((*aaps)[0]), nil
}
return nil, fmt.Errorf("id %v of account.aged.partner not found", id)
}
// GetAccountAgedPartners gets account.aged.partner existing records.
func (c *Client) GetAccountAgedPartners(ids []int64) (*AccountAgedPartners, error) {
aaps := &AccountAgedPartners{}
if err := c.Read(AccountAgedPartnerModel, ids, nil, aaps); err != nil {
return nil, err
}
return aaps, nil
}
// FindAccountAgedPartner finds account.aged.partner record by querying it with criteria.
func (c *Client) FindAccountAgedPartner(criteria *Criteria) (*AccountAgedPartner, error) {
aaps := &AccountAgedPartners{}
if err := c.SearchRead(AccountAgedPartnerModel, criteria, NewOptions().Limit(1), aaps); err != nil {
return nil, err
}
if aaps != nil && len(*aaps) > 0 {
return &((*aaps)[0]), nil
}
return nil, fmt.Errorf("account.aged.partner was not found")
}
// FindAccountAgedPartners finds account.aged.partner records by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountAgedPartners(criteria *Criteria, options *Options) (*AccountAgedPartners, error) {
aaps := &AccountAgedPartners{}
if err := c.SearchRead(AccountAgedPartnerModel, criteria, options, aaps); err != nil {
return nil, err
}
return aaps, nil
}
// FindAccountAgedPartnerIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountAgedPartnerIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(AccountAgedPartnerModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindAccountAgedPartnerId finds record id by querying it with criteria.
func (c *Client) FindAccountAgedPartnerId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(AccountAgedPartnerModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("account.aged.partner was not found")
}