-
Notifications
You must be signed in to change notification settings - Fork 64
/
account_financial_year_op.go
123 lines (107 loc) · 5.03 KB
/
account_financial_year_op.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
// AccountFinancialYearOp represents account.financial.year.op model.
type AccountFinancialYearOp struct {
LastUpdate *Time `xmlrpc:"__last_update,omitempty"`
AccountSetupFyDataDone *Bool `xmlrpc:"account_setup_fy_data_done,omitempty"`
CompanyId *Many2One `xmlrpc:"company_id,omitempty"`
CreateDate *Time `xmlrpc:"create_date,omitempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omitempty"`
DisplayName *String `xmlrpc:"display_name,omitempty"`
FiscalyearLastDay *Int `xmlrpc:"fiscalyear_last_day,omitempty"`
FiscalyearLastMonth *Selection `xmlrpc:"fiscalyear_last_month,omitempty"`
Id *Int `xmlrpc:"id,omitempty"`
OpeningDate *Time `xmlrpc:"opening_date,omitempty"`
OpeningMovePosted *Bool `xmlrpc:"opening_move_posted,omitempty"`
WriteDate *Time `xmlrpc:"write_date,omitempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omitempty"`
}
// AccountFinancialYearOps represents array of account.financial.year.op model.
type AccountFinancialYearOps []AccountFinancialYearOp
// AccountFinancialYearOpModel is the odoo model name.
const AccountFinancialYearOpModel = "account.financial.year.op"
// Many2One convert AccountFinancialYearOp to *Many2One.
func (afyo *AccountFinancialYearOp) Many2One() *Many2One {
return NewMany2One(afyo.Id.Get(), "")
}
// CreateAccountFinancialYearOp creates a new account.financial.year.op model and returns its id.
func (c *Client) CreateAccountFinancialYearOp(afyo *AccountFinancialYearOp) (int64, error) {
ids, err := c.CreateAccountFinancialYearOps([]*AccountFinancialYearOp{afyo})
if err != nil {
return -1, err
}
if len(ids) == 0 {
return -1, nil
}
return ids[0], nil
}
// CreateAccountFinancialYearOps creates a new account.financial.year.op model and returns its id.
func (c *Client) CreateAccountFinancialYearOps(afyos []*AccountFinancialYearOp) ([]int64, error) {
var vv []interface{}
for _, v := range afyos {
vv = append(vv, v)
}
return c.Create(AccountFinancialYearOpModel, vv, nil)
}
// UpdateAccountFinancialYearOp updates an existing account.financial.year.op record.
func (c *Client) UpdateAccountFinancialYearOp(afyo *AccountFinancialYearOp) error {
return c.UpdateAccountFinancialYearOps([]int64{afyo.Id.Get()}, afyo)
}
// UpdateAccountFinancialYearOps updates existing account.financial.year.op records.
// All records (represented by ids) will be updated by afyo values.
func (c *Client) UpdateAccountFinancialYearOps(ids []int64, afyo *AccountFinancialYearOp) error {
return c.Update(AccountFinancialYearOpModel, ids, afyo, nil)
}
// DeleteAccountFinancialYearOp deletes an existing account.financial.year.op record.
func (c *Client) DeleteAccountFinancialYearOp(id int64) error {
return c.DeleteAccountFinancialYearOps([]int64{id})
}
// DeleteAccountFinancialYearOps deletes existing account.financial.year.op records.
func (c *Client) DeleteAccountFinancialYearOps(ids []int64) error {
return c.Delete(AccountFinancialYearOpModel, ids)
}
// GetAccountFinancialYearOp gets account.financial.year.op existing record.
func (c *Client) GetAccountFinancialYearOp(id int64) (*AccountFinancialYearOp, error) {
afyos, err := c.GetAccountFinancialYearOps([]int64{id})
if err != nil {
return nil, err
}
return &((*afyos)[0]), nil
}
// GetAccountFinancialYearOps gets account.financial.year.op existing records.
func (c *Client) GetAccountFinancialYearOps(ids []int64) (*AccountFinancialYearOps, error) {
afyos := &AccountFinancialYearOps{}
if err := c.Read(AccountFinancialYearOpModel, ids, nil, afyos); err != nil {
return nil, err
}
return afyos, nil
}
// FindAccountFinancialYearOp finds account.financial.year.op record by querying it with criteria.
func (c *Client) FindAccountFinancialYearOp(criteria *Criteria) (*AccountFinancialYearOp, error) {
afyos := &AccountFinancialYearOps{}
if err := c.SearchRead(AccountFinancialYearOpModel, criteria, NewOptions().Limit(1), afyos); err != nil {
return nil, err
}
return &((*afyos)[0]), nil
}
// FindAccountFinancialYearOps finds account.financial.year.op records by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountFinancialYearOps(criteria *Criteria, options *Options) (*AccountFinancialYearOps, error) {
afyos := &AccountFinancialYearOps{}
if err := c.SearchRead(AccountFinancialYearOpModel, criteria, options, afyos); err != nil {
return nil, err
}
return afyos, nil
}
// FindAccountFinancialYearOpIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountFinancialYearOpIds(criteria *Criteria, options *Options) ([]int64, error) {
return c.Search(AccountFinancialYearOpModel, criteria, options)
}
// FindAccountFinancialYearOpId finds record id by querying it with criteria.
func (c *Client) FindAccountFinancialYearOpId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(AccountFinancialYearOpModel, criteria, options)
if err != nil {
return -1, err
}
return ids[0], nil
}