forked from skilld-labs/go-odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_move_line.go
165 lines (149 loc) · 7.29 KB
/
account_move_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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package odoo
import (
"fmt"
)
// AccountMoveLine represents account.move.line model.
type AccountMoveLine struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
AccountId *Many2One `xmlrpc:"account_id,omptempty"`
AmountCurrency *Float `xmlrpc:"amount_currency,omptempty"`
AmountResidual *Float `xmlrpc:"amount_residual,omptempty"`
AmountResidualCurrency *Float `xmlrpc:"amount_residual_currency,omptempty"`
AnalyticAccountId *Many2One `xmlrpc:"analytic_account_id,omptempty"`
AnalyticLineIds *Relation `xmlrpc:"analytic_line_ids,omptempty"`
AnalyticTagIds *Relation `xmlrpc:"analytic_tag_ids,omptempty"`
Balance *Float `xmlrpc:"balance,omptempty"`
BalanceCashBasis *Float `xmlrpc:"balance_cash_basis,omptempty"`
Blocked *Bool `xmlrpc:"blocked,omptempty"`
CompanyCurrencyId *Many2One `xmlrpc:"company_currency_id,omptempty"`
CompanyId *Many2One `xmlrpc:"company_id,omptempty"`
Counterpart *String `xmlrpc:"counterpart,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
Credit *Float `xmlrpc:"credit,omptempty"`
CreditCashBasis *Float `xmlrpc:"credit_cash_basis,omptempty"`
CurrencyId *Many2One `xmlrpc:"currency_id,omptempty"`
Date *Time `xmlrpc:"date,omptempty"`
DateMaturity *Time `xmlrpc:"date_maturity,omptempty"`
Debit *Float `xmlrpc:"debit,omptempty"`
DebitCashBasis *Float `xmlrpc:"debit_cash_basis,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
ExpectedPayDate *Time `xmlrpc:"expected_pay_date,omptempty"`
FullReconcileId *Many2One `xmlrpc:"full_reconcile_id,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
InternalNote *String `xmlrpc:"internal_note,omptempty"`
InvoiceId *Many2One `xmlrpc:"invoice_id,omptempty"`
IsUnaffectedEarningsLine *Bool `xmlrpc:"is_unaffected_earnings_line,omptempty"`
JournalId *Many2One `xmlrpc:"journal_id,omptempty"`
MatchedCreditIds *Relation `xmlrpc:"matched_credit_ids,omptempty"`
MatchedDebitIds *Relation `xmlrpc:"matched_debit_ids,omptempty"`
MoveId *Many2One `xmlrpc:"move_id,omptempty"`
Name *String `xmlrpc:"name,omptempty"`
Narration *String `xmlrpc:"narration,omptempty"`
NextActionDate *Time `xmlrpc:"next_action_date,omptempty"`
ParentState *String `xmlrpc:"parent_state,omptempty"`
PartnerId *Many2One `xmlrpc:"partner_id,omptempty"`
PaymentId *Many2One `xmlrpc:"payment_id,omptempty"`
ProductId *Many2One `xmlrpc:"product_id,omptempty"`
ProductUomId *Many2One `xmlrpc:"product_uom_id,omptempty"`
Quantity *Float `xmlrpc:"quantity,omptempty"`
Reconciled *Bool `xmlrpc:"reconciled,omptempty"`
Ref *String `xmlrpc:"ref,omptempty"`
StatementId *Many2One `xmlrpc:"statement_id,omptempty"`
StatementLineId *Many2One `xmlrpc:"statement_line_id,omptempty"`
TaxBaseAmount *Float `xmlrpc:"tax_base_amount,omptempty"`
TaxExigible *Bool `xmlrpc:"tax_exigible,omptempty"`
TaxIds *Relation `xmlrpc:"tax_ids,omptempty"`
TaxLineId *Many2One `xmlrpc:"tax_line_id,omptempty"`
UserTypeId *Many2One `xmlrpc:"user_type_id,omptempty"`
WriteDate *Time `xmlrpc:"write_date,omptempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}
// AccountMoveLines represents array of account.move.line model.
type AccountMoveLines []AccountMoveLine
// AccountMoveLineModel is the odoo model name.
const AccountMoveLineModel = "account.move.line"
// Many2One convert AccountMoveLine to *Many2One.
func (aml *AccountMoveLine) Many2One() *Many2One {
return NewMany2One(aml.Id.Get(), "")
}
// CreateAccountMoveLine creates a new account.move.line model and returns its id.
func (c *Client) CreateAccountMoveLine(aml *AccountMoveLine) (int64, error) {
return c.Create(AccountMoveLineModel, aml)
}
// UpdateAccountMoveLine updates an existing account.move.line record.
func (c *Client) UpdateAccountMoveLine(aml *AccountMoveLine) error {
return c.UpdateAccountMoveLines([]int64{aml.Id.Get()}, aml)
}
// UpdateAccountMoveLines updates existing account.move.line records.
// All records (represented by ids) will be updated by aml values.
func (c *Client) UpdateAccountMoveLines(ids []int64, aml *AccountMoveLine) error {
return c.Update(AccountMoveLineModel, ids, aml)
}
// DeleteAccountMoveLine deletes an existing account.move.line record.
func (c *Client) DeleteAccountMoveLine(id int64) error {
return c.DeleteAccountMoveLines([]int64{id})
}
// DeleteAccountMoveLines deletes existing account.move.line records.
func (c *Client) DeleteAccountMoveLines(ids []int64) error {
return c.Delete(AccountMoveLineModel, ids)
}
// GetAccountMoveLine gets account.move.line existing record.
func (c *Client) GetAccountMoveLine(id int64) (*AccountMoveLine, error) {
amls, err := c.GetAccountMoveLines([]int64{id})
if err != nil {
return nil, err
}
if amls != nil && len(*amls) > 0 {
return &((*amls)[0]), nil
}
return nil, fmt.Errorf("id %v of account.move.line not found", id)
}
// GetAccountMoveLines gets account.move.line existing records.
func (c *Client) GetAccountMoveLines(ids []int64) (*AccountMoveLines, error) {
amls := &AccountMoveLines{}
if err := c.Read(AccountMoveLineModel, ids, nil, amls); err != nil {
return nil, err
}
return amls, nil
}
// FindAccountMoveLine finds account.move.line record by querying it with criteria.
func (c *Client) FindAccountMoveLine(criteria *Criteria) (*AccountMoveLine, error) {
amls := &AccountMoveLines{}
if err := c.SearchRead(AccountMoveLineModel, criteria, NewOptions().Limit(1), amls); err != nil {
return nil, err
}
if amls != nil && len(*amls) > 0 {
return &((*amls)[0]), nil
}
return nil, fmt.Errorf("account.move.line was not found")
}
// FindAccountMoveLines finds account.move.line records by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountMoveLines(criteria *Criteria, options *Options) (*AccountMoveLines, error) {
amls := &AccountMoveLines{}
if err := c.SearchRead(AccountMoveLineModel, criteria, options, amls); err != nil {
return nil, err
}
return amls, nil
}
// FindAccountMoveLineIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountMoveLineIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(AccountMoveLineModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindAccountMoveLineId finds record id by querying it with criteria.
func (c *Client) FindAccountMoveLineId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(AccountMoveLineModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("account.move.line was not found")
}