Skip to content

Commit

Permalink
added find ids & find id function in templates + regenerated models
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuret committed May 20, 2020
1 parent 1ada708 commit bd966f4
Show file tree
Hide file tree
Showing 20 changed files with 486 additions and 119 deletions.
32 changes: 27 additions & 5 deletions account_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
)

// AccountAccount represents account.account model
// AccountAccount represents account.account model.
type AccountAccount struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Code *String `xmlrpc:"code,omptempty"`
Expand All @@ -30,10 +30,10 @@ type AccountAccount struct {
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}

// AccountAccounts represents array of account.account model
// AccountAccounts represents array of account.account model.
type AccountAccounts []AccountAccount

// AccountAccountModel is the odoo model name
// AccountAccountModel is the odoo model name.
const AccountAccountModel = "account.account"

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

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

// FindAccountAccount finds account.account record by querying it with criteria
// FindAccountAccount finds account.account record by querying it with criteria.
func (c *Client) FindAccountAccount(criteria *Criteria) (*AccountAccount, error) {
aas := &AccountAccounts{}
if err := c.SearchRead(AccountAccountModel, criteria, NewOptions().Limit(1), aas); err != nil {
Expand All @@ -109,3 +109,25 @@ func (c *Client) FindAccountAccounts(criteria *Criteria, options *Options) (*Acc
}
return aas, nil
}

// FindAccountAccountIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountAccountIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(AccountAccountModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}

// FindAccountAccountId finds record id by querying it with criteria.
func (c *Client) FindAccountAccountId(criteria *Criteria) (int64, error) {
ids, err := c.Search(AccountAccountModel, criteria, NewOptions().Limit(1))
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("account.account was not found")
}
32 changes: 27 additions & 5 deletions account_analytic_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
)

// AccountAnalyticAccount represents account.analytic.account model
// AccountAnalyticAccount represents account.analytic.account model.
type AccountAnalyticAccount struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Active *Bool `xmlrpc:"active,omptempty"`
Expand Down Expand Up @@ -42,10 +42,10 @@ type AccountAnalyticAccount struct {
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}

// AccountAnalyticAccounts represents array of account.analytic.account model
// AccountAnalyticAccounts represents array of account.analytic.account model.
type AccountAnalyticAccounts []AccountAnalyticAccount

// AccountAnalyticAccountModel is the odoo model name
// AccountAnalyticAccountModel is the odoo model name.
const AccountAnalyticAccountModel = "account.analytic.account"

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

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

// FindAccountAnalyticAccount finds account.analytic.account record by querying it with criteria
// FindAccountAnalyticAccount finds account.analytic.account record by querying it with criteria.
func (c *Client) FindAccountAnalyticAccount(criteria *Criteria) (*AccountAnalyticAccount, error) {
aaas := &AccountAnalyticAccounts{}
if err := c.SearchRead(AccountAnalyticAccountModel, criteria, NewOptions().Limit(1), aaas); err != nil {
Expand All @@ -121,3 +121,25 @@ func (c *Client) FindAccountAnalyticAccounts(criteria *Criteria, options *Option
}
return aaas, nil
}

// FindAccountAnalyticAccountIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountAnalyticAccountIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(AccountAnalyticAccountModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}

// FindAccountAnalyticAccountId finds record id by querying it with criteria.
func (c *Client) FindAccountAnalyticAccountId(criteria *Criteria) (int64, error) {
ids, err := c.Search(AccountAnalyticAccountModel, criteria, NewOptions().Limit(1))
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("account.analytic.account was not found")
}
32 changes: 27 additions & 5 deletions account_analytic_line.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
)

// AccountAnalyticLine represents account.analytic.line model
// AccountAnalyticLine represents account.analytic.line model.
type AccountAnalyticLine struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
AccountId *Many2One `xmlrpc:"account_id,omptempty"`
Expand Down Expand Up @@ -43,10 +43,10 @@ type AccountAnalyticLine struct {
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}

// AccountAnalyticLines represents array of account.analytic.line model
// AccountAnalyticLines represents array of account.analytic.line model.
type AccountAnalyticLines []AccountAnalyticLine

// AccountAnalyticLineModel is the odoo model name
// AccountAnalyticLineModel is the odoo model name.
const AccountAnalyticLineModel = "account.analytic.line"

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

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

// FindAccountAnalyticLine finds account.analytic.line record by querying it with criteria
// 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 {
Expand All @@ -122,3 +122,25 @@ func (c *Client) FindAccountAnalyticLines(criteria *Criteria, options *Options)
}
return aals, nil
}

// FindAccountAnalyticLineIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountAnalyticLineIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(AccountAnalyticLineModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}

// FindAccountAnalyticLineId finds record id by querying it with criteria.
func (c *Client) FindAccountAnalyticLineId(criteria *Criteria) (int64, error) {
ids, err := c.Search(AccountAnalyticLineModel, criteria, NewOptions().Limit(1))
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("account.analytic.line was not found")
}
32 changes: 27 additions & 5 deletions account_analytic_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
)

// AccountAnalyticTag represents account.analytic.tag model
// AccountAnalyticTag represents account.analytic.tag model.
type AccountAnalyticTag struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Active *Bool `xmlrpc:"active,omptempty"`
Expand All @@ -18,10 +18,10 @@ type AccountAnalyticTag struct {
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}

// AccountAnalyticTags represents array of account.analytic.tag model
// AccountAnalyticTags represents array of account.analytic.tag model.
type AccountAnalyticTags []AccountAnalyticTag

// AccountAnalyticTagModel is the odoo model name
// AccountAnalyticTagModel is the odoo model name.
const AccountAnalyticTagModel = "account.analytic.tag"

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

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

// FindAccountAnalyticTag finds account.analytic.tag record by querying it with criteria
// FindAccountAnalyticTag finds account.analytic.tag record by querying it with criteria.
func (c *Client) FindAccountAnalyticTag(criteria *Criteria) (*AccountAnalyticTag, error) {
aats := &AccountAnalyticTags{}
if err := c.SearchRead(AccountAnalyticTagModel, criteria, NewOptions().Limit(1), aats); err != nil {
Expand All @@ -97,3 +97,25 @@ func (c *Client) FindAccountAnalyticTags(criteria *Criteria, options *Options) (
}
return aats, nil
}

// FindAccountAnalyticTagIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountAnalyticTagIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(AccountAnalyticTagModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}

// FindAccountAnalyticTagId finds record id by querying it with criteria.
func (c *Client) FindAccountAnalyticTagId(criteria *Criteria) (int64, error) {
ids, err := c.Search(AccountAnalyticTagModel, criteria, NewOptions().Limit(1))
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("account.analytic.tag was not found")
}
32 changes: 27 additions & 5 deletions account_invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
)

// AccountInvoice represents account.invoice model
// AccountInvoice represents account.invoice model.
type AccountInvoice struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
AccessToken *String `xmlrpc:"access_token,omptempty"`
Expand Down Expand Up @@ -96,10 +96,10 @@ type AccountInvoice struct {
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}

// AccountInvoices represents array of account.invoice model
// AccountInvoices represents array of account.invoice model.
type AccountInvoices []AccountInvoice

// AccountInvoiceModel is the odoo model name
// AccountInvoiceModel is the odoo model name.
const AccountInvoiceModel = "account.invoice"

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

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

// FindAccountInvoice finds account.invoice record by querying it with criteria
// FindAccountInvoice finds account.invoice record by querying it with criteria.
func (c *Client) FindAccountInvoice(criteria *Criteria) (*AccountInvoice, error) {
ais := &AccountInvoices{}
if err := c.SearchRead(AccountInvoiceModel, criteria, NewOptions().Limit(1), ais); err != nil {
Expand All @@ -175,3 +175,25 @@ func (c *Client) FindAccountInvoices(criteria *Criteria, options *Options) (*Acc
}
return ais, nil
}

// FindAccountInvoiceIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountInvoiceIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(AccountInvoiceModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}

// FindAccountInvoiceId finds record id by querying it with criteria.
func (c *Client) FindAccountInvoiceId(criteria *Criteria) (int64, error) {
ids, err := c.Search(AccountInvoiceModel, criteria, NewOptions().Limit(1))
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("account.invoice was not found")
}
32 changes: 27 additions & 5 deletions account_invoice_line.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
)

// AccountInvoiceLine represents account.invoice.line model
// AccountInvoiceLine represents account.invoice.line model.
type AccountInvoiceLine struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
AccountAnalyticId *Many2One `xmlrpc:"account_analytic_id,omptempty"`
Expand Down Expand Up @@ -42,10 +42,10 @@ type AccountInvoiceLine struct {
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}

// AccountInvoiceLines represents array of account.invoice.line model
// AccountInvoiceLines represents array of account.invoice.line model.
type AccountInvoiceLines []AccountInvoiceLine

// AccountInvoiceLineModel is the odoo model name
// AccountInvoiceLineModel is the odoo model name.
const AccountInvoiceLineModel = "account.invoice.line"

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

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

// FindAccountInvoiceLine finds account.invoice.line record by querying it with criteria
// FindAccountInvoiceLine finds account.invoice.line record by querying it with criteria.
func (c *Client) FindAccountInvoiceLine(criteria *Criteria) (*AccountInvoiceLine, error) {
ails := &AccountInvoiceLines{}
if err := c.SearchRead(AccountInvoiceLineModel, criteria, NewOptions().Limit(1), ails); err != nil {
Expand All @@ -121,3 +121,25 @@ func (c *Client) FindAccountInvoiceLines(criteria *Criteria, options *Options) (
}
return ails, nil
}

// FindAccountInvoiceLineIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountInvoiceLineIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(AccountInvoiceLineModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}

// FindAccountInvoiceLineId finds record id by querying it with criteria.
func (c *Client) FindAccountInvoiceLineId(criteria *Criteria) (int64, error) {
ids, err := c.Search(AccountInvoiceLineModel, criteria, NewOptions().Limit(1))
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("account.invoice.line was not found")
}
Loading

0 comments on commit bd966f4

Please sign in to comment.