-
Notifications
You must be signed in to change notification settings - Fork 64
/
account_abstract_payment.go
125 lines (109 loc) · 5.04 KB
/
account_abstract_payment.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
121
122
123
124
125
package odoo
// AccountAbstractPayment represents account.abstract.payment model.
type AccountAbstractPayment struct {
LastUpdate *Time `xmlrpc:"__last_update,omitempty"`
Amount *Float `xmlrpc:"amount,omitempty"`
Communication *String `xmlrpc:"communication,omitempty"`
CompanyId *Many2One `xmlrpc:"company_id,omitempty"`
CurrencyId *Many2One `xmlrpc:"currency_id,omitempty"`
DisplayName *String `xmlrpc:"display_name,omitempty"`
HidePaymentMethod *Bool `xmlrpc:"hide_payment_method,omitempty"`
Id *Int `xmlrpc:"id,omitempty"`
JournalId *Many2One `xmlrpc:"journal_id,omitempty"`
PartnerId *Many2One `xmlrpc:"partner_id,omitempty"`
PartnerType *Selection `xmlrpc:"partner_type,omitempty"`
PaymentDate *Time `xmlrpc:"payment_date,omitempty"`
PaymentMethodCode *String `xmlrpc:"payment_method_code,omitempty"`
PaymentMethodId *Many2One `xmlrpc:"payment_method_id,omitempty"`
PaymentType *Selection `xmlrpc:"payment_type,omitempty"`
}
// AccountAbstractPayments represents array of account.abstract.payment model.
type AccountAbstractPayments []AccountAbstractPayment
// AccountAbstractPaymentModel is the odoo model name.
const AccountAbstractPaymentModel = "account.abstract.payment"
// Many2One convert AccountAbstractPayment to *Many2One.
func (aap *AccountAbstractPayment) Many2One() *Many2One {
return NewMany2One(aap.Id.Get(), "")
}
// CreateAccountAbstractPayment creates a new account.abstract.payment model and returns its id.
func (c *Client) CreateAccountAbstractPayment(aap *AccountAbstractPayment) (int64, error) {
ids, err := c.CreateAccountAbstractPayments([]*AccountAbstractPayment{aap})
if err != nil {
return -1, err
}
if len(ids) == 0 {
return -1, nil
}
return ids[0], nil
}
// CreateAccountAbstractPayments creates a new account.abstract.payment model and returns its id.
func (c *Client) CreateAccountAbstractPayments(aaps []*AccountAbstractPayment) ([]int64, error) {
var vv []interface{}
for _, v := range aaps {
vv = append(vv, v)
}
return c.Create(AccountAbstractPaymentModel, vv, nil)
}
// UpdateAccountAbstractPayment updates an existing account.abstract.payment record.
func (c *Client) UpdateAccountAbstractPayment(aap *AccountAbstractPayment) error {
return c.UpdateAccountAbstractPayments([]int64{aap.Id.Get()}, aap)
}
// UpdateAccountAbstractPayments updates existing account.abstract.payment records.
// All records (represented by ids) will be updated by aap values.
func (c *Client) UpdateAccountAbstractPayments(ids []int64, aap *AccountAbstractPayment) error {
return c.Update(AccountAbstractPaymentModel, ids, aap, nil)
}
// DeleteAccountAbstractPayment deletes an existing account.abstract.payment record.
func (c *Client) DeleteAccountAbstractPayment(id int64) error {
return c.DeleteAccountAbstractPayments([]int64{id})
}
// DeleteAccountAbstractPayments deletes existing account.abstract.payment records.
func (c *Client) DeleteAccountAbstractPayments(ids []int64) error {
return c.Delete(AccountAbstractPaymentModel, ids)
}
// GetAccountAbstractPayment gets account.abstract.payment existing record.
func (c *Client) GetAccountAbstractPayment(id int64) (*AccountAbstractPayment, error) {
aaps, err := c.GetAccountAbstractPayments([]int64{id})
if err != nil {
return nil, err
}
return &((*aaps)[0]), nil
}
// GetAccountAbstractPayments gets account.abstract.payment existing records.
func (c *Client) GetAccountAbstractPayments(ids []int64) (*AccountAbstractPayments, error) {
aaps := &AccountAbstractPayments{}
if err := c.Read(AccountAbstractPaymentModel, ids, nil, aaps); err != nil {
return nil, err
}
return aaps, nil
}
// FindAccountAbstractPayment finds account.abstract.payment record by querying it with criteria.
func (c *Client) FindAccountAbstractPayment(criteria *Criteria) (*AccountAbstractPayment, error) {
aaps := &AccountAbstractPayments{}
if err := c.SearchRead(AccountAbstractPaymentModel, criteria, NewOptions().Limit(1), aaps); err != nil {
return nil, err
}
return &((*aaps)[0]), nil
}
// FindAccountAbstractPayments finds account.abstract.payment records by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountAbstractPayments(criteria *Criteria, options *Options) (*AccountAbstractPayments, error) {
aaps := &AccountAbstractPayments{}
if err := c.SearchRead(AccountAbstractPaymentModel, criteria, options, aaps); err != nil {
return nil, err
}
return aaps, nil
}
// FindAccountAbstractPaymentIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountAbstractPaymentIds(criteria *Criteria, options *Options) ([]int64, error) {
return c.Search(AccountAbstractPaymentModel, criteria, options)
}
// FindAccountAbstractPaymentId finds record id by querying it with criteria.
func (c *Client) FindAccountAbstractPaymentId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(AccountAbstractPaymentModel, criteria, options)
if err != nil {
return -1, err
}
return ids[0], nil
}