Skip to content

Commit a3b1dd7

Browse files
author
Antoine Huret
committed
added templates + recover panics when closing connections
1 parent bd966f4 commit a3b1dd7

19 files changed

+62
-56
lines changed

account_account.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 account.account was not found", id)
79+
return nil, fmt.Errorf("id %v of account.account not found", id)
8080
}
8181

8282
// GetAccountAccounts gets account.account existing records.
@@ -121,8 +121,8 @@ func (c *Client) FindAccountAccountIds(criteria *Criteria, options *Options) ([]
121121
}
122122

123123
// 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))
124+
func (c *Client) FindAccountAccountId(criteria *Criteria, options *Options) (int64, error) {
125+
ids, err := c.Search(AccountAccountModel, criteria, options)
126126
if err != nil {
127127
return -1, err
128128
}

account_analytic_account.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 account.analytic.account was not found", id)
91+
return nil, fmt.Errorf("id %v of account.analytic.account not found", id)
9292
}
9393

9494
// GetAccountAnalyticAccounts gets account.analytic.account existing records.
@@ -133,8 +133,8 @@ func (c *Client) FindAccountAnalyticAccountIds(criteria *Criteria, options *Opti
133133
}
134134

135135
// 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))
136+
func (c *Client) FindAccountAnalyticAccountId(criteria *Criteria, options *Options) (int64, error) {
137+
ids, err := c.Search(AccountAnalyticAccountModel, criteria, options)
138138
if err != nil {
139139
return -1, err
140140
}

account_analytic_line.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 account.analytic.line was not found", id)
92+
return nil, fmt.Errorf("id %v of account.analytic.line not found", id)
9393
}
9494

9595
// GetAccountAnalyticLines gets account.analytic.line existing records.
@@ -134,8 +134,8 @@ func (c *Client) FindAccountAnalyticLineIds(criteria *Criteria, options *Options
134134
}
135135

136136
// 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))
137+
func (c *Client) FindAccountAnalyticLineId(criteria *Criteria, options *Options) (int64, error) {
138+
ids, err := c.Search(AccountAnalyticLineModel, criteria, options)
139139
if err != nil {
140140
return -1, err
141141
}

account_analytic_tag.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 account.analytic.tag was not found", id)
67+
return nil, fmt.Errorf("id %v of account.analytic.tag not found", id)
6868
}
6969

7070
// GetAccountAnalyticTags gets account.analytic.tag existing records.
@@ -109,8 +109,8 @@ func (c *Client) FindAccountAnalyticTagIds(criteria *Criteria, options *Options)
109109
}
110110

111111
// 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))
112+
func (c *Client) FindAccountAnalyticTagId(criteria *Criteria, options *Options) (int64, error) {
113+
ids, err := c.Search(AccountAnalyticTagModel, criteria, options)
114114
if err != nil {
115115
return -1, err
116116
}

account_invoice.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 account.invoice was not found", id)
145+
return nil, fmt.Errorf("id %v of account.invoice not found", id)
146146
}
147147

148148
// GetAccountInvoices gets account.invoice existing records.
@@ -187,8 +187,8 @@ func (c *Client) FindAccountInvoiceIds(criteria *Criteria, options *Options) ([]
187187
}
188188

189189
// 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))
190+
func (c *Client) FindAccountInvoiceId(criteria *Criteria, options *Options) (int64, error) {
191+
ids, err := c.Search(AccountInvoiceModel, criteria, options)
192192
if err != nil {
193193
return -1, err
194194
}

account_invoice_line.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 account.invoice.line was not found", id)
91+
return nil, fmt.Errorf("id %v of account.invoice.line not found", id)
9292
}
9393

9494
// GetAccountInvoiceLines gets account.invoice.line existing records.
@@ -133,8 +133,8 @@ func (c *Client) FindAccountInvoiceLineIds(criteria *Criteria, options *Options)
133133
}
134134

135135
// 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))
136+
func (c *Client) FindAccountInvoiceLineId(criteria *Criteria, options *Options) (int64, error) {
137+
ids, err := c.Search(AccountInvoiceLineModel, criteria, options)
138138
if err != nil {
139139
return -1, err
140140
}

account_journal.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (c *Client) GetAccountJournal(id int64) (*AccountJournal, error) {
9595
if ajs != nil && len(*ajs) > 0 {
9696
return &((*ajs)[0]), nil
9797
}
98-
return nil, fmt.Errorf("id %v of account.journal was not found", id)
98+
return nil, fmt.Errorf("id %v of account.journal not found", id)
9999
}
100100

101101
// GetAccountJournals gets account.journal existing records.
@@ -140,8 +140,8 @@ func (c *Client) FindAccountJournalIds(criteria *Criteria, options *Options) ([]
140140
}
141141

142142
// FindAccountJournalId finds record id by querying it with criteria.
143-
func (c *Client) FindAccountJournalId(criteria *Criteria) (int64, error) {
144-
ids, err := c.Search(AccountJournalModel, criteria, NewOptions().Limit(1))
143+
func (c *Client) FindAccountJournalId(criteria *Criteria, options *Options) (int64, error) {
144+
ids, err := c.Search(AccountJournalModel, criteria, options)
145145
if err != nil {
146146
return -1, err
147147
}

crm_lead.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (c *Client) GetCrmLead(id int64) (*CrmLead, error) {
133133
if cls != nil && len(*cls) > 0 {
134134
return &((*cls)[0]), nil
135135
}
136-
return nil, fmt.Errorf("id %v of crm.lead was not found", id)
136+
return nil, fmt.Errorf("id %v of crm.lead not found", id)
137137
}
138138

139139
// GetCrmLeads gets crm.lead existing records.
@@ -178,8 +178,8 @@ func (c *Client) FindCrmLeadIds(criteria *Criteria, options *Options) ([]int64,
178178
}
179179

180180
// FindCrmLeadId finds record id by querying it with criteria.
181-
func (c *Client) FindCrmLeadId(criteria *Criteria) (int64, error) {
182-
ids, err := c.Search(CrmLeadModel, criteria, NewOptions().Limit(1))
181+
func (c *Client) FindCrmLeadId(criteria *Criteria, options *Options) (int64, error) {
182+
ids, err := c.Search(CrmLeadModel, criteria, options)
183183
if err != nil {
184184
return -1, err
185185
}

crm_lead_tag.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (c *Client) GetCrmLeadTag(id int64) (*CrmLeadTag, error) {
6363
if clts != nil && len(*clts) > 0 {
6464
return &((*clts)[0]), nil
6565
}
66-
return nil, fmt.Errorf("id %v of crm.lead.tag was not found", id)
66+
return nil, fmt.Errorf("id %v of crm.lead.tag not found", id)
6767
}
6868

6969
// GetCrmLeadTags gets crm.lead.tag existing records.
@@ -108,8 +108,8 @@ func (c *Client) FindCrmLeadTagIds(criteria *Criteria, options *Options) ([]int6
108108
}
109109

110110
// FindCrmLeadTagId finds record id by querying it with criteria.
111-
func (c *Client) FindCrmLeadTagId(criteria *Criteria) (int64, error) {
112-
ids, err := c.Search(CrmLeadTagModel, criteria, NewOptions().Limit(1))
111+
func (c *Client) FindCrmLeadTagId(criteria *Criteria, options *Options) (int64, error) {
112+
ids, err := c.Search(CrmLeadTagModel, criteria, options)
113113
if err != nil {
114114
return -1, err
115115
}

generator/cmd/tmpl/model.tmpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package odoo
1+
package odoo
22

33
import (
44
"fmt"
@@ -55,7 +55,7 @@ func (c *Client) Get{{.StructName}}(id int64) (*{{.StructName}}, error) {
5555
if {{.VarsName}} != nil && len(*{{.VarsName}}) > 0 {
5656
return &((*{{.VarsName}})[0]), nil
5757
}
58-
return nil, fmt.Errorf("id %v of {{ .Name }} was not found", id)
58+
return nil, fmt.Errorf("id %v of {{.Name}} not found", id)
5959
}
6060

6161
// Get{{.StructName}}s gets {{ .Name }} existing records.
@@ -79,7 +79,7 @@ func (c *Client) Find{{.StructName}}(criteria *Criteria) (*{{.StructName}}, erro
7979
return nil, fmt.Errorf("{{ .Name }} was not found")
8080
}
8181

82-
// Find{{.StructName}}s finds {{ .Name }} records by querying it
82+
// Find{{.StructName}}s finds {{ .Name }} records by querying it
8383
// and filtering it with criteria and options.
8484
func (c *Client) Find{{.StructName}}s(criteria *Criteria, options *Options) (*{{.StructName}}s, error) {
8585
{{.VarsName}} := &{{.StructName}}s{}
@@ -100,8 +100,8 @@ func (c *Client) Find{{.StructName}}Ids(criteria *Criteria, options *Options) ([
100100
}
101101

102102
// Find{{.StructName}}Id finds record id by querying it with criteria.
103-
func (c *Client) Find{{.StructName}}Id(criteria *Criteria) (int64, error) {
104-
ids, err := c.Search({{.StructName}}Model, criteria, NewOptions().Limit(1))
103+
func (c *Client) Find{{.StructName}}Id(criteria *Criteria, options *Options) (int64, error) {
104+
ids, err := c.Search({{.StructName}}Model, criteria, options)
105105
if err != nil {
106106
return -1, err
107107
}

0 commit comments

Comments
 (0)