Skip to content

Commit bd966f4

Browse files
author
Antoine Huret
committed
added find ids & find id function in templates + regenerated models
1 parent 1ada708 commit bd966f4

20 files changed

+486
-119
lines changed

account_account.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
)
66

7-
// AccountAccount represents account.account model
7+
// AccountAccount represents account.account model.
88
type AccountAccount struct {
99
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
1010
Code *String `xmlrpc:"code,omptempty"`
@@ -30,10 +30,10 @@ type AccountAccount struct {
3030
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
3131
}
3232

33-
// AccountAccounts represents array of account.account model
33+
// AccountAccounts represents array of account.account model.
3434
type AccountAccounts []AccountAccount
3535

36-
// AccountAccountModel is the odoo model name
36+
// AccountAccountModel is the odoo model name.
3737
const AccountAccountModel = "account.account"
3838

3939
// Many2One convert AccountAccount to *Many2One.
@@ -76,7 +76,7 @@ func (c *Client) GetAccountAccount(id int64) (*AccountAccount, error) {
7676
if aas != nil && len(*aas) > 0 {
7777
return &((*aas)[0]), nil
7878
}
79-
return nil, fmt.Errorf("id %v of %s not found", id, AccountAccountModel)
79+
return nil, fmt.Errorf("id %v of account.account was not found", id)
8080
}
8181

8282
// GetAccountAccounts gets account.account existing records.
@@ -88,7 +88,7 @@ func (c *Client) GetAccountAccounts(ids []int64) (*AccountAccounts, error) {
8888
return aas, nil
8989
}
9090

91-
// FindAccountAccount finds account.account record by querying it with criteria
91+
// FindAccountAccount finds account.account record by querying it with criteria.
9292
func (c *Client) FindAccountAccount(criteria *Criteria) (*AccountAccount, error) {
9393
aas := &AccountAccounts{}
9494
if err := c.SearchRead(AccountAccountModel, criteria, NewOptions().Limit(1), aas); err != nil {
@@ -109,3 +109,25 @@ func (c *Client) FindAccountAccounts(criteria *Criteria, options *Options) (*Acc
109109
}
110110
return aas, nil
111111
}
112+
113+
// FindAccountAccountIds finds records ids by querying it
114+
// and filtering it with criteria and options.
115+
func (c *Client) FindAccountAccountIds(criteria *Criteria, options *Options) ([]int64, error) {
116+
ids, err := c.Search(AccountAccountModel, criteria, options)
117+
if err != nil {
118+
return []int64{}, err
119+
}
120+
return ids, nil
121+
}
122+
123+
// FindAccountAccountId finds record id by querying it with criteria.
124+
func (c *Client) FindAccountAccountId(criteria *Criteria) (int64, error) {
125+
ids, err := c.Search(AccountAccountModel, criteria, NewOptions().Limit(1))
126+
if err != nil {
127+
return -1, err
128+
}
129+
if len(ids) > 0 {
130+
return ids[0], nil
131+
}
132+
return -1, fmt.Errorf("account.account was not found")
133+
}

account_analytic_account.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
)
66

7-
// AccountAnalyticAccount represents account.analytic.account model
7+
// AccountAnalyticAccount represents account.analytic.account model.
88
type AccountAnalyticAccount struct {
99
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
1010
Active *Bool `xmlrpc:"active,omptempty"`
@@ -42,10 +42,10 @@ type AccountAnalyticAccount struct {
4242
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
4343
}
4444

45-
// AccountAnalyticAccounts represents array of account.analytic.account model
45+
// AccountAnalyticAccounts represents array of account.analytic.account model.
4646
type AccountAnalyticAccounts []AccountAnalyticAccount
4747

48-
// AccountAnalyticAccountModel is the odoo model name
48+
// AccountAnalyticAccountModel is the odoo model name.
4949
const AccountAnalyticAccountModel = "account.analytic.account"
5050

5151
// Many2One convert AccountAnalyticAccount to *Many2One.
@@ -88,7 +88,7 @@ func (c *Client) GetAccountAnalyticAccount(id int64) (*AccountAnalyticAccount, e
8888
if aaas != nil && len(*aaas) > 0 {
8989
return &((*aaas)[0]), nil
9090
}
91-
return nil, fmt.Errorf("id %v of %s not found", id, AccountAnalyticAccountModel)
91+
return nil, fmt.Errorf("id %v of account.analytic.account was not found", id)
9292
}
9393

9494
// GetAccountAnalyticAccounts gets account.analytic.account existing records.
@@ -100,7 +100,7 @@ func (c *Client) GetAccountAnalyticAccounts(ids []int64) (*AccountAnalyticAccoun
100100
return aaas, nil
101101
}
102102

103-
// FindAccountAnalyticAccount finds account.analytic.account record by querying it with criteria
103+
// FindAccountAnalyticAccount finds account.analytic.account record by querying it with criteria.
104104
func (c *Client) FindAccountAnalyticAccount(criteria *Criteria) (*AccountAnalyticAccount, error) {
105105
aaas := &AccountAnalyticAccounts{}
106106
if err := c.SearchRead(AccountAnalyticAccountModel, criteria, NewOptions().Limit(1), aaas); err != nil {
@@ -121,3 +121,25 @@ func (c *Client) FindAccountAnalyticAccounts(criteria *Criteria, options *Option
121121
}
122122
return aaas, nil
123123
}
124+
125+
// FindAccountAnalyticAccountIds finds records ids by querying it
126+
// and filtering it with criteria and options.
127+
func (c *Client) FindAccountAnalyticAccountIds(criteria *Criteria, options *Options) ([]int64, error) {
128+
ids, err := c.Search(AccountAnalyticAccountModel, criteria, options)
129+
if err != nil {
130+
return []int64{}, err
131+
}
132+
return ids, nil
133+
}
134+
135+
// FindAccountAnalyticAccountId finds record id by querying it with criteria.
136+
func (c *Client) FindAccountAnalyticAccountId(criteria *Criteria) (int64, error) {
137+
ids, err := c.Search(AccountAnalyticAccountModel, criteria, NewOptions().Limit(1))
138+
if err != nil {
139+
return -1, err
140+
}
141+
if len(ids) > 0 {
142+
return ids[0], nil
143+
}
144+
return -1, fmt.Errorf("account.analytic.account was not found")
145+
}

account_analytic_line.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
)
66

7-
// AccountAnalyticLine represents account.analytic.line model
7+
// AccountAnalyticLine represents account.analytic.line model.
88
type AccountAnalyticLine struct {
99
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
1010
AccountId *Many2One `xmlrpc:"account_id,omptempty"`
@@ -43,10 +43,10 @@ type AccountAnalyticLine struct {
4343
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
4444
}
4545

46-
// AccountAnalyticLines represents array of account.analytic.line model
46+
// AccountAnalyticLines represents array of account.analytic.line model.
4747
type AccountAnalyticLines []AccountAnalyticLine
4848

49-
// AccountAnalyticLineModel is the odoo model name
49+
// AccountAnalyticLineModel is the odoo model name.
5050
const AccountAnalyticLineModel = "account.analytic.line"
5151

5252
// Many2One convert AccountAnalyticLine to *Many2One.
@@ -89,7 +89,7 @@ func (c *Client) GetAccountAnalyticLine(id int64) (*AccountAnalyticLine, error)
8989
if aals != nil && len(*aals) > 0 {
9090
return &((*aals)[0]), nil
9191
}
92-
return nil, fmt.Errorf("id %v of %s not found", id, AccountAnalyticLineModel)
92+
return nil, fmt.Errorf("id %v of account.analytic.line was not found", id)
9393
}
9494

9595
// GetAccountAnalyticLines gets account.analytic.line existing records.
@@ -101,7 +101,7 @@ func (c *Client) GetAccountAnalyticLines(ids []int64) (*AccountAnalyticLines, er
101101
return aals, nil
102102
}
103103

104-
// FindAccountAnalyticLine finds account.analytic.line record by querying it with criteria
104+
// FindAccountAnalyticLine finds account.analytic.line record by querying it with criteria.
105105
func (c *Client) FindAccountAnalyticLine(criteria *Criteria) (*AccountAnalyticLine, error) {
106106
aals := &AccountAnalyticLines{}
107107
if err := c.SearchRead(AccountAnalyticLineModel, criteria, NewOptions().Limit(1), aals); err != nil {
@@ -122,3 +122,25 @@ func (c *Client) FindAccountAnalyticLines(criteria *Criteria, options *Options)
122122
}
123123
return aals, nil
124124
}
125+
126+
// FindAccountAnalyticLineIds finds records ids by querying it
127+
// and filtering it with criteria and options.
128+
func (c *Client) FindAccountAnalyticLineIds(criteria *Criteria, options *Options) ([]int64, error) {
129+
ids, err := c.Search(AccountAnalyticLineModel, criteria, options)
130+
if err != nil {
131+
return []int64{}, err
132+
}
133+
return ids, nil
134+
}
135+
136+
// FindAccountAnalyticLineId finds record id by querying it with criteria.
137+
func (c *Client) FindAccountAnalyticLineId(criteria *Criteria) (int64, error) {
138+
ids, err := c.Search(AccountAnalyticLineModel, criteria, NewOptions().Limit(1))
139+
if err != nil {
140+
return -1, err
141+
}
142+
if len(ids) > 0 {
143+
return ids[0], nil
144+
}
145+
return -1, fmt.Errorf("account.analytic.line was not found")
146+
}

account_analytic_tag.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
)
66

7-
// AccountAnalyticTag represents account.analytic.tag model
7+
// AccountAnalyticTag represents account.analytic.tag model.
88
type AccountAnalyticTag struct {
99
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
1010
Active *Bool `xmlrpc:"active,omptempty"`
@@ -18,10 +18,10 @@ type AccountAnalyticTag struct {
1818
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
1919
}
2020

21-
// AccountAnalyticTags represents array of account.analytic.tag model
21+
// AccountAnalyticTags represents array of account.analytic.tag model.
2222
type AccountAnalyticTags []AccountAnalyticTag
2323

24-
// AccountAnalyticTagModel is the odoo model name
24+
// AccountAnalyticTagModel is the odoo model name.
2525
const AccountAnalyticTagModel = "account.analytic.tag"
2626

2727
// Many2One convert AccountAnalyticTag to *Many2One.
@@ -64,7 +64,7 @@ func (c *Client) GetAccountAnalyticTag(id int64) (*AccountAnalyticTag, error) {
6464
if aats != nil && len(*aats) > 0 {
6565
return &((*aats)[0]), nil
6666
}
67-
return nil, fmt.Errorf("id %v of %s not found", id, AccountAnalyticTagModel)
67+
return nil, fmt.Errorf("id %v of account.analytic.tag was not found", id)
6868
}
6969

7070
// GetAccountAnalyticTags gets account.analytic.tag existing records.
@@ -76,7 +76,7 @@ func (c *Client) GetAccountAnalyticTags(ids []int64) (*AccountAnalyticTags, erro
7676
return aats, nil
7777
}
7878

79-
// FindAccountAnalyticTag finds account.analytic.tag record by querying it with criteria
79+
// FindAccountAnalyticTag finds account.analytic.tag record by querying it with criteria.
8080
func (c *Client) FindAccountAnalyticTag(criteria *Criteria) (*AccountAnalyticTag, error) {
8181
aats := &AccountAnalyticTags{}
8282
if err := c.SearchRead(AccountAnalyticTagModel, criteria, NewOptions().Limit(1), aats); err != nil {
@@ -97,3 +97,25 @@ func (c *Client) FindAccountAnalyticTags(criteria *Criteria, options *Options) (
9797
}
9898
return aats, nil
9999
}
100+
101+
// FindAccountAnalyticTagIds finds records ids by querying it
102+
// and filtering it with criteria and options.
103+
func (c *Client) FindAccountAnalyticTagIds(criteria *Criteria, options *Options) ([]int64, error) {
104+
ids, err := c.Search(AccountAnalyticTagModel, criteria, options)
105+
if err != nil {
106+
return []int64{}, err
107+
}
108+
return ids, nil
109+
}
110+
111+
// FindAccountAnalyticTagId finds record id by querying it with criteria.
112+
func (c *Client) FindAccountAnalyticTagId(criteria *Criteria) (int64, error) {
113+
ids, err := c.Search(AccountAnalyticTagModel, criteria, NewOptions().Limit(1))
114+
if err != nil {
115+
return -1, err
116+
}
117+
if len(ids) > 0 {
118+
return ids[0], nil
119+
}
120+
return -1, fmt.Errorf("account.analytic.tag was not found")
121+
}

account_invoice.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
)
66

7-
// AccountInvoice represents account.invoice model
7+
// AccountInvoice represents account.invoice model.
88
type AccountInvoice struct {
99
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
1010
AccessToken *String `xmlrpc:"access_token,omptempty"`
@@ -96,10 +96,10 @@ type AccountInvoice struct {
9696
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
9797
}
9898

99-
// AccountInvoices represents array of account.invoice model
99+
// AccountInvoices represents array of account.invoice model.
100100
type AccountInvoices []AccountInvoice
101101

102-
// AccountInvoiceModel is the odoo model name
102+
// AccountInvoiceModel is the odoo model name.
103103
const AccountInvoiceModel = "account.invoice"
104104

105105
// Many2One convert AccountInvoice to *Many2One.
@@ -142,7 +142,7 @@ func (c *Client) GetAccountInvoice(id int64) (*AccountInvoice, error) {
142142
if ais != nil && len(*ais) > 0 {
143143
return &((*ais)[0]), nil
144144
}
145-
return nil, fmt.Errorf("id %v of %s not found", id, AccountInvoiceModel)
145+
return nil, fmt.Errorf("id %v of account.invoice was not found", id)
146146
}
147147

148148
// GetAccountInvoices gets account.invoice existing records.
@@ -154,7 +154,7 @@ func (c *Client) GetAccountInvoices(ids []int64) (*AccountInvoices, error) {
154154
return ais, nil
155155
}
156156

157-
// FindAccountInvoice finds account.invoice record by querying it with criteria
157+
// FindAccountInvoice finds account.invoice record by querying it with criteria.
158158
func (c *Client) FindAccountInvoice(criteria *Criteria) (*AccountInvoice, error) {
159159
ais := &AccountInvoices{}
160160
if err := c.SearchRead(AccountInvoiceModel, criteria, NewOptions().Limit(1), ais); err != nil {
@@ -175,3 +175,25 @@ func (c *Client) FindAccountInvoices(criteria *Criteria, options *Options) (*Acc
175175
}
176176
return ais, nil
177177
}
178+
179+
// FindAccountInvoiceIds finds records ids by querying it
180+
// and filtering it with criteria and options.
181+
func (c *Client) FindAccountInvoiceIds(criteria *Criteria, options *Options) ([]int64, error) {
182+
ids, err := c.Search(AccountInvoiceModel, criteria, options)
183+
if err != nil {
184+
return []int64{}, err
185+
}
186+
return ids, nil
187+
}
188+
189+
// FindAccountInvoiceId finds record id by querying it with criteria.
190+
func (c *Client) FindAccountInvoiceId(criteria *Criteria) (int64, error) {
191+
ids, err := c.Search(AccountInvoiceModel, criteria, NewOptions().Limit(1))
192+
if err != nil {
193+
return -1, err
194+
}
195+
if len(ids) > 0 {
196+
return ids[0], nil
197+
}
198+
return -1, fmt.Errorf("account.invoice was not found")
199+
}

account_invoice_line.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
)
66

7-
// AccountInvoiceLine represents account.invoice.line model
7+
// AccountInvoiceLine represents account.invoice.line model.
88
type AccountInvoiceLine struct {
99
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
1010
AccountAnalyticId *Many2One `xmlrpc:"account_analytic_id,omptempty"`
@@ -42,10 +42,10 @@ type AccountInvoiceLine struct {
4242
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
4343
}
4444

45-
// AccountInvoiceLines represents array of account.invoice.line model
45+
// AccountInvoiceLines represents array of account.invoice.line model.
4646
type AccountInvoiceLines []AccountInvoiceLine
4747

48-
// AccountInvoiceLineModel is the odoo model name
48+
// AccountInvoiceLineModel is the odoo model name.
4949
const AccountInvoiceLineModel = "account.invoice.line"
5050

5151
// Many2One convert AccountInvoiceLine to *Many2One.
@@ -88,7 +88,7 @@ func (c *Client) GetAccountInvoiceLine(id int64) (*AccountInvoiceLine, error) {
8888
if ails != nil && len(*ails) > 0 {
8989
return &((*ails)[0]), nil
9090
}
91-
return nil, fmt.Errorf("id %v of %s not found", id, AccountInvoiceLineModel)
91+
return nil, fmt.Errorf("id %v of account.invoice.line was not found", id)
9292
}
9393

9494
// GetAccountInvoiceLines gets account.invoice.line existing records.
@@ -100,7 +100,7 @@ func (c *Client) GetAccountInvoiceLines(ids []int64) (*AccountInvoiceLines, erro
100100
return ails, nil
101101
}
102102

103-
// FindAccountInvoiceLine finds account.invoice.line record by querying it with criteria
103+
// FindAccountInvoiceLine finds account.invoice.line record by querying it with criteria.
104104
func (c *Client) FindAccountInvoiceLine(criteria *Criteria) (*AccountInvoiceLine, error) {
105105
ails := &AccountInvoiceLines{}
106106
if err := c.SearchRead(AccountInvoiceLineModel, criteria, NewOptions().Limit(1), ails); err != nil {
@@ -121,3 +121,25 @@ func (c *Client) FindAccountInvoiceLines(criteria *Criteria, options *Options) (
121121
}
122122
return ails, nil
123123
}
124+
125+
// FindAccountInvoiceLineIds finds records ids by querying it
126+
// and filtering it with criteria and options.
127+
func (c *Client) FindAccountInvoiceLineIds(criteria *Criteria, options *Options) ([]int64, error) {
128+
ids, err := c.Search(AccountInvoiceLineModel, criteria, options)
129+
if err != nil {
130+
return []int64{}, err
131+
}
132+
return ids, nil
133+
}
134+
135+
// FindAccountInvoiceLineId finds record id by querying it with criteria.
136+
func (c *Client) FindAccountInvoiceLineId(criteria *Criteria) (int64, error) {
137+
ids, err := c.Search(AccountInvoiceLineModel, criteria, NewOptions().Limit(1))
138+
if err != nil {
139+
return -1, err
140+
}
141+
if len(ids) > 0 {
142+
return ids[0], nil
143+
}
144+
return -1, fmt.Errorf("account.invoice.line was not found")
145+
}

0 commit comments

Comments
 (0)