-
Notifications
You must be signed in to change notification settings - Fork 64
/
account_payment_term_line.go
123 lines (107 loc) · 4.83 KB
/
account_payment_term_line.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
package odoo
// AccountPaymentTermLine represents account.payment.term.line model.
type AccountPaymentTermLine struct {
LastUpdate *Time `xmlrpc:"__last_update,omitempty"`
CreateDate *Time `xmlrpc:"create_date,omitempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omitempty"`
Days *Int `xmlrpc:"days,omitempty"`
DisplayName *String `xmlrpc:"display_name,omitempty"`
Id *Int `xmlrpc:"id,omitempty"`
Option *Selection `xmlrpc:"option,omitempty"`
PaymentId *Many2One `xmlrpc:"payment_id,omitempty"`
Sequence *Int `xmlrpc:"sequence,omitempty"`
Value *Selection `xmlrpc:"value,omitempty"`
ValueAmount *Float `xmlrpc:"value_amount,omitempty"`
WriteDate *Time `xmlrpc:"write_date,omitempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omitempty"`
}
// AccountPaymentTermLines represents array of account.payment.term.line model.
type AccountPaymentTermLines []AccountPaymentTermLine
// AccountPaymentTermLineModel is the odoo model name.
const AccountPaymentTermLineModel = "account.payment.term.line"
// Many2One convert AccountPaymentTermLine to *Many2One.
func (aptl *AccountPaymentTermLine) Many2One() *Many2One {
return NewMany2One(aptl.Id.Get(), "")
}
// CreateAccountPaymentTermLine creates a new account.payment.term.line model and returns its id.
func (c *Client) CreateAccountPaymentTermLine(aptl *AccountPaymentTermLine) (int64, error) {
ids, err := c.CreateAccountPaymentTermLines([]*AccountPaymentTermLine{aptl})
if err != nil {
return -1, err
}
if len(ids) == 0 {
return -1, nil
}
return ids[0], nil
}
// CreateAccountPaymentTermLines creates a new account.payment.term.line model and returns its id.
func (c *Client) CreateAccountPaymentTermLines(aptls []*AccountPaymentTermLine) ([]int64, error) {
var vv []interface{}
for _, v := range aptls {
vv = append(vv, v)
}
return c.Create(AccountPaymentTermLineModel, vv, nil)
}
// UpdateAccountPaymentTermLine updates an existing account.payment.term.line record.
func (c *Client) UpdateAccountPaymentTermLine(aptl *AccountPaymentTermLine) error {
return c.UpdateAccountPaymentTermLines([]int64{aptl.Id.Get()}, aptl)
}
// UpdateAccountPaymentTermLines updates existing account.payment.term.line records.
// All records (represented by ids) will be updated by aptl values.
func (c *Client) UpdateAccountPaymentTermLines(ids []int64, aptl *AccountPaymentTermLine) error {
return c.Update(AccountPaymentTermLineModel, ids, aptl, nil)
}
// DeleteAccountPaymentTermLine deletes an existing account.payment.term.line record.
func (c *Client) DeleteAccountPaymentTermLine(id int64) error {
return c.DeleteAccountPaymentTermLines([]int64{id})
}
// DeleteAccountPaymentTermLines deletes existing account.payment.term.line records.
func (c *Client) DeleteAccountPaymentTermLines(ids []int64) error {
return c.Delete(AccountPaymentTermLineModel, ids)
}
// GetAccountPaymentTermLine gets account.payment.term.line existing record.
func (c *Client) GetAccountPaymentTermLine(id int64) (*AccountPaymentTermLine, error) {
aptls, err := c.GetAccountPaymentTermLines([]int64{id})
if err != nil {
return nil, err
}
return &((*aptls)[0]), nil
}
// GetAccountPaymentTermLines gets account.payment.term.line existing records.
func (c *Client) GetAccountPaymentTermLines(ids []int64) (*AccountPaymentTermLines, error) {
aptls := &AccountPaymentTermLines{}
if err := c.Read(AccountPaymentTermLineModel, ids, nil, aptls); err != nil {
return nil, err
}
return aptls, nil
}
// FindAccountPaymentTermLine finds account.payment.term.line record by querying it with criteria.
func (c *Client) FindAccountPaymentTermLine(criteria *Criteria) (*AccountPaymentTermLine, error) {
aptls := &AccountPaymentTermLines{}
if err := c.SearchRead(AccountPaymentTermLineModel, criteria, NewOptions().Limit(1), aptls); err != nil {
return nil, err
}
return &((*aptls)[0]), nil
}
// FindAccountPaymentTermLines finds account.payment.term.line records by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountPaymentTermLines(criteria *Criteria, options *Options) (*AccountPaymentTermLines, error) {
aptls := &AccountPaymentTermLines{}
if err := c.SearchRead(AccountPaymentTermLineModel, criteria, options, aptls); err != nil {
return nil, err
}
return aptls, nil
}
// FindAccountPaymentTermLineIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountPaymentTermLineIds(criteria *Criteria, options *Options) ([]int64, error) {
return c.Search(AccountPaymentTermLineModel, criteria, options)
}
// FindAccountPaymentTermLineId finds record id by querying it with criteria.
func (c *Client) FindAccountPaymentTermLineId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(AccountPaymentTermLineModel, criteria, options)
if err != nil {
return -1, err
}
return ids[0], nil
}