forked from skilld-labs/go-odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount_analytic_line.go
124 lines (110 loc) · 5.46 KB
/
account_analytic_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
package odoo
import (
"fmt"
)
// AccountAnalyticLine represents account.analytic.line model
type AccountAnalyticLine struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
AccountId *Many2One `xmlrpc:"account_id,omptempty"`
Amount *Float `xmlrpc:"amount,omptempty"`
AmountCurrency *Float `xmlrpc:"amount_currency,omptempty"`
AnalyticAmountCurrency *Float `xmlrpc:"analytic_amount_currency,omptempty"`
Code *String `xmlrpc:"code,omptempty"`
CompanyCurrencyId *Many2One `xmlrpc:"company_currency_id,omptempty"`
CompanyId *Many2One `xmlrpc:"company_id,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
CurrencyId *Many2One `xmlrpc:"currency_id,omptempty"`
Date *Time `xmlrpc:"date,omptempty"`
DepartmentId *Many2One `xmlrpc:"department_id,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
EmployeeId *Many2One `xmlrpc:"employee_id,omptempty"`
GeneralAccountId *Many2One `xmlrpc:"general_account_id,omptempty"`
HolidayId *Many2One `xmlrpc:"holiday_id,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
MoveId *Many2One `xmlrpc:"move_id,omptempty"`
Name *String `xmlrpc:"name,omptempty"`
PartnerId *Many2One `xmlrpc:"partner_id,omptempty"`
ProductId *Many2One `xmlrpc:"product_id,omptempty"`
ProductUomId *Many2One `xmlrpc:"product_uom_id,omptempty"`
ProjectId *Many2One `xmlrpc:"project_id,omptempty"`
Ref *String `xmlrpc:"ref,omptempty"`
SoLine *Many2One `xmlrpc:"so_line,omptempty"`
TagIds *Relation `xmlrpc:"tag_ids,omptempty"`
TaskId *Many2One `xmlrpc:"task_id,omptempty"`
TimesheetInvoiceId *Many2One `xmlrpc:"timesheet_invoice_id,omptempty"`
TimesheetInvoiceType *Selection `xmlrpc:"timesheet_invoice_type,omptempty"`
TimesheetRevenue *Float `xmlrpc:"timesheet_revenue,omptempty"`
UnitAmount *Float `xmlrpc:"unit_amount,omptempty"`
UserId *Many2One `xmlrpc:"user_id,omptempty"`
WriteDate *Time `xmlrpc:"write_date,omptempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}
// AccountAnalyticLines represents array of account.analytic.line model
type AccountAnalyticLines []AccountAnalyticLine
// AccountAnalyticLineModel is the odoo model name
const AccountAnalyticLineModel = "account.analytic.line"
// Many2One convert AccountAnalyticLine to *Many2One.
func (aal *AccountAnalyticLine) Many2One() *Many2One {
return NewMany2One(aal.Id.Get(), "")
}
// CreateAccountAnalyticLine creates a new account.analytic.line model and returns its id.
func (c *Client) CreateAccountAnalyticLine(aal *AccountAnalyticLine) (int64, error) {
return c.Create(AccountAnalyticLineModel, aal)
}
// UpdateAccountAnalyticLine updates an existing account.analytic.line record.
func (c *Client) UpdateAccountAnalyticLine(aal *AccountAnalyticLine) error {
return c.UpdateAccountAnalyticLines([]int64{aal.Id.Get()}, aal)
}
// UpdateAccountAnalyticLines updates existing account.analytic.line records.
// All records (represented by ids) will be updated by aal values.
func (c *Client) UpdateAccountAnalyticLines(ids []int64, aal *AccountAnalyticLine) error {
return c.Update(AccountAnalyticLineModel, ids, aal)
}
// DeleteAccountAnalyticLine deletes an existing account.analytic.line record.
func (c *Client) DeleteAccountAnalyticLine(id int64) error {
return c.DeleteAccountAnalyticLines([]int64{id})
}
// DeleteAccountAnalyticLines deletes existing account.analytic.line records.
func (c *Client) DeleteAccountAnalyticLines(ids []int64) error {
return c.Delete(AccountAnalyticLineModel, ids)
}
// GetAccountAnalyticLine gets account.analytic.line existing record.
func (c *Client) GetAccountAnalyticLine(id int64) (*AccountAnalyticLine, error) {
aals, err := c.GetAccountAnalyticLines([]int64{id})
if err != nil {
return nil, err
}
if aals != nil && len(*aals) > 0 {
return &((*aals)[0]), nil
}
return nil, fmt.Errorf("id %v of %s not found", id, AccountAnalyticLineModel)
}
// GetAccountAnalyticLines gets account.analytic.line existing records.
func (c *Client) GetAccountAnalyticLines(ids []int64) (*AccountAnalyticLines, error) {
aals := &AccountAnalyticLines{}
if err := c.Read(AccountAnalyticLineModel, ids, nil, aals); err != nil {
return nil, err
}
return aals, nil
}
// FindAccountAnalyticLine finds account.analytic.line record by querying it with criteria
func (c *Client) FindAccountAnalyticLine(criteria *Criteria) (*AccountAnalyticLine, error) {
aals := &AccountAnalyticLines{}
if err := c.SearchRead(AccountAnalyticLineModel, criteria, NewOptions().Limit(1), aals); err != nil {
return nil, err
}
if aals != nil && len(*aals) > 0 {
return &((*aals)[0]), nil
}
return nil, fmt.Errorf("account.analytic.line was not found")
}
// FindAccountAnalyticLines finds account.analytic.line records by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountAnalyticLines(criteria *Criteria, options *Options) (*AccountAnalyticLines, error) {
aals := &AccountAnalyticLines{}
if err := c.SearchRead(AccountAnalyticLineModel, criteria, options, aals); err != nil {
return nil, err
}
return aals, nil
}