-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_move_line.go
213 lines (197 loc) · 11.4 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
package odoo
// AccountMoveLine represents account.move.line model.
type AccountMoveLine struct {
AccountId *Many2One `xmlrpc:"account_id,omitempty"`
AccountInternalGroup *Selection `xmlrpc:"account_internal_group,omitempty"`
AccountRootId *Many2One `xmlrpc:"account_root_id,omitempty"`
AccountType *Selection `xmlrpc:"account_type,omitempty"`
AmountCurrency *Float `xmlrpc:"amount_currency,omitempty"`
AmountResidual *Float `xmlrpc:"amount_residual,omitempty"`
AmountResidualCurrency *Float `xmlrpc:"amount_residual_currency,omitempty"`
AnalyticDistribution interface{} `xmlrpc:"analytic_distribution,omitempty"`
AnalyticDistributionSearch interface{} `xmlrpc:"analytic_distribution_search,omitempty"`
AnalyticLineIds *Relation `xmlrpc:"analytic_line_ids,omitempty"`
AnalyticPrecision *Int `xmlrpc:"analytic_precision,omitempty"`
AssetIds *Relation `xmlrpc:"asset_ids,omitempty"`
Balance *Float `xmlrpc:"balance,omitempty"`
Blocked *Bool `xmlrpc:"blocked,omitempty"`
CogsOriginId *Many2One `xmlrpc:"cogs_origin_id,omitempty"`
CompanyCurrencyId *Many2One `xmlrpc:"company_currency_id,omitempty"`
CompanyId *Many2One `xmlrpc:"company_id,omitempty"`
ComputeAllTax *String `xmlrpc:"compute_all_tax,omitempty"`
ComputeAllTaxDirty *Bool `xmlrpc:"compute_all_tax_dirty,omitempty"`
CreateDate *Time `xmlrpc:"create_date,omitempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omitempty"`
Credit *Float `xmlrpc:"credit,omitempty"`
CumulatedBalance *Float `xmlrpc:"cumulated_balance,omitempty"`
CurrencyId *Many2One `xmlrpc:"currency_id,omitempty"`
CurrencyRate *Float `xmlrpc:"currency_rate,omitempty"`
Date *Time `xmlrpc:"date,omitempty"`
DateMaturity *Time `xmlrpc:"date_maturity,omitempty"`
Debit *Float `xmlrpc:"debit,omitempty"`
DeferredEndDate *Time `xmlrpc:"deferred_end_date,omitempty"`
DeferredStartDate *Time `xmlrpc:"deferred_start_date,omitempty"`
Discount *Float `xmlrpc:"discount,omitempty"`
DiscountAllocationDirty *Bool `xmlrpc:"discount_allocation_dirty,omitempty"`
DiscountAllocationKey *String `xmlrpc:"discount_allocation_key,omitempty"`
DiscountAllocationNeeded *String `xmlrpc:"discount_allocation_needed,omitempty"`
DiscountAmountCurrency *Float `xmlrpc:"discount_amount_currency,omitempty"`
DiscountBalance *Float `xmlrpc:"discount_balance,omitempty"`
DiscountDate *Time `xmlrpc:"discount_date,omitempty"`
DisplayName *String `xmlrpc:"display_name,omitempty"`
DisplayType *Selection `xmlrpc:"display_type,omitempty"`
EpdDirty *Bool `xmlrpc:"epd_dirty,omitempty"`
EpdKey *String `xmlrpc:"epd_key,omitempty"`
EpdNeeded *String `xmlrpc:"epd_needed,omitempty"`
ExpectedPayDate *Time `xmlrpc:"expected_pay_date,omitempty"`
ExpenseId *Many2One `xmlrpc:"expense_id,omitempty"`
FollowupLineId *Many2One `xmlrpc:"followup_line_id,omitempty"`
FullReconcileId *Many2One `xmlrpc:"full_reconcile_id,omitempty"`
GroupTaxId *Many2One `xmlrpc:"group_tax_id,omitempty"`
HasDeferredMoves *Bool `xmlrpc:"has_deferred_moves,omitempty"`
Id *Int `xmlrpc:"id,omitempty"`
InvoiceDate *Time `xmlrpc:"invoice_date,omitempty"`
InvoiceOrigin *String `xmlrpc:"invoice_origin,omitempty"`
IsAccountReconcile *Bool `xmlrpc:"is_account_reconcile,omitempty"`
IsDownpayment *Bool `xmlrpc:"is_downpayment,omitempty"`
IsRefund *Bool `xmlrpc:"is_refund,omitempty"`
IsSameCurrency *Bool `xmlrpc:"is_same_currency,omitempty"`
IsStorno *Bool `xmlrpc:"is_storno,omitempty"`
JournalId *Many2One `xmlrpc:"journal_id,omitempty"`
LastFollowupDate *Time `xmlrpc:"last_followup_date,omitempty"`
MatchedCreditIds *Relation `xmlrpc:"matched_credit_ids,omitempty"`
MatchedDebitIds *Relation `xmlrpc:"matched_debit_ids,omitempty"`
MatchingNumber *String `xmlrpc:"matching_number,omitempty"`
MoveAttachmentIds *Relation `xmlrpc:"move_attachment_ids,omitempty"`
MoveId *Many2One `xmlrpc:"move_id,omitempty"`
MoveName *String `xmlrpc:"move_name,omitempty"`
MoveType *Selection `xmlrpc:"move_type,omitempty"`
Name *String `xmlrpc:"name,omitempty"`
NeedVehicle *Bool `xmlrpc:"need_vehicle,omitempty"`
NextActionDate *Time `xmlrpc:"next_action_date,omitempty"`
NonDeductibleTaxValue *Float `xmlrpc:"non_deductible_tax_value,omitempty"`
ParentState *Selection `xmlrpc:"parent_state,omitempty"`
PartnerId *Many2One `xmlrpc:"partner_id,omitempty"`
PaymentDate *Time `xmlrpc:"payment_date,omitempty"`
PaymentId *Many2One `xmlrpc:"payment_id,omitempty"`
PriceSubtotal *Float `xmlrpc:"price_subtotal,omitempty"`
PriceTotal *Float `xmlrpc:"price_total,omitempty"`
PriceUnit *Float `xmlrpc:"price_unit,omitempty"`
ProductId *Many2One `xmlrpc:"product_id,omitempty"`
ProductUomCategoryId *Many2One `xmlrpc:"product_uom_category_id,omitempty"`
ProductUomId *Many2One `xmlrpc:"product_uom_id,omitempty"`
PurchaseLineId *Many2One `xmlrpc:"purchase_line_id,omitempty"`
PurchaseOrderId *Many2One `xmlrpc:"purchase_order_id,omitempty"`
Quantity *Float `xmlrpc:"quantity,omitempty"`
ReconcileModelId *Many2One `xmlrpc:"reconcile_model_id,omitempty"`
Reconciled *Bool `xmlrpc:"reconciled,omitempty"`
Ref *String `xmlrpc:"ref,omitempty"`
SaleLineIds *Relation `xmlrpc:"sale_line_ids,omitempty"`
Sequence *Int `xmlrpc:"sequence,omitempty"`
StatementId *Many2One `xmlrpc:"statement_id,omitempty"`
StatementLineId *Many2One `xmlrpc:"statement_line_id,omitempty"`
StockValuationLayerIds *Relation `xmlrpc:"stock_valuation_layer_ids,omitempty"`
TaxBaseAmount *Float `xmlrpc:"tax_base_amount,omitempty"`
TaxCalculationRoundingMethod *Selection `xmlrpc:"tax_calculation_rounding_method,omitempty"`
TaxGroupId *Many2One `xmlrpc:"tax_group_id,omitempty"`
TaxIds *Relation `xmlrpc:"tax_ids,omitempty"`
TaxKey *String `xmlrpc:"tax_key,omitempty"`
TaxLineId *Many2One `xmlrpc:"tax_line_id,omitempty"`
TaxRepartitionLineId *Many2One `xmlrpc:"tax_repartition_line_id,omitempty"`
TaxTagIds *Relation `xmlrpc:"tax_tag_ids,omitempty"`
TaxTagInvert *Bool `xmlrpc:"tax_tag_invert,omitempty"`
TermKey *String `xmlrpc:"term_key,omitempty"`
VehicleId *Many2One `xmlrpc:"vehicle_id,omitempty"`
WriteDate *Time `xmlrpc:"write_date,omitempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omitempty"`
}
// 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) {
ids, err := c.CreateAccountMoveLines([]*AccountMoveLine{aml})
if err != nil {
return -1, err
}
if len(ids) == 0 {
return -1, nil
}
return ids[0], nil
}
// CreateAccountMoveLine creates a new account.move.line model and returns its id.
func (c *Client) CreateAccountMoveLines(amls []*AccountMoveLine) ([]int64, error) {
var vv []interface{}
for _, v := range amls {
vv = append(vv, v)
}
return c.Create(AccountMoveLineModel, vv, nil)
}
// 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, nil)
}
// 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
}
return &((*amls)[0]), nil
}
// 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
}
return &((*amls)[0]), nil
}
// 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) {
return c.Search(AccountMoveLineModel, criteria, options)
}
// 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
}
return ids[0], nil
}