diff --git a/README.md b/README.md index 60c5f033..2d101697 100644 --- a/README.md +++ b/README.md @@ -175,8 +175,8 @@ These functions give you more flexibility but less usability. We recommand you t Here are available low level functions : ```go -func (c *Client) Create(model string, values []interface{}) ([]int64, error) {} !! Creating multiple instances is only for odoo 12+ versions !! -func (c *Client) Update(model string, ids []int64, values interface{}) error {} +func (c *Client) Create(model string, values []interface{}, options *Options) ([]int64, error) {} !! Creating multiple instances is only for odoo 12+ versions !! +func (c *Client) Update(model string, ids []int64, values interface{}, options *Options) error {} func (c *Client) Delete(model string, ids []int64) error {} func (c *Client) SearchRead(model string, criteria *Criteria, options *Options, elem interface{}) error {} func (c *Client) Read(model string, ids []int64, options *Options, elem interface{}) error {} diff --git a/account_abstract_payment.go b/account_abstract_payment.go index 37a1dea1..f68c5e5b 100644 --- a/account_abstract_payment.go +++ b/account_abstract_payment.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountAbstractPayment represents account.abstract.payment model. type AccountAbstractPayment struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -52,7 +48,7 @@ func (c *Client) CreateAccountAbstractPayments(aaps []*AccountAbstractPayment) ( for _, v := range aaps { vv = append(vv, v) } - return c.Create(AccountAbstractPaymentModel, vv) + return c.Create(AccountAbstractPaymentModel, vv, nil) } // UpdateAccountAbstractPayment updates an existing account.abstract.payment record. @@ -63,7 +59,7 @@ func (c *Client) UpdateAccountAbstractPayment(aap *AccountAbstractPayment) error // UpdateAccountAbstractPayments updates existing account.abstract.payment records. // All records (represented by ids) will be updated by aap values. func (c *Client) UpdateAccountAbstractPayments(ids []int64, aap *AccountAbstractPayment) error { - return c.Update(AccountAbstractPaymentModel, ids, aap) + return c.Update(AccountAbstractPaymentModel, ids, aap, nil) } // DeleteAccountAbstractPayment deletes an existing account.abstract.payment record. @@ -82,10 +78,7 @@ func (c *Client) GetAccountAbstractPayment(id int64) (*AccountAbstractPayment, e if err != nil { return nil, err } - if aaps != nil && len(*aaps) > 0 { - return &((*aaps)[0]), nil - } - return nil, fmt.Errorf("id %v of account.abstract.payment not found", id) + return &((*aaps)[0]), nil } // GetAccountAbstractPayments gets account.abstract.payment existing records. @@ -103,10 +96,7 @@ func (c *Client) FindAccountAbstractPayment(criteria *Criteria) (*AccountAbstrac if err := c.SearchRead(AccountAbstractPaymentModel, criteria, NewOptions().Limit(1), aaps); err != nil { return nil, err } - if aaps != nil && len(*aaps) > 0 { - return &((*aaps)[0]), nil - } - return nil, fmt.Errorf("account.abstract.payment was not found with criteria %v", criteria) + return &((*aaps)[0]), nil } // FindAccountAbstractPayments finds account.abstract.payment records by querying it @@ -122,11 +112,7 @@ func (c *Client) FindAccountAbstractPayments(criteria *Criteria, options *Option // FindAccountAbstractPaymentIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountAbstractPaymentIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountAbstractPaymentModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountAbstractPaymentModel, criteria, options) } // FindAccountAbstractPaymentId finds record id by querying it with criteria. @@ -135,8 +121,5 @@ func (c *Client) FindAccountAbstractPaymentId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.abstract.payment was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_account.go b/account_account.go index fd8fd7e4..4044f595 100644 --- a/account_account.go +++ b/account_account.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountAccount represents account.account model. type AccountAccount struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -59,7 +55,7 @@ func (c *Client) CreateAccountAccounts(aas []*AccountAccount) ([]int64, error) { for _, v := range aas { vv = append(vv, v) } - return c.Create(AccountAccountModel, vv) + return c.Create(AccountAccountModel, vv, nil) } // UpdateAccountAccount updates an existing account.account record. @@ -70,7 +66,7 @@ func (c *Client) UpdateAccountAccount(aa *AccountAccount) error { // UpdateAccountAccounts updates existing account.account records. // All records (represented by ids) will be updated by aa values. func (c *Client) UpdateAccountAccounts(ids []int64, aa *AccountAccount) error { - return c.Update(AccountAccountModel, ids, aa) + return c.Update(AccountAccountModel, ids, aa, nil) } // DeleteAccountAccount deletes an existing account.account record. @@ -89,10 +85,7 @@ func (c *Client) GetAccountAccount(id int64) (*AccountAccount, error) { if err != nil { return nil, err } - if aas != nil && len(*aas) > 0 { - return &((*aas)[0]), nil - } - return nil, fmt.Errorf("id %v of account.account not found", id) + return &((*aas)[0]), nil } // GetAccountAccounts gets account.account existing records. @@ -110,10 +103,7 @@ func (c *Client) FindAccountAccount(criteria *Criteria) (*AccountAccount, error) if err := c.SearchRead(AccountAccountModel, criteria, NewOptions().Limit(1), aas); err != nil { return nil, err } - if aas != nil && len(*aas) > 0 { - return &((*aas)[0]), nil - } - return nil, fmt.Errorf("account.account was not found with criteria %v", criteria) + return &((*aas)[0]), nil } // FindAccountAccounts finds account.account records by querying it @@ -129,11 +119,7 @@ func (c *Client) FindAccountAccounts(criteria *Criteria, options *Options) (*Acc // 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 + return c.Search(AccountAccountModel, criteria, options) } // FindAccountAccountId finds record id by querying it with criteria. @@ -142,8 +128,5 @@ func (c *Client) FindAccountAccountId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.account was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_account_tag.go b/account_account_tag.go index 0b152f0c..51d2a109 100644 --- a/account_account_tag.go +++ b/account_account_tag.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountAccountTag represents account.account.tag model. type AccountAccountTag struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateAccountAccountTags(aats []*AccountAccountTag) ([]int64, e for _, v := range aats { vv = append(vv, v) } - return c.Create(AccountAccountTagModel, vv) + return c.Create(AccountAccountTagModel, vv, nil) } // UpdateAccountAccountTag updates an existing account.account.tag record. @@ -59,7 +55,7 @@ func (c *Client) UpdateAccountAccountTag(aat *AccountAccountTag) error { // UpdateAccountAccountTags updates existing account.account.tag records. // All records (represented by ids) will be updated by aat values. func (c *Client) UpdateAccountAccountTags(ids []int64, aat *AccountAccountTag) error { - return c.Update(AccountAccountTagModel, ids, aat) + return c.Update(AccountAccountTagModel, ids, aat, nil) } // DeleteAccountAccountTag deletes an existing account.account.tag record. @@ -78,10 +74,7 @@ func (c *Client) GetAccountAccountTag(id int64) (*AccountAccountTag, error) { if err != nil { return nil, err } - if aats != nil && len(*aats) > 0 { - return &((*aats)[0]), nil - } - return nil, fmt.Errorf("id %v of account.account.tag not found", id) + return &((*aats)[0]), nil } // GetAccountAccountTags gets account.account.tag existing records. @@ -99,10 +92,7 @@ func (c *Client) FindAccountAccountTag(criteria *Criteria) (*AccountAccountTag, if err := c.SearchRead(AccountAccountTagModel, criteria, NewOptions().Limit(1), aats); err != nil { return nil, err } - if aats != nil && len(*aats) > 0 { - return &((*aats)[0]), nil - } - return nil, fmt.Errorf("account.account.tag was not found with criteria %v", criteria) + return &((*aats)[0]), nil } // FindAccountAccountTags finds account.account.tag records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindAccountAccountTags(criteria *Criteria, options *Options) (* // FindAccountAccountTagIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountAccountTagIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountAccountTagModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountAccountTagModel, criteria, options) } // FindAccountAccountTagId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindAccountAccountTagId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.account.tag was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_account_template.go b/account_account_template.go index 70bf34a8..aa3f5c62 100644 --- a/account_account_template.go +++ b/account_account_template.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountAccountTemplate represents account.account.template model. type AccountAccountTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -55,7 +51,7 @@ func (c *Client) CreateAccountAccountTemplates(aats []*AccountAccountTemplate) ( for _, v := range aats { vv = append(vv, v) } - return c.Create(AccountAccountTemplateModel, vv) + return c.Create(AccountAccountTemplateModel, vv, nil) } // UpdateAccountAccountTemplate updates an existing account.account.template record. @@ -66,7 +62,7 @@ func (c *Client) UpdateAccountAccountTemplate(aat *AccountAccountTemplate) error // UpdateAccountAccountTemplates updates existing account.account.template records. // All records (represented by ids) will be updated by aat values. func (c *Client) UpdateAccountAccountTemplates(ids []int64, aat *AccountAccountTemplate) error { - return c.Update(AccountAccountTemplateModel, ids, aat) + return c.Update(AccountAccountTemplateModel, ids, aat, nil) } // DeleteAccountAccountTemplate deletes an existing account.account.template record. @@ -85,10 +81,7 @@ func (c *Client) GetAccountAccountTemplate(id int64) (*AccountAccountTemplate, e if err != nil { return nil, err } - if aats != nil && len(*aats) > 0 { - return &((*aats)[0]), nil - } - return nil, fmt.Errorf("id %v of account.account.template not found", id) + return &((*aats)[0]), nil } // GetAccountAccountTemplates gets account.account.template existing records. @@ -106,10 +99,7 @@ func (c *Client) FindAccountAccountTemplate(criteria *Criteria) (*AccountAccount if err := c.SearchRead(AccountAccountTemplateModel, criteria, NewOptions().Limit(1), aats); err != nil { return nil, err } - if aats != nil && len(*aats) > 0 { - return &((*aats)[0]), nil - } - return nil, fmt.Errorf("account.account.template was not found with criteria %v", criteria) + return &((*aats)[0]), nil } // FindAccountAccountTemplates finds account.account.template records by querying it @@ -125,11 +115,7 @@ func (c *Client) FindAccountAccountTemplates(criteria *Criteria, options *Option // FindAccountAccountTemplateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountAccountTemplateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountAccountTemplateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountAccountTemplateModel, criteria, options) } // FindAccountAccountTemplateId finds record id by querying it with criteria. @@ -138,8 +124,5 @@ func (c *Client) FindAccountAccountTemplateId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.account.template was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_account_type.go b/account_account_type.go index 4b6a2667..d156d00b 100644 --- a/account_account_type.go +++ b/account_account_type.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountAccountType represents account.account.type model. type AccountAccountType struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateAccountAccountTypes(aats []*AccountAccountType) ([]int64, for _, v := range aats { vv = append(vv, v) } - return c.Create(AccountAccountTypeModel, vv) + return c.Create(AccountAccountTypeModel, vv, nil) } // UpdateAccountAccountType updates an existing account.account.type record. @@ -59,7 +55,7 @@ func (c *Client) UpdateAccountAccountType(aat *AccountAccountType) error { // UpdateAccountAccountTypes updates existing account.account.type records. // All records (represented by ids) will be updated by aat values. func (c *Client) UpdateAccountAccountTypes(ids []int64, aat *AccountAccountType) error { - return c.Update(AccountAccountTypeModel, ids, aat) + return c.Update(AccountAccountTypeModel, ids, aat, nil) } // DeleteAccountAccountType deletes an existing account.account.type record. @@ -78,10 +74,7 @@ func (c *Client) GetAccountAccountType(id int64) (*AccountAccountType, error) { if err != nil { return nil, err } - if aats != nil && len(*aats) > 0 { - return &((*aats)[0]), nil - } - return nil, fmt.Errorf("id %v of account.account.type not found", id) + return &((*aats)[0]), nil } // GetAccountAccountTypes gets account.account.type existing records. @@ -99,10 +92,7 @@ func (c *Client) FindAccountAccountType(criteria *Criteria) (*AccountAccountType if err := c.SearchRead(AccountAccountTypeModel, criteria, NewOptions().Limit(1), aats); err != nil { return nil, err } - if aats != nil && len(*aats) > 0 { - return &((*aats)[0]), nil - } - return nil, fmt.Errorf("account.account.type was not found with criteria %v", criteria) + return &((*aats)[0]), nil } // FindAccountAccountTypes finds account.account.type records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindAccountAccountTypes(criteria *Criteria, options *Options) ( // FindAccountAccountTypeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountAccountTypeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountAccountTypeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountAccountTypeModel, criteria, options) } // FindAccountAccountTypeId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindAccountAccountTypeId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.account.type was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_aged_trial_balance.go b/account_aged_trial_balance.go index 4257c1a1..d7df2c45 100644 --- a/account_aged_trial_balance.go +++ b/account_aged_trial_balance.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountAgedTrialBalance represents account.aged.trial.balance model. type AccountAgedTrialBalance struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -51,7 +47,7 @@ func (c *Client) CreateAccountAgedTrialBalances(aatbs []*AccountAgedTrialBalance for _, v := range aatbs { vv = append(vv, v) } - return c.Create(AccountAgedTrialBalanceModel, vv) + return c.Create(AccountAgedTrialBalanceModel, vv, nil) } // UpdateAccountAgedTrialBalance updates an existing account.aged.trial.balance record. @@ -62,7 +58,7 @@ func (c *Client) UpdateAccountAgedTrialBalance(aatb *AccountAgedTrialBalance) er // UpdateAccountAgedTrialBalances updates existing account.aged.trial.balance records. // All records (represented by ids) will be updated by aatb values. func (c *Client) UpdateAccountAgedTrialBalances(ids []int64, aatb *AccountAgedTrialBalance) error { - return c.Update(AccountAgedTrialBalanceModel, ids, aatb) + return c.Update(AccountAgedTrialBalanceModel, ids, aatb, nil) } // DeleteAccountAgedTrialBalance deletes an existing account.aged.trial.balance record. @@ -81,10 +77,7 @@ func (c *Client) GetAccountAgedTrialBalance(id int64) (*AccountAgedTrialBalance, if err != nil { return nil, err } - if aatbs != nil && len(*aatbs) > 0 { - return &((*aatbs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.aged.trial.balance not found", id) + return &((*aatbs)[0]), nil } // GetAccountAgedTrialBalances gets account.aged.trial.balance existing records. @@ -102,10 +95,7 @@ func (c *Client) FindAccountAgedTrialBalance(criteria *Criteria) (*AccountAgedTr if err := c.SearchRead(AccountAgedTrialBalanceModel, criteria, NewOptions().Limit(1), aatbs); err != nil { return nil, err } - if aatbs != nil && len(*aatbs) > 0 { - return &((*aatbs)[0]), nil - } - return nil, fmt.Errorf("account.aged.trial.balance was not found with criteria %v", criteria) + return &((*aatbs)[0]), nil } // FindAccountAgedTrialBalances finds account.aged.trial.balance records by querying it @@ -121,11 +111,7 @@ func (c *Client) FindAccountAgedTrialBalances(criteria *Criteria, options *Optio // FindAccountAgedTrialBalanceIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountAgedTrialBalanceIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountAgedTrialBalanceModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountAgedTrialBalanceModel, criteria, options) } // FindAccountAgedTrialBalanceId finds record id by querying it with criteria. @@ -134,8 +120,5 @@ func (c *Client) FindAccountAgedTrialBalanceId(criteria *Criteria, options *Opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.aged.trial.balance was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_analytic_account.go b/account_analytic_account.go index 597e9c08..5ed204d2 100644 --- a/account_analytic_account.go +++ b/account_analytic_account.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountAnalyticAccount represents account.analytic.account model. type AccountAnalyticAccount struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -21,6 +17,7 @@ type AccountAnalyticAccount struct { Id *Int `xmlrpc:"id,omptempty"` LineIds *Relation `xmlrpc:"line_ids,omptempty"` MachineInitiativeName *String `xmlrpc:"machine_initiative_name,omptempty"` + MachineProjectName *String `xmlrpc:"machine_project_name,omptempty"` MessageChannelIds *Relation `xmlrpc:"message_channel_ids,omptempty"` MessageFollowerIds *Relation `xmlrpc:"message_follower_ids,omptempty"` MessageIds *Relation `xmlrpc:"message_ids,omptempty"` @@ -34,6 +31,7 @@ type AccountAnalyticAccount struct { Name *String `xmlrpc:"name,omptempty"` PartnerId *Many2One `xmlrpc:"partner_id,omptempty"` ProjectCount *Int `xmlrpc:"project_count,omptempty"` + ProjectCreated *Bool `xmlrpc:"project_created,omptempty"` ProjectIds *Relation `xmlrpc:"project_ids,omptempty"` TagIds *Relation `xmlrpc:"tag_ids,omptempty"` WebsiteMessageIds *Relation `xmlrpc:"website_message_ids,omptempty"` @@ -70,7 +68,7 @@ func (c *Client) CreateAccountAnalyticAccounts(aaas []*AccountAnalyticAccount) ( for _, v := range aaas { vv = append(vv, v) } - return c.Create(AccountAnalyticAccountModel, vv) + return c.Create(AccountAnalyticAccountModel, vv, nil) } // UpdateAccountAnalyticAccount updates an existing account.analytic.account record. @@ -81,7 +79,7 @@ func (c *Client) UpdateAccountAnalyticAccount(aaa *AccountAnalyticAccount) error // UpdateAccountAnalyticAccounts updates existing account.analytic.account records. // All records (represented by ids) will be updated by aaa values. func (c *Client) UpdateAccountAnalyticAccounts(ids []int64, aaa *AccountAnalyticAccount) error { - return c.Update(AccountAnalyticAccountModel, ids, aaa) + return c.Update(AccountAnalyticAccountModel, ids, aaa, nil) } // DeleteAccountAnalyticAccount deletes an existing account.analytic.account record. @@ -100,10 +98,7 @@ func (c *Client) GetAccountAnalyticAccount(id int64) (*AccountAnalyticAccount, e if err != nil { return nil, err } - if aaas != nil && len(*aaas) > 0 { - return &((*aaas)[0]), nil - } - return nil, fmt.Errorf("id %v of account.analytic.account not found", id) + return &((*aaas)[0]), nil } // GetAccountAnalyticAccounts gets account.analytic.account existing records. @@ -121,10 +116,7 @@ func (c *Client) FindAccountAnalyticAccount(criteria *Criteria) (*AccountAnalyti if err := c.SearchRead(AccountAnalyticAccountModel, criteria, NewOptions().Limit(1), aaas); err != nil { return nil, err } - if aaas != nil && len(*aaas) > 0 { - return &((*aaas)[0]), nil - } - return nil, fmt.Errorf("account.analytic.account was not found with criteria %v", criteria) + return &((*aaas)[0]), nil } // FindAccountAnalyticAccounts finds account.analytic.account records by querying it @@ -140,11 +132,7 @@ func (c *Client) FindAccountAnalyticAccounts(criteria *Criteria, options *Option // 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 + return c.Search(AccountAnalyticAccountModel, criteria, options) } // FindAccountAnalyticAccountId finds record id by querying it with criteria. @@ -153,8 +141,5 @@ func (c *Client) FindAccountAnalyticAccountId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.analytic.account was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_analytic_line.go b/account_analytic_line.go index 685e8f90..4ec9de65 100644 --- a/account_analytic_line.go +++ b/account_analytic_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountAnalyticLine represents account.analytic.line model. type AccountAnalyticLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -72,7 +68,7 @@ func (c *Client) CreateAccountAnalyticLines(aals []*AccountAnalyticLine) ([]int6 for _, v := range aals { vv = append(vv, v) } - return c.Create(AccountAnalyticLineModel, vv) + return c.Create(AccountAnalyticLineModel, vv, nil) } // UpdateAccountAnalyticLine updates an existing account.analytic.line record. @@ -83,7 +79,7 @@ func (c *Client) UpdateAccountAnalyticLine(aal *AccountAnalyticLine) error { // 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) + return c.Update(AccountAnalyticLineModel, ids, aal, nil) } // DeleteAccountAnalyticLine deletes an existing account.analytic.line record. @@ -102,10 +98,7 @@ func (c *Client) GetAccountAnalyticLine(id int64) (*AccountAnalyticLine, error) if err != nil { return nil, err } - if aals != nil && len(*aals) > 0 { - return &((*aals)[0]), nil - } - return nil, fmt.Errorf("id %v of account.analytic.line not found", id) + return &((*aals)[0]), nil } // GetAccountAnalyticLines gets account.analytic.line existing records. @@ -123,10 +116,7 @@ func (c *Client) FindAccountAnalyticLine(criteria *Criteria) (*AccountAnalyticLi 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 with criteria %v", criteria) + return &((*aals)[0]), nil } // FindAccountAnalyticLines finds account.analytic.line records by querying it @@ -142,11 +132,7 @@ func (c *Client) FindAccountAnalyticLines(criteria *Criteria, options *Options) // 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 + return c.Search(AccountAnalyticLineModel, criteria, options) } // FindAccountAnalyticLineId finds record id by querying it with criteria. @@ -155,8 +141,5 @@ func (c *Client) FindAccountAnalyticLineId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.analytic.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_analytic_tag.go b/account_analytic_tag.go index cb5b6e1d..bff688f1 100644 --- a/account_analytic_tag.go +++ b/account_analytic_tag.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountAnalyticTag represents account.analytic.tag model. type AccountAnalyticTag struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateAccountAnalyticTags(aats []*AccountAnalyticTag) ([]int64, for _, v := range aats { vv = append(vv, v) } - return c.Create(AccountAnalyticTagModel, vv) + return c.Create(AccountAnalyticTagModel, vv, nil) } // UpdateAccountAnalyticTag updates an existing account.analytic.tag record. @@ -58,7 +54,7 @@ func (c *Client) UpdateAccountAnalyticTag(aat *AccountAnalyticTag) error { // UpdateAccountAnalyticTags updates existing account.analytic.tag records. // All records (represented by ids) will be updated by aat values. func (c *Client) UpdateAccountAnalyticTags(ids []int64, aat *AccountAnalyticTag) error { - return c.Update(AccountAnalyticTagModel, ids, aat) + return c.Update(AccountAnalyticTagModel, ids, aat, nil) } // DeleteAccountAnalyticTag deletes an existing account.analytic.tag record. @@ -77,10 +73,7 @@ func (c *Client) GetAccountAnalyticTag(id int64) (*AccountAnalyticTag, error) { if err != nil { return nil, err } - if aats != nil && len(*aats) > 0 { - return &((*aats)[0]), nil - } - return nil, fmt.Errorf("id %v of account.analytic.tag not found", id) + return &((*aats)[0]), nil } // GetAccountAnalyticTags gets account.analytic.tag existing records. @@ -98,10 +91,7 @@ func (c *Client) FindAccountAnalyticTag(criteria *Criteria) (*AccountAnalyticTag if err := c.SearchRead(AccountAnalyticTagModel, criteria, NewOptions().Limit(1), aats); err != nil { return nil, err } - if aats != nil && len(*aats) > 0 { - return &((*aats)[0]), nil - } - return nil, fmt.Errorf("account.analytic.tag was not found with criteria %v", criteria) + return &((*aats)[0]), nil } // FindAccountAnalyticTags finds account.analytic.tag records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindAccountAnalyticTags(criteria *Criteria, options *Options) ( // 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 + return c.Search(AccountAnalyticTagModel, criteria, options) } // FindAccountAnalyticTagId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindAccountAnalyticTagId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.analytic.tag was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_balance_report.go b/account_balance_report.go index 5d595a66..09428756 100644 --- a/account_balance_report.go +++ b/account_balance_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountBalanceReport represents account.balance.report model. type AccountBalanceReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateAccountBalanceReports(abrs []*AccountBalanceReport) ([]in for _, v := range abrs { vv = append(vv, v) } - return c.Create(AccountBalanceReportModel, vv) + return c.Create(AccountBalanceReportModel, vv, nil) } // UpdateAccountBalanceReport updates an existing account.balance.report record. @@ -61,7 +57,7 @@ func (c *Client) UpdateAccountBalanceReport(abr *AccountBalanceReport) error { // UpdateAccountBalanceReports updates existing account.balance.report records. // All records (represented by ids) will be updated by abr values. func (c *Client) UpdateAccountBalanceReports(ids []int64, abr *AccountBalanceReport) error { - return c.Update(AccountBalanceReportModel, ids, abr) + return c.Update(AccountBalanceReportModel, ids, abr, nil) } // DeleteAccountBalanceReport deletes an existing account.balance.report record. @@ -80,10 +76,7 @@ func (c *Client) GetAccountBalanceReport(id int64) (*AccountBalanceReport, error if err != nil { return nil, err } - if abrs != nil && len(*abrs) > 0 { - return &((*abrs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.balance.report not found", id) + return &((*abrs)[0]), nil } // GetAccountBalanceReports gets account.balance.report existing records. @@ -101,10 +94,7 @@ func (c *Client) FindAccountBalanceReport(criteria *Criteria) (*AccountBalanceRe if err := c.SearchRead(AccountBalanceReportModel, criteria, NewOptions().Limit(1), abrs); err != nil { return nil, err } - if abrs != nil && len(*abrs) > 0 { - return &((*abrs)[0]), nil - } - return nil, fmt.Errorf("account.balance.report was not found with criteria %v", criteria) + return &((*abrs)[0]), nil } // FindAccountBalanceReports finds account.balance.report records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindAccountBalanceReports(criteria *Criteria, options *Options) // FindAccountBalanceReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountBalanceReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountBalanceReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountBalanceReportModel, criteria, options) } // FindAccountBalanceReportId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindAccountBalanceReportId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.balance.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_bank_accounts_wizard.go b/account_bank_accounts_wizard.go index e5a81645..e2d5d9a4 100644 --- a/account_bank_accounts_wizard.go +++ b/account_bank_accounts_wizard.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountBankAccountsWizard represents account.bank.accounts.wizard model. type AccountBankAccountsWizard struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateAccountBankAccountsWizards(abaws []*AccountBankAccountsWi for _, v := range abaws { vv = append(vv, v) } - return c.Create(AccountBankAccountsWizardModel, vv) + return c.Create(AccountBankAccountsWizardModel, vv, nil) } // UpdateAccountBankAccountsWizard updates an existing account.bank.accounts.wizard record. @@ -59,7 +55,7 @@ func (c *Client) UpdateAccountBankAccountsWizard(abaw *AccountBankAccountsWizard // UpdateAccountBankAccountsWizards updates existing account.bank.accounts.wizard records. // All records (represented by ids) will be updated by abaw values. func (c *Client) UpdateAccountBankAccountsWizards(ids []int64, abaw *AccountBankAccountsWizard) error { - return c.Update(AccountBankAccountsWizardModel, ids, abaw) + return c.Update(AccountBankAccountsWizardModel, ids, abaw, nil) } // DeleteAccountBankAccountsWizard deletes an existing account.bank.accounts.wizard record. @@ -78,10 +74,7 @@ func (c *Client) GetAccountBankAccountsWizard(id int64) (*AccountBankAccountsWiz if err != nil { return nil, err } - if abaws != nil && len(*abaws) > 0 { - return &((*abaws)[0]), nil - } - return nil, fmt.Errorf("id %v of account.bank.accounts.wizard not found", id) + return &((*abaws)[0]), nil } // GetAccountBankAccountsWizards gets account.bank.accounts.wizard existing records. @@ -99,10 +92,7 @@ func (c *Client) FindAccountBankAccountsWizard(criteria *Criteria) (*AccountBank if err := c.SearchRead(AccountBankAccountsWizardModel, criteria, NewOptions().Limit(1), abaws); err != nil { return nil, err } - if abaws != nil && len(*abaws) > 0 { - return &((*abaws)[0]), nil - } - return nil, fmt.Errorf("account.bank.accounts.wizard was not found with criteria %v", criteria) + return &((*abaws)[0]), nil } // FindAccountBankAccountsWizards finds account.bank.accounts.wizard records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindAccountBankAccountsWizards(criteria *Criteria, options *Opt // FindAccountBankAccountsWizardIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountBankAccountsWizardIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountBankAccountsWizardModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountBankAccountsWizardModel, criteria, options) } // FindAccountBankAccountsWizardId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindAccountBankAccountsWizardId(criteria *Criteria, options *Op if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.bank.accounts.wizard was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_bank_statement.go b/account_bank_statement.go index 7fa4c0f7..32d2f90c 100644 --- a/account_bank_statement.go +++ b/account_bank_statement.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountBankStatement represents account.bank.statement model. type AccountBankStatement struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -77,7 +73,7 @@ func (c *Client) CreateAccountBankStatements(abss []*AccountBankStatement) ([]in for _, v := range abss { vv = append(vv, v) } - return c.Create(AccountBankStatementModel, vv) + return c.Create(AccountBankStatementModel, vv, nil) } // UpdateAccountBankStatement updates an existing account.bank.statement record. @@ -88,7 +84,7 @@ func (c *Client) UpdateAccountBankStatement(abs *AccountBankStatement) error { // UpdateAccountBankStatements updates existing account.bank.statement records. // All records (represented by ids) will be updated by abs values. func (c *Client) UpdateAccountBankStatements(ids []int64, abs *AccountBankStatement) error { - return c.Update(AccountBankStatementModel, ids, abs) + return c.Update(AccountBankStatementModel, ids, abs, nil) } // DeleteAccountBankStatement deletes an existing account.bank.statement record. @@ -107,10 +103,7 @@ func (c *Client) GetAccountBankStatement(id int64) (*AccountBankStatement, error if err != nil { return nil, err } - if abss != nil && len(*abss) > 0 { - return &((*abss)[0]), nil - } - return nil, fmt.Errorf("id %v of account.bank.statement not found", id) + return &((*abss)[0]), nil } // GetAccountBankStatements gets account.bank.statement existing records. @@ -128,10 +121,7 @@ func (c *Client) FindAccountBankStatement(criteria *Criteria) (*AccountBankState if err := c.SearchRead(AccountBankStatementModel, criteria, NewOptions().Limit(1), abss); err != nil { return nil, err } - if abss != nil && len(*abss) > 0 { - return &((*abss)[0]), nil - } - return nil, fmt.Errorf("account.bank.statement was not found with criteria %v", criteria) + return &((*abss)[0]), nil } // FindAccountBankStatements finds account.bank.statement records by querying it @@ -147,11 +137,7 @@ func (c *Client) FindAccountBankStatements(criteria *Criteria, options *Options) // FindAccountBankStatementIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountBankStatementIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountBankStatementModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountBankStatementModel, criteria, options) } // FindAccountBankStatementId finds record id by querying it with criteria. @@ -160,8 +146,5 @@ func (c *Client) FindAccountBankStatementId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.bank.statement was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_bank_statement_cashbox.go b/account_bank_statement_cashbox.go index 9e0b9181..fa839c54 100644 --- a/account_bank_statement_cashbox.go +++ b/account_bank_statement_cashbox.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountBankStatementCashbox represents account.bank.statement.cashbox model. type AccountBankStatementCashbox struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateAccountBankStatementCashboxs(abscs []*AccountBankStatemen for _, v := range abscs { vv = append(vv, v) } - return c.Create(AccountBankStatementCashboxModel, vv) + return c.Create(AccountBankStatementCashboxModel, vv, nil) } // UpdateAccountBankStatementCashbox updates an existing account.bank.statement.cashbox record. @@ -56,7 +52,7 @@ func (c *Client) UpdateAccountBankStatementCashbox(absc *AccountBankStatementCas // UpdateAccountBankStatementCashboxs updates existing account.bank.statement.cashbox records. // All records (represented by ids) will be updated by absc values. func (c *Client) UpdateAccountBankStatementCashboxs(ids []int64, absc *AccountBankStatementCashbox) error { - return c.Update(AccountBankStatementCashboxModel, ids, absc) + return c.Update(AccountBankStatementCashboxModel, ids, absc, nil) } // DeleteAccountBankStatementCashbox deletes an existing account.bank.statement.cashbox record. @@ -75,10 +71,7 @@ func (c *Client) GetAccountBankStatementCashbox(id int64) (*AccountBankStatement if err != nil { return nil, err } - if abscs != nil && len(*abscs) > 0 { - return &((*abscs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.bank.statement.cashbox not found", id) + return &((*abscs)[0]), nil } // GetAccountBankStatementCashboxs gets account.bank.statement.cashbox existing records. @@ -96,10 +89,7 @@ func (c *Client) FindAccountBankStatementCashbox(criteria *Criteria) (*AccountBa if err := c.SearchRead(AccountBankStatementCashboxModel, criteria, NewOptions().Limit(1), abscs); err != nil { return nil, err } - if abscs != nil && len(*abscs) > 0 { - return &((*abscs)[0]), nil - } - return nil, fmt.Errorf("account.bank.statement.cashbox was not found with criteria %v", criteria) + return &((*abscs)[0]), nil } // FindAccountBankStatementCashboxs finds account.bank.statement.cashbox records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindAccountBankStatementCashboxs(criteria *Criteria, options *O // FindAccountBankStatementCashboxIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountBankStatementCashboxIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountBankStatementCashboxModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountBankStatementCashboxModel, criteria, options) } // FindAccountBankStatementCashboxId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindAccountBankStatementCashboxId(criteria *Criteria, options * if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.bank.statement.cashbox was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_bank_statement_closebalance.go b/account_bank_statement_closebalance.go index bbb00ad3..9aebd774 100644 --- a/account_bank_statement_closebalance.go +++ b/account_bank_statement_closebalance.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountBankStatementClosebalance represents account.bank.statement.closebalance model. type AccountBankStatementClosebalance struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -44,7 +40,7 @@ func (c *Client) CreateAccountBankStatementClosebalances(abscs []*AccountBankSta for _, v := range abscs { vv = append(vv, v) } - return c.Create(AccountBankStatementClosebalanceModel, vv) + return c.Create(AccountBankStatementClosebalanceModel, vv, nil) } // UpdateAccountBankStatementClosebalance updates an existing account.bank.statement.closebalance record. @@ -55,7 +51,7 @@ func (c *Client) UpdateAccountBankStatementClosebalance(absc *AccountBankStateme // UpdateAccountBankStatementClosebalances updates existing account.bank.statement.closebalance records. // All records (represented by ids) will be updated by absc values. func (c *Client) UpdateAccountBankStatementClosebalances(ids []int64, absc *AccountBankStatementClosebalance) error { - return c.Update(AccountBankStatementClosebalanceModel, ids, absc) + return c.Update(AccountBankStatementClosebalanceModel, ids, absc, nil) } // DeleteAccountBankStatementClosebalance deletes an existing account.bank.statement.closebalance record. @@ -74,10 +70,7 @@ func (c *Client) GetAccountBankStatementClosebalance(id int64) (*AccountBankStat if err != nil { return nil, err } - if abscs != nil && len(*abscs) > 0 { - return &((*abscs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.bank.statement.closebalance not found", id) + return &((*abscs)[0]), nil } // GetAccountBankStatementClosebalances gets account.bank.statement.closebalance existing records. @@ -95,10 +88,7 @@ func (c *Client) FindAccountBankStatementClosebalance(criteria *Criteria) (*Acco if err := c.SearchRead(AccountBankStatementClosebalanceModel, criteria, NewOptions().Limit(1), abscs); err != nil { return nil, err } - if abscs != nil && len(*abscs) > 0 { - return &((*abscs)[0]), nil - } - return nil, fmt.Errorf("account.bank.statement.closebalance was not found with criteria %v", criteria) + return &((*abscs)[0]), nil } // FindAccountBankStatementClosebalances finds account.bank.statement.closebalance records by querying it @@ -114,11 +104,7 @@ func (c *Client) FindAccountBankStatementClosebalances(criteria *Criteria, optio // FindAccountBankStatementClosebalanceIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountBankStatementClosebalanceIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountBankStatementClosebalanceModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountBankStatementClosebalanceModel, criteria, options) } // FindAccountBankStatementClosebalanceId finds record id by querying it with criteria. @@ -127,8 +113,5 @@ func (c *Client) FindAccountBankStatementClosebalanceId(criteria *Criteria, opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.bank.statement.closebalance was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_bank_statement_import.go b/account_bank_statement_import.go index bc686f86..de01ef3d 100644 --- a/account_bank_statement_import.go +++ b/account_bank_statement_import.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountBankStatementImport represents account.bank.statement.import model. type AccountBankStatementImport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateAccountBankStatementImports(absis []*AccountBankStatement for _, v := range absis { vv = append(vv, v) } - return c.Create(AccountBankStatementImportModel, vv) + return c.Create(AccountBankStatementImportModel, vv, nil) } // UpdateAccountBankStatementImport updates an existing account.bank.statement.import record. @@ -57,7 +53,7 @@ func (c *Client) UpdateAccountBankStatementImport(absi *AccountBankStatementImpo // UpdateAccountBankStatementImports updates existing account.bank.statement.import records. // All records (represented by ids) will be updated by absi values. func (c *Client) UpdateAccountBankStatementImports(ids []int64, absi *AccountBankStatementImport) error { - return c.Update(AccountBankStatementImportModel, ids, absi) + return c.Update(AccountBankStatementImportModel, ids, absi, nil) } // DeleteAccountBankStatementImport deletes an existing account.bank.statement.import record. @@ -76,10 +72,7 @@ func (c *Client) GetAccountBankStatementImport(id int64) (*AccountBankStatementI if err != nil { return nil, err } - if absis != nil && len(*absis) > 0 { - return &((*absis)[0]), nil - } - return nil, fmt.Errorf("id %v of account.bank.statement.import not found", id) + return &((*absis)[0]), nil } // GetAccountBankStatementImports gets account.bank.statement.import existing records. @@ -97,10 +90,7 @@ func (c *Client) FindAccountBankStatementImport(criteria *Criteria) (*AccountBan if err := c.SearchRead(AccountBankStatementImportModel, criteria, NewOptions().Limit(1), absis); err != nil { return nil, err } - if absis != nil && len(*absis) > 0 { - return &((*absis)[0]), nil - } - return nil, fmt.Errorf("account.bank.statement.import was not found with criteria %v", criteria) + return &((*absis)[0]), nil } // FindAccountBankStatementImports finds account.bank.statement.import records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindAccountBankStatementImports(criteria *Criteria, options *Op // FindAccountBankStatementImportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountBankStatementImportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountBankStatementImportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountBankStatementImportModel, criteria, options) } // FindAccountBankStatementImportId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindAccountBankStatementImportId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.bank.statement.import was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_bank_statement_import_journal_creation.go b/account_bank_statement_import_journal_creation.go index f96a0a03..59fc90db 100644 --- a/account_bank_statement_import_journal_creation.go +++ b/account_bank_statement_import_journal_creation.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountBankStatementImportJournalCreation represents account.bank.statement.import.journal.creation model. type AccountBankStatementImportJournalCreation struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -79,7 +75,7 @@ func (c *Client) CreateAccountBankStatementImportJournalCreations(absijcs []*Acc for _, v := range absijcs { vv = append(vv, v) } - return c.Create(AccountBankStatementImportJournalCreationModel, vv) + return c.Create(AccountBankStatementImportJournalCreationModel, vv, nil) } // UpdateAccountBankStatementImportJournalCreation updates an existing account.bank.statement.import.journal.creation record. @@ -90,7 +86,7 @@ func (c *Client) UpdateAccountBankStatementImportJournalCreation(absijc *Account // UpdateAccountBankStatementImportJournalCreations updates existing account.bank.statement.import.journal.creation records. // All records (represented by ids) will be updated by absijc values. func (c *Client) UpdateAccountBankStatementImportJournalCreations(ids []int64, absijc *AccountBankStatementImportJournalCreation) error { - return c.Update(AccountBankStatementImportJournalCreationModel, ids, absijc) + return c.Update(AccountBankStatementImportJournalCreationModel, ids, absijc, nil) } // DeleteAccountBankStatementImportJournalCreation deletes an existing account.bank.statement.import.journal.creation record. @@ -109,10 +105,7 @@ func (c *Client) GetAccountBankStatementImportJournalCreation(id int64) (*Accoun if err != nil { return nil, err } - if absijcs != nil && len(*absijcs) > 0 { - return &((*absijcs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.bank.statement.import.journal.creation not found", id) + return &((*absijcs)[0]), nil } // GetAccountBankStatementImportJournalCreations gets account.bank.statement.import.journal.creation existing records. @@ -130,10 +123,7 @@ func (c *Client) FindAccountBankStatementImportJournalCreation(criteria *Criteri if err := c.SearchRead(AccountBankStatementImportJournalCreationModel, criteria, NewOptions().Limit(1), absijcs); err != nil { return nil, err } - if absijcs != nil && len(*absijcs) > 0 { - return &((*absijcs)[0]), nil - } - return nil, fmt.Errorf("account.bank.statement.import.journal.creation was not found with criteria %v", criteria) + return &((*absijcs)[0]), nil } // FindAccountBankStatementImportJournalCreations finds account.bank.statement.import.journal.creation records by querying it @@ -149,11 +139,7 @@ func (c *Client) FindAccountBankStatementImportJournalCreations(criteria *Criter // FindAccountBankStatementImportJournalCreationIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountBankStatementImportJournalCreationIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountBankStatementImportJournalCreationModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountBankStatementImportJournalCreationModel, criteria, options) } // FindAccountBankStatementImportJournalCreationId finds record id by querying it with criteria. @@ -162,8 +148,5 @@ func (c *Client) FindAccountBankStatementImportJournalCreationId(criteria *Crite if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.bank.statement.import.journal.creation was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_bank_statement_line.go b/account_bank_statement_line.go index 700f8fe7..4ea86b04 100644 --- a/account_bank_statement_line.go +++ b/account_bank_statement_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountBankStatementLine represents account.bank.statement.line model. type AccountBankStatementLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -64,7 +60,7 @@ func (c *Client) CreateAccountBankStatementLines(absls []*AccountBankStatementLi for _, v := range absls { vv = append(vv, v) } - return c.Create(AccountBankStatementLineModel, vv) + return c.Create(AccountBankStatementLineModel, vv, nil) } // UpdateAccountBankStatementLine updates an existing account.bank.statement.line record. @@ -75,7 +71,7 @@ func (c *Client) UpdateAccountBankStatementLine(absl *AccountBankStatementLine) // UpdateAccountBankStatementLines updates existing account.bank.statement.line records. // All records (represented by ids) will be updated by absl values. func (c *Client) UpdateAccountBankStatementLines(ids []int64, absl *AccountBankStatementLine) error { - return c.Update(AccountBankStatementLineModel, ids, absl) + return c.Update(AccountBankStatementLineModel, ids, absl, nil) } // DeleteAccountBankStatementLine deletes an existing account.bank.statement.line record. @@ -94,10 +90,7 @@ func (c *Client) GetAccountBankStatementLine(id int64) (*AccountBankStatementLin if err != nil { return nil, err } - if absls != nil && len(*absls) > 0 { - return &((*absls)[0]), nil - } - return nil, fmt.Errorf("id %v of account.bank.statement.line not found", id) + return &((*absls)[0]), nil } // GetAccountBankStatementLines gets account.bank.statement.line existing records. @@ -115,10 +108,7 @@ func (c *Client) FindAccountBankStatementLine(criteria *Criteria) (*AccountBankS if err := c.SearchRead(AccountBankStatementLineModel, criteria, NewOptions().Limit(1), absls); err != nil { return nil, err } - if absls != nil && len(*absls) > 0 { - return &((*absls)[0]), nil - } - return nil, fmt.Errorf("account.bank.statement.line was not found with criteria %v", criteria) + return &((*absls)[0]), nil } // FindAccountBankStatementLines finds account.bank.statement.line records by querying it @@ -134,11 +124,7 @@ func (c *Client) FindAccountBankStatementLines(criteria *Criteria, options *Opti // FindAccountBankStatementLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountBankStatementLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountBankStatementLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountBankStatementLineModel, criteria, options) } // FindAccountBankStatementLineId finds record id by querying it with criteria. @@ -147,8 +133,5 @@ func (c *Client) FindAccountBankStatementLineId(criteria *Criteria, options *Opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.bank.statement.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_cash_rounding.go b/account_cash_rounding.go index 1a5c5285..a39332d2 100644 --- a/account_cash_rounding.go +++ b/account_cash_rounding.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountCashRounding represents account.cash.rounding model. type AccountCashRounding struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateAccountCashRoundings(acrs []*AccountCashRounding) ([]int6 for _, v := range acrs { vv = append(vv, v) } - return c.Create(AccountCashRoundingModel, vv) + return c.Create(AccountCashRoundingModel, vv, nil) } // UpdateAccountCashRounding updates an existing account.cash.rounding record. @@ -60,7 +56,7 @@ func (c *Client) UpdateAccountCashRounding(acr *AccountCashRounding) error { // UpdateAccountCashRoundings updates existing account.cash.rounding records. // All records (represented by ids) will be updated by acr values. func (c *Client) UpdateAccountCashRoundings(ids []int64, acr *AccountCashRounding) error { - return c.Update(AccountCashRoundingModel, ids, acr) + return c.Update(AccountCashRoundingModel, ids, acr, nil) } // DeleteAccountCashRounding deletes an existing account.cash.rounding record. @@ -79,10 +75,7 @@ func (c *Client) GetAccountCashRounding(id int64) (*AccountCashRounding, error) if err != nil { return nil, err } - if acrs != nil && len(*acrs) > 0 { - return &((*acrs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.cash.rounding not found", id) + return &((*acrs)[0]), nil } // GetAccountCashRoundings gets account.cash.rounding existing records. @@ -100,10 +93,7 @@ func (c *Client) FindAccountCashRounding(criteria *Criteria) (*AccountCashRoundi if err := c.SearchRead(AccountCashRoundingModel, criteria, NewOptions().Limit(1), acrs); err != nil { return nil, err } - if acrs != nil && len(*acrs) > 0 { - return &((*acrs)[0]), nil - } - return nil, fmt.Errorf("account.cash.rounding was not found with criteria %v", criteria) + return &((*acrs)[0]), nil } // FindAccountCashRoundings finds account.cash.rounding records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindAccountCashRoundings(criteria *Criteria, options *Options) // FindAccountCashRoundingIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountCashRoundingIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountCashRoundingModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountCashRoundingModel, criteria, options) } // FindAccountCashRoundingId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindAccountCashRoundingId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.cash.rounding was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_cashbox_line.go b/account_cashbox_line.go index 6c9714cb..7295b31c 100644 --- a/account_cashbox_line.go +++ b/account_cashbox_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountCashboxLine represents account.cashbox.line model. type AccountCashboxLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateAccountCashboxLines(acls []*AccountCashboxLine) ([]int64, for _, v := range acls { vv = append(vv, v) } - return c.Create(AccountCashboxLineModel, vv) + return c.Create(AccountCashboxLineModel, vv, nil) } // UpdateAccountCashboxLine updates an existing account.cashbox.line record. @@ -59,7 +55,7 @@ func (c *Client) UpdateAccountCashboxLine(acl *AccountCashboxLine) error { // UpdateAccountCashboxLines updates existing account.cashbox.line records. // All records (represented by ids) will be updated by acl values. func (c *Client) UpdateAccountCashboxLines(ids []int64, acl *AccountCashboxLine) error { - return c.Update(AccountCashboxLineModel, ids, acl) + return c.Update(AccountCashboxLineModel, ids, acl, nil) } // DeleteAccountCashboxLine deletes an existing account.cashbox.line record. @@ -78,10 +74,7 @@ func (c *Client) GetAccountCashboxLine(id int64) (*AccountCashboxLine, error) { if err != nil { return nil, err } - if acls != nil && len(*acls) > 0 { - return &((*acls)[0]), nil - } - return nil, fmt.Errorf("id %v of account.cashbox.line not found", id) + return &((*acls)[0]), nil } // GetAccountCashboxLines gets account.cashbox.line existing records. @@ -99,10 +92,7 @@ func (c *Client) FindAccountCashboxLine(criteria *Criteria) (*AccountCashboxLine if err := c.SearchRead(AccountCashboxLineModel, criteria, NewOptions().Limit(1), acls); err != nil { return nil, err } - if acls != nil && len(*acls) > 0 { - return &((*acls)[0]), nil - } - return nil, fmt.Errorf("account.cashbox.line was not found with criteria %v", criteria) + return &((*acls)[0]), nil } // FindAccountCashboxLines finds account.cashbox.line records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindAccountCashboxLines(criteria *Criteria, options *Options) ( // FindAccountCashboxLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountCashboxLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountCashboxLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountCashboxLineModel, criteria, options) } // FindAccountCashboxLineId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindAccountCashboxLineId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.cashbox.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_chart_template.go b/account_chart_template.go index 3f2aa31e..e5adcdcb 100644 --- a/account_chart_template.go +++ b/account_chart_template.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountChartTemplate represents account.chart.template model. type AccountChartTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -68,7 +64,7 @@ func (c *Client) CreateAccountChartTemplates(acts []*AccountChartTemplate) ([]in for _, v := range acts { vv = append(vv, v) } - return c.Create(AccountChartTemplateModel, vv) + return c.Create(AccountChartTemplateModel, vv, nil) } // UpdateAccountChartTemplate updates an existing account.chart.template record. @@ -79,7 +75,7 @@ func (c *Client) UpdateAccountChartTemplate(act *AccountChartTemplate) error { // UpdateAccountChartTemplates updates existing account.chart.template records. // All records (represented by ids) will be updated by act values. func (c *Client) UpdateAccountChartTemplates(ids []int64, act *AccountChartTemplate) error { - return c.Update(AccountChartTemplateModel, ids, act) + return c.Update(AccountChartTemplateModel, ids, act, nil) } // DeleteAccountChartTemplate deletes an existing account.chart.template record. @@ -98,10 +94,7 @@ func (c *Client) GetAccountChartTemplate(id int64) (*AccountChartTemplate, error if err != nil { return nil, err } - if acts != nil && len(*acts) > 0 { - return &((*acts)[0]), nil - } - return nil, fmt.Errorf("id %v of account.chart.template not found", id) + return &((*acts)[0]), nil } // GetAccountChartTemplates gets account.chart.template existing records. @@ -119,10 +112,7 @@ func (c *Client) FindAccountChartTemplate(criteria *Criteria) (*AccountChartTemp if err := c.SearchRead(AccountChartTemplateModel, criteria, NewOptions().Limit(1), acts); err != nil { return nil, err } - if acts != nil && len(*acts) > 0 { - return &((*acts)[0]), nil - } - return nil, fmt.Errorf("account.chart.template was not found with criteria %v", criteria) + return &((*acts)[0]), nil } // FindAccountChartTemplates finds account.chart.template records by querying it @@ -138,11 +128,7 @@ func (c *Client) FindAccountChartTemplates(criteria *Criteria, options *Options) // FindAccountChartTemplateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountChartTemplateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountChartTemplateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountChartTemplateModel, criteria, options) } // FindAccountChartTemplateId finds record id by querying it with criteria. @@ -151,8 +137,5 @@ func (c *Client) FindAccountChartTemplateId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.chart.template was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_common_account_report.go b/account_common_account_report.go index 55c0465b..aca47154 100644 --- a/account_common_account_report.go +++ b/account_common_account_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountCommonAccountReport represents account.common.account.report model. type AccountCommonAccountReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateAccountCommonAccountReports(acars []*AccountCommonAccount for _, v := range acars { vv = append(vv, v) } - return c.Create(AccountCommonAccountReportModel, vv) + return c.Create(AccountCommonAccountReportModel, vv, nil) } // UpdateAccountCommonAccountReport updates an existing account.common.account.report record. @@ -61,7 +57,7 @@ func (c *Client) UpdateAccountCommonAccountReport(acar *AccountCommonAccountRepo // UpdateAccountCommonAccountReports updates existing account.common.account.report records. // All records (represented by ids) will be updated by acar values. func (c *Client) UpdateAccountCommonAccountReports(ids []int64, acar *AccountCommonAccountReport) error { - return c.Update(AccountCommonAccountReportModel, ids, acar) + return c.Update(AccountCommonAccountReportModel, ids, acar, nil) } // DeleteAccountCommonAccountReport deletes an existing account.common.account.report record. @@ -80,10 +76,7 @@ func (c *Client) GetAccountCommonAccountReport(id int64) (*AccountCommonAccountR if err != nil { return nil, err } - if acars != nil && len(*acars) > 0 { - return &((*acars)[0]), nil - } - return nil, fmt.Errorf("id %v of account.common.account.report not found", id) + return &((*acars)[0]), nil } // GetAccountCommonAccountReports gets account.common.account.report existing records. @@ -101,10 +94,7 @@ func (c *Client) FindAccountCommonAccountReport(criteria *Criteria) (*AccountCom if err := c.SearchRead(AccountCommonAccountReportModel, criteria, NewOptions().Limit(1), acars); err != nil { return nil, err } - if acars != nil && len(*acars) > 0 { - return &((*acars)[0]), nil - } - return nil, fmt.Errorf("account.common.account.report was not found with criteria %v", criteria) + return &((*acars)[0]), nil } // FindAccountCommonAccountReports finds account.common.account.report records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindAccountCommonAccountReports(criteria *Criteria, options *Op // FindAccountCommonAccountReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountCommonAccountReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountCommonAccountReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountCommonAccountReportModel, criteria, options) } // FindAccountCommonAccountReportId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindAccountCommonAccountReportId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.common.account.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_common_journal_report.go b/account_common_journal_report.go index a5ddcc72..52eb6c48 100644 --- a/account_common_journal_report.go +++ b/account_common_journal_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountCommonJournalReport represents account.common.journal.report model. type AccountCommonJournalReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateAccountCommonJournalReports(acjrs []*AccountCommonJournal for _, v := range acjrs { vv = append(vv, v) } - return c.Create(AccountCommonJournalReportModel, vv) + return c.Create(AccountCommonJournalReportModel, vv, nil) } // UpdateAccountCommonJournalReport updates an existing account.common.journal.report record. @@ -61,7 +57,7 @@ func (c *Client) UpdateAccountCommonJournalReport(acjr *AccountCommonJournalRepo // UpdateAccountCommonJournalReports updates existing account.common.journal.report records. // All records (represented by ids) will be updated by acjr values. func (c *Client) UpdateAccountCommonJournalReports(ids []int64, acjr *AccountCommonJournalReport) error { - return c.Update(AccountCommonJournalReportModel, ids, acjr) + return c.Update(AccountCommonJournalReportModel, ids, acjr, nil) } // DeleteAccountCommonJournalReport deletes an existing account.common.journal.report record. @@ -80,10 +76,7 @@ func (c *Client) GetAccountCommonJournalReport(id int64) (*AccountCommonJournalR if err != nil { return nil, err } - if acjrs != nil && len(*acjrs) > 0 { - return &((*acjrs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.common.journal.report not found", id) + return &((*acjrs)[0]), nil } // GetAccountCommonJournalReports gets account.common.journal.report existing records. @@ -101,10 +94,7 @@ func (c *Client) FindAccountCommonJournalReport(criteria *Criteria) (*AccountCom if err := c.SearchRead(AccountCommonJournalReportModel, criteria, NewOptions().Limit(1), acjrs); err != nil { return nil, err } - if acjrs != nil && len(*acjrs) > 0 { - return &((*acjrs)[0]), nil - } - return nil, fmt.Errorf("account.common.journal.report was not found with criteria %v", criteria) + return &((*acjrs)[0]), nil } // FindAccountCommonJournalReports finds account.common.journal.report records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindAccountCommonJournalReports(criteria *Criteria, options *Op // FindAccountCommonJournalReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountCommonJournalReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountCommonJournalReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountCommonJournalReportModel, criteria, options) } // FindAccountCommonJournalReportId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindAccountCommonJournalReportId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.common.journal.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_common_partner_report.go b/account_common_partner_report.go index a2fd77a7..db97e317 100644 --- a/account_common_partner_report.go +++ b/account_common_partner_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountCommonPartnerReport represents account.common.partner.report model. type AccountCommonPartnerReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateAccountCommonPartnerReports(acprs []*AccountCommonPartner for _, v := range acprs { vv = append(vv, v) } - return c.Create(AccountCommonPartnerReportModel, vv) + return c.Create(AccountCommonPartnerReportModel, vv, nil) } // UpdateAccountCommonPartnerReport updates an existing account.common.partner.report record. @@ -61,7 +57,7 @@ func (c *Client) UpdateAccountCommonPartnerReport(acpr *AccountCommonPartnerRepo // UpdateAccountCommonPartnerReports updates existing account.common.partner.report records. // All records (represented by ids) will be updated by acpr values. func (c *Client) UpdateAccountCommonPartnerReports(ids []int64, acpr *AccountCommonPartnerReport) error { - return c.Update(AccountCommonPartnerReportModel, ids, acpr) + return c.Update(AccountCommonPartnerReportModel, ids, acpr, nil) } // DeleteAccountCommonPartnerReport deletes an existing account.common.partner.report record. @@ -80,10 +76,7 @@ func (c *Client) GetAccountCommonPartnerReport(id int64) (*AccountCommonPartnerR if err != nil { return nil, err } - if acprs != nil && len(*acprs) > 0 { - return &((*acprs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.common.partner.report not found", id) + return &((*acprs)[0]), nil } // GetAccountCommonPartnerReports gets account.common.partner.report existing records. @@ -101,10 +94,7 @@ func (c *Client) FindAccountCommonPartnerReport(criteria *Criteria) (*AccountCom if err := c.SearchRead(AccountCommonPartnerReportModel, criteria, NewOptions().Limit(1), acprs); err != nil { return nil, err } - if acprs != nil && len(*acprs) > 0 { - return &((*acprs)[0]), nil - } - return nil, fmt.Errorf("account.common.partner.report was not found with criteria %v", criteria) + return &((*acprs)[0]), nil } // FindAccountCommonPartnerReports finds account.common.partner.report records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindAccountCommonPartnerReports(criteria *Criteria, options *Op // FindAccountCommonPartnerReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountCommonPartnerReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountCommonPartnerReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountCommonPartnerReportModel, criteria, options) } // FindAccountCommonPartnerReportId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindAccountCommonPartnerReportId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.common.partner.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_common_report.go b/account_common_report.go index 690f2773..3604c7d0 100644 --- a/account_common_report.go +++ b/account_common_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountCommonReport represents account.common.report model. type AccountCommonReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateAccountCommonReports(acrs []*AccountCommonReport) ([]int6 for _, v := range acrs { vv = append(vv, v) } - return c.Create(AccountCommonReportModel, vv) + return c.Create(AccountCommonReportModel, vv, nil) } // UpdateAccountCommonReport updates an existing account.common.report record. @@ -60,7 +56,7 @@ func (c *Client) UpdateAccountCommonReport(acr *AccountCommonReport) error { // UpdateAccountCommonReports updates existing account.common.report records. // All records (represented by ids) will be updated by acr values. func (c *Client) UpdateAccountCommonReports(ids []int64, acr *AccountCommonReport) error { - return c.Update(AccountCommonReportModel, ids, acr) + return c.Update(AccountCommonReportModel, ids, acr, nil) } // DeleteAccountCommonReport deletes an existing account.common.report record. @@ -79,10 +75,7 @@ func (c *Client) GetAccountCommonReport(id int64) (*AccountCommonReport, error) if err != nil { return nil, err } - if acrs != nil && len(*acrs) > 0 { - return &((*acrs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.common.report not found", id) + return &((*acrs)[0]), nil } // GetAccountCommonReports gets account.common.report existing records. @@ -100,10 +93,7 @@ func (c *Client) FindAccountCommonReport(criteria *Criteria) (*AccountCommonRepo if err := c.SearchRead(AccountCommonReportModel, criteria, NewOptions().Limit(1), acrs); err != nil { return nil, err } - if acrs != nil && len(*acrs) > 0 { - return &((*acrs)[0]), nil - } - return nil, fmt.Errorf("account.common.report was not found with criteria %v", criteria) + return &((*acrs)[0]), nil } // FindAccountCommonReports finds account.common.report records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindAccountCommonReports(criteria *Criteria, options *Options) // FindAccountCommonReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountCommonReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountCommonReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountCommonReportModel, criteria, options) } // FindAccountCommonReportId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindAccountCommonReportId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.common.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_financial_report.go b/account_financial_report.go index 6a916d87..117d3f02 100644 --- a/account_financial_report.go +++ b/account_financial_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountFinancialReport represents account.financial.report model. type AccountFinancialReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -56,7 +52,7 @@ func (c *Client) CreateAccountFinancialReports(afrs []*AccountFinancialReport) ( for _, v := range afrs { vv = append(vv, v) } - return c.Create(AccountFinancialReportModel, vv) + return c.Create(AccountFinancialReportModel, vv, nil) } // UpdateAccountFinancialReport updates an existing account.financial.report record. @@ -67,7 +63,7 @@ func (c *Client) UpdateAccountFinancialReport(afr *AccountFinancialReport) error // UpdateAccountFinancialReports updates existing account.financial.report records. // All records (represented by ids) will be updated by afr values. func (c *Client) UpdateAccountFinancialReports(ids []int64, afr *AccountFinancialReport) error { - return c.Update(AccountFinancialReportModel, ids, afr) + return c.Update(AccountFinancialReportModel, ids, afr, nil) } // DeleteAccountFinancialReport deletes an existing account.financial.report record. @@ -86,10 +82,7 @@ func (c *Client) GetAccountFinancialReport(id int64) (*AccountFinancialReport, e if err != nil { return nil, err } - if afrs != nil && len(*afrs) > 0 { - return &((*afrs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.financial.report not found", id) + return &((*afrs)[0]), nil } // GetAccountFinancialReports gets account.financial.report existing records. @@ -107,10 +100,7 @@ func (c *Client) FindAccountFinancialReport(criteria *Criteria) (*AccountFinanci if err := c.SearchRead(AccountFinancialReportModel, criteria, NewOptions().Limit(1), afrs); err != nil { return nil, err } - if afrs != nil && len(*afrs) > 0 { - return &((*afrs)[0]), nil - } - return nil, fmt.Errorf("account.financial.report was not found with criteria %v", criteria) + return &((*afrs)[0]), nil } // FindAccountFinancialReports finds account.financial.report records by querying it @@ -126,11 +116,7 @@ func (c *Client) FindAccountFinancialReports(criteria *Criteria, options *Option // FindAccountFinancialReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountFinancialReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountFinancialReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountFinancialReportModel, criteria, options) } // FindAccountFinancialReportId finds record id by querying it with criteria. @@ -139,8 +125,5 @@ func (c *Client) FindAccountFinancialReportId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.financial.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_financial_year_op.go b/account_financial_year_op.go index 463cd28b..d953ab2a 100644 --- a/account_financial_year_op.go +++ b/account_financial_year_op.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountFinancialYearOp represents account.financial.year.op model. type AccountFinancialYearOp struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateAccountFinancialYearOps(afyos []*AccountFinancialYearOp) for _, v := range afyos { vv = append(vv, v) } - return c.Create(AccountFinancialYearOpModel, vv) + return c.Create(AccountFinancialYearOpModel, vv, nil) } // UpdateAccountFinancialYearOp updates an existing account.financial.year.op record. @@ -61,7 +57,7 @@ func (c *Client) UpdateAccountFinancialYearOp(afyo *AccountFinancialYearOp) erro // 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) + return c.Update(AccountFinancialYearOpModel, ids, afyo, nil) } // DeleteAccountFinancialYearOp deletes an existing account.financial.year.op record. @@ -80,10 +76,7 @@ func (c *Client) GetAccountFinancialYearOp(id int64) (*AccountFinancialYearOp, e if err != nil { return nil, err } - if afyos != nil && len(*afyos) > 0 { - return &((*afyos)[0]), nil - } - return nil, fmt.Errorf("id %v of account.financial.year.op not found", id) + return &((*afyos)[0]), nil } // GetAccountFinancialYearOps gets account.financial.year.op existing records. @@ -101,10 +94,7 @@ func (c *Client) FindAccountFinancialYearOp(criteria *Criteria) (*AccountFinanci if err := c.SearchRead(AccountFinancialYearOpModel, criteria, NewOptions().Limit(1), afyos); err != nil { return nil, err } - if afyos != nil && len(*afyos) > 0 { - return &((*afyos)[0]), nil - } - return nil, fmt.Errorf("account.financial.year.op was not found with criteria %v", criteria) + return &((*afyos)[0]), nil } // FindAccountFinancialYearOps finds account.financial.year.op records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindAccountFinancialYearOps(criteria *Criteria, options *Option // FindAccountFinancialYearOpIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountFinancialYearOpIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountFinancialYearOpModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountFinancialYearOpModel, criteria, options) } // FindAccountFinancialYearOpId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindAccountFinancialYearOpId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.financial.year.op was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_fiscal_position.go b/account_fiscal_position.go index 93e0ae33..dc801c51 100644 --- a/account_fiscal_position.go +++ b/account_fiscal_position.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountFiscalPosition represents account.fiscal.position model. type AccountFiscalPosition struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -59,7 +55,7 @@ func (c *Client) CreateAccountFiscalPositions(afps []*AccountFiscalPosition) ([] for _, v := range afps { vv = append(vv, v) } - return c.Create(AccountFiscalPositionModel, vv) + return c.Create(AccountFiscalPositionModel, vv, nil) } // UpdateAccountFiscalPosition updates an existing account.fiscal.position record. @@ -70,7 +66,7 @@ func (c *Client) UpdateAccountFiscalPosition(afp *AccountFiscalPosition) error { // UpdateAccountFiscalPositions updates existing account.fiscal.position records. // All records (represented by ids) will be updated by afp values. func (c *Client) UpdateAccountFiscalPositions(ids []int64, afp *AccountFiscalPosition) error { - return c.Update(AccountFiscalPositionModel, ids, afp) + return c.Update(AccountFiscalPositionModel, ids, afp, nil) } // DeleteAccountFiscalPosition deletes an existing account.fiscal.position record. @@ -89,10 +85,7 @@ func (c *Client) GetAccountFiscalPosition(id int64) (*AccountFiscalPosition, err if err != nil { return nil, err } - if afps != nil && len(*afps) > 0 { - return &((*afps)[0]), nil - } - return nil, fmt.Errorf("id %v of account.fiscal.position not found", id) + return &((*afps)[0]), nil } // GetAccountFiscalPositions gets account.fiscal.position existing records. @@ -110,10 +103,7 @@ func (c *Client) FindAccountFiscalPosition(criteria *Criteria) (*AccountFiscalPo if err := c.SearchRead(AccountFiscalPositionModel, criteria, NewOptions().Limit(1), afps); err != nil { return nil, err } - if afps != nil && len(*afps) > 0 { - return &((*afps)[0]), nil - } - return nil, fmt.Errorf("account.fiscal.position was not found with criteria %v", criteria) + return &((*afps)[0]), nil } // FindAccountFiscalPositions finds account.fiscal.position records by querying it @@ -129,11 +119,7 @@ func (c *Client) FindAccountFiscalPositions(criteria *Criteria, options *Options // FindAccountFiscalPositionIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountFiscalPositionIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountFiscalPositionModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountFiscalPositionModel, criteria, options) } // FindAccountFiscalPositionId finds record id by querying it with criteria. @@ -142,8 +128,5 @@ func (c *Client) FindAccountFiscalPositionId(criteria *Criteria, options *Option if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.fiscal.position was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_fiscal_position_account.go b/account_fiscal_position_account.go index dd78d7db..32531312 100644 --- a/account_fiscal_position_account.go +++ b/account_fiscal_position_account.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountFiscalPositionAccount represents account.fiscal.position.account model. type AccountFiscalPositionAccount struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateAccountFiscalPositionAccounts(afpas []*AccountFiscalPosit for _, v := range afpas { vv = append(vv, v) } - return c.Create(AccountFiscalPositionAccountModel, vv) + return c.Create(AccountFiscalPositionAccountModel, vv, nil) } // UpdateAccountFiscalPositionAccount updates an existing account.fiscal.position.account record. @@ -58,7 +54,7 @@ func (c *Client) UpdateAccountFiscalPositionAccount(afpa *AccountFiscalPositionA // UpdateAccountFiscalPositionAccounts updates existing account.fiscal.position.account records. // All records (represented by ids) will be updated by afpa values. func (c *Client) UpdateAccountFiscalPositionAccounts(ids []int64, afpa *AccountFiscalPositionAccount) error { - return c.Update(AccountFiscalPositionAccountModel, ids, afpa) + return c.Update(AccountFiscalPositionAccountModel, ids, afpa, nil) } // DeleteAccountFiscalPositionAccount deletes an existing account.fiscal.position.account record. @@ -77,10 +73,7 @@ func (c *Client) GetAccountFiscalPositionAccount(id int64) (*AccountFiscalPositi if err != nil { return nil, err } - if afpas != nil && len(*afpas) > 0 { - return &((*afpas)[0]), nil - } - return nil, fmt.Errorf("id %v of account.fiscal.position.account not found", id) + return &((*afpas)[0]), nil } // GetAccountFiscalPositionAccounts gets account.fiscal.position.account existing records. @@ -98,10 +91,7 @@ func (c *Client) FindAccountFiscalPositionAccount(criteria *Criteria) (*AccountF if err := c.SearchRead(AccountFiscalPositionAccountModel, criteria, NewOptions().Limit(1), afpas); err != nil { return nil, err } - if afpas != nil && len(*afpas) > 0 { - return &((*afpas)[0]), nil - } - return nil, fmt.Errorf("account.fiscal.position.account was not found with criteria %v", criteria) + return &((*afpas)[0]), nil } // FindAccountFiscalPositionAccounts finds account.fiscal.position.account records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindAccountFiscalPositionAccounts(criteria *Criteria, options * // FindAccountFiscalPositionAccountIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountFiscalPositionAccountIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountFiscalPositionAccountModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountFiscalPositionAccountModel, criteria, options) } // FindAccountFiscalPositionAccountId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindAccountFiscalPositionAccountId(criteria *Criteria, options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.fiscal.position.account was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_fiscal_position_account_template.go b/account_fiscal_position_account_template.go index 3c1be850..5e07280d 100644 --- a/account_fiscal_position_account_template.go +++ b/account_fiscal_position_account_template.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountFiscalPositionAccountTemplate represents account.fiscal.position.account.template model. type AccountFiscalPositionAccountTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateAccountFiscalPositionAccountTemplates(afpats []*AccountFi for _, v := range afpats { vv = append(vv, v) } - return c.Create(AccountFiscalPositionAccountTemplateModel, vv) + return c.Create(AccountFiscalPositionAccountTemplateModel, vv, nil) } // UpdateAccountFiscalPositionAccountTemplate updates an existing account.fiscal.position.account.template record. @@ -58,7 +54,7 @@ func (c *Client) UpdateAccountFiscalPositionAccountTemplate(afpat *AccountFiscal // UpdateAccountFiscalPositionAccountTemplates updates existing account.fiscal.position.account.template records. // All records (represented by ids) will be updated by afpat values. func (c *Client) UpdateAccountFiscalPositionAccountTemplates(ids []int64, afpat *AccountFiscalPositionAccountTemplate) error { - return c.Update(AccountFiscalPositionAccountTemplateModel, ids, afpat) + return c.Update(AccountFiscalPositionAccountTemplateModel, ids, afpat, nil) } // DeleteAccountFiscalPositionAccountTemplate deletes an existing account.fiscal.position.account.template record. @@ -77,10 +73,7 @@ func (c *Client) GetAccountFiscalPositionAccountTemplate(id int64) (*AccountFisc if err != nil { return nil, err } - if afpats != nil && len(*afpats) > 0 { - return &((*afpats)[0]), nil - } - return nil, fmt.Errorf("id %v of account.fiscal.position.account.template not found", id) + return &((*afpats)[0]), nil } // GetAccountFiscalPositionAccountTemplates gets account.fiscal.position.account.template existing records. @@ -98,10 +91,7 @@ func (c *Client) FindAccountFiscalPositionAccountTemplate(criteria *Criteria) (* if err := c.SearchRead(AccountFiscalPositionAccountTemplateModel, criteria, NewOptions().Limit(1), afpats); err != nil { return nil, err } - if afpats != nil && len(*afpats) > 0 { - return &((*afpats)[0]), nil - } - return nil, fmt.Errorf("account.fiscal.position.account.template was not found with criteria %v", criteria) + return &((*afpats)[0]), nil } // FindAccountFiscalPositionAccountTemplates finds account.fiscal.position.account.template records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindAccountFiscalPositionAccountTemplates(criteria *Criteria, o // FindAccountFiscalPositionAccountTemplateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountFiscalPositionAccountTemplateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountFiscalPositionAccountTemplateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountFiscalPositionAccountTemplateModel, criteria, options) } // FindAccountFiscalPositionAccountTemplateId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindAccountFiscalPositionAccountTemplateId(criteria *Criteria, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.fiscal.position.account.template was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_fiscal_position_tax.go b/account_fiscal_position_tax.go index cae8d541..0da0b4bd 100644 --- a/account_fiscal_position_tax.go +++ b/account_fiscal_position_tax.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountFiscalPositionTax represents account.fiscal.position.tax model. type AccountFiscalPositionTax struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateAccountFiscalPositionTaxs(afpts []*AccountFiscalPositionT for _, v := range afpts { vv = append(vv, v) } - return c.Create(AccountFiscalPositionTaxModel, vv) + return c.Create(AccountFiscalPositionTaxModel, vv, nil) } // UpdateAccountFiscalPositionTax updates an existing account.fiscal.position.tax record. @@ -58,7 +54,7 @@ func (c *Client) UpdateAccountFiscalPositionTax(afpt *AccountFiscalPositionTax) // UpdateAccountFiscalPositionTaxs updates existing account.fiscal.position.tax records. // All records (represented by ids) will be updated by afpt values. func (c *Client) UpdateAccountFiscalPositionTaxs(ids []int64, afpt *AccountFiscalPositionTax) error { - return c.Update(AccountFiscalPositionTaxModel, ids, afpt) + return c.Update(AccountFiscalPositionTaxModel, ids, afpt, nil) } // DeleteAccountFiscalPositionTax deletes an existing account.fiscal.position.tax record. @@ -77,10 +73,7 @@ func (c *Client) GetAccountFiscalPositionTax(id int64) (*AccountFiscalPositionTa if err != nil { return nil, err } - if afpts != nil && len(*afpts) > 0 { - return &((*afpts)[0]), nil - } - return nil, fmt.Errorf("id %v of account.fiscal.position.tax not found", id) + return &((*afpts)[0]), nil } // GetAccountFiscalPositionTaxs gets account.fiscal.position.tax existing records. @@ -98,10 +91,7 @@ func (c *Client) FindAccountFiscalPositionTax(criteria *Criteria) (*AccountFisca if err := c.SearchRead(AccountFiscalPositionTaxModel, criteria, NewOptions().Limit(1), afpts); err != nil { return nil, err } - if afpts != nil && len(*afpts) > 0 { - return &((*afpts)[0]), nil - } - return nil, fmt.Errorf("account.fiscal.position.tax was not found with criteria %v", criteria) + return &((*afpts)[0]), nil } // FindAccountFiscalPositionTaxs finds account.fiscal.position.tax records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindAccountFiscalPositionTaxs(criteria *Criteria, options *Opti // FindAccountFiscalPositionTaxIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountFiscalPositionTaxIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountFiscalPositionTaxModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountFiscalPositionTaxModel, criteria, options) } // FindAccountFiscalPositionTaxId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindAccountFiscalPositionTaxId(criteria *Criteria, options *Opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.fiscal.position.tax was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_fiscal_position_tax_template.go b/account_fiscal_position_tax_template.go index eb67cdc4..7a325f30 100644 --- a/account_fiscal_position_tax_template.go +++ b/account_fiscal_position_tax_template.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountFiscalPositionTaxTemplate represents account.fiscal.position.tax.template model. type AccountFiscalPositionTaxTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateAccountFiscalPositionTaxTemplates(afptts []*AccountFiscal for _, v := range afptts { vv = append(vv, v) } - return c.Create(AccountFiscalPositionTaxTemplateModel, vv) + return c.Create(AccountFiscalPositionTaxTemplateModel, vv, nil) } // UpdateAccountFiscalPositionTaxTemplate updates an existing account.fiscal.position.tax.template record. @@ -58,7 +54,7 @@ func (c *Client) UpdateAccountFiscalPositionTaxTemplate(afptt *AccountFiscalPosi // UpdateAccountFiscalPositionTaxTemplates updates existing account.fiscal.position.tax.template records. // All records (represented by ids) will be updated by afptt values. func (c *Client) UpdateAccountFiscalPositionTaxTemplates(ids []int64, afptt *AccountFiscalPositionTaxTemplate) error { - return c.Update(AccountFiscalPositionTaxTemplateModel, ids, afptt) + return c.Update(AccountFiscalPositionTaxTemplateModel, ids, afptt, nil) } // DeleteAccountFiscalPositionTaxTemplate deletes an existing account.fiscal.position.tax.template record. @@ -77,10 +73,7 @@ func (c *Client) GetAccountFiscalPositionTaxTemplate(id int64) (*AccountFiscalPo if err != nil { return nil, err } - if afptts != nil && len(*afptts) > 0 { - return &((*afptts)[0]), nil - } - return nil, fmt.Errorf("id %v of account.fiscal.position.tax.template not found", id) + return &((*afptts)[0]), nil } // GetAccountFiscalPositionTaxTemplates gets account.fiscal.position.tax.template existing records. @@ -98,10 +91,7 @@ func (c *Client) FindAccountFiscalPositionTaxTemplate(criteria *Criteria) (*Acco if err := c.SearchRead(AccountFiscalPositionTaxTemplateModel, criteria, NewOptions().Limit(1), afptts); err != nil { return nil, err } - if afptts != nil && len(*afptts) > 0 { - return &((*afptts)[0]), nil - } - return nil, fmt.Errorf("account.fiscal.position.tax.template was not found with criteria %v", criteria) + return &((*afptts)[0]), nil } // FindAccountFiscalPositionTaxTemplates finds account.fiscal.position.tax.template records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindAccountFiscalPositionTaxTemplates(criteria *Criteria, optio // FindAccountFiscalPositionTaxTemplateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountFiscalPositionTaxTemplateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountFiscalPositionTaxTemplateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountFiscalPositionTaxTemplateModel, criteria, options) } // FindAccountFiscalPositionTaxTemplateId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindAccountFiscalPositionTaxTemplateId(criteria *Criteria, opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.fiscal.position.tax.template was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_fiscal_position_template.go b/account_fiscal_position_template.go index cab6780c..0fe0fce2 100644 --- a/account_fiscal_position_template.go +++ b/account_fiscal_position_template.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountFiscalPositionTemplate represents account.fiscal.position.template model. type AccountFiscalPositionTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -57,7 +53,7 @@ func (c *Client) CreateAccountFiscalPositionTemplates(afpts []*AccountFiscalPosi for _, v := range afpts { vv = append(vv, v) } - return c.Create(AccountFiscalPositionTemplateModel, vv) + return c.Create(AccountFiscalPositionTemplateModel, vv, nil) } // UpdateAccountFiscalPositionTemplate updates an existing account.fiscal.position.template record. @@ -68,7 +64,7 @@ func (c *Client) UpdateAccountFiscalPositionTemplate(afpt *AccountFiscalPosition // UpdateAccountFiscalPositionTemplates updates existing account.fiscal.position.template records. // All records (represented by ids) will be updated by afpt values. func (c *Client) UpdateAccountFiscalPositionTemplates(ids []int64, afpt *AccountFiscalPositionTemplate) error { - return c.Update(AccountFiscalPositionTemplateModel, ids, afpt) + return c.Update(AccountFiscalPositionTemplateModel, ids, afpt, nil) } // DeleteAccountFiscalPositionTemplate deletes an existing account.fiscal.position.template record. @@ -87,10 +83,7 @@ func (c *Client) GetAccountFiscalPositionTemplate(id int64) (*AccountFiscalPosit if err != nil { return nil, err } - if afpts != nil && len(*afpts) > 0 { - return &((*afpts)[0]), nil - } - return nil, fmt.Errorf("id %v of account.fiscal.position.template not found", id) + return &((*afpts)[0]), nil } // GetAccountFiscalPositionTemplates gets account.fiscal.position.template existing records. @@ -108,10 +101,7 @@ func (c *Client) FindAccountFiscalPositionTemplate(criteria *Criteria) (*Account if err := c.SearchRead(AccountFiscalPositionTemplateModel, criteria, NewOptions().Limit(1), afpts); err != nil { return nil, err } - if afpts != nil && len(*afpts) > 0 { - return &((*afpts)[0]), nil - } - return nil, fmt.Errorf("account.fiscal.position.template was not found with criteria %v", criteria) + return &((*afpts)[0]), nil } // FindAccountFiscalPositionTemplates finds account.fiscal.position.template records by querying it @@ -127,11 +117,7 @@ func (c *Client) FindAccountFiscalPositionTemplates(criteria *Criteria, options // FindAccountFiscalPositionTemplateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountFiscalPositionTemplateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountFiscalPositionTemplateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountFiscalPositionTemplateModel, criteria, options) } // FindAccountFiscalPositionTemplateId finds record id by querying it with criteria. @@ -140,8 +126,5 @@ func (c *Client) FindAccountFiscalPositionTemplateId(criteria *Criteria, options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.fiscal.position.template was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_fr_fec.go b/account_fr_fec.go index 5fe198c3..9d93286b 100644 --- a/account_fr_fec.go +++ b/account_fr_fec.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountFrFec represents account.fr.fec model. type AccountFrFec struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateAccountFrFecs(affs []*AccountFrFec) ([]int64, error) { for _, v := range affs { vv = append(vv, v) } - return c.Create(AccountFrFecModel, vv) + return c.Create(AccountFrFecModel, vv, nil) } // UpdateAccountFrFec updates an existing account.fr.fec record. @@ -60,7 +56,7 @@ func (c *Client) UpdateAccountFrFec(aff *AccountFrFec) error { // UpdateAccountFrFecs updates existing account.fr.fec records. // All records (represented by ids) will be updated by aff values. func (c *Client) UpdateAccountFrFecs(ids []int64, aff *AccountFrFec) error { - return c.Update(AccountFrFecModel, ids, aff) + return c.Update(AccountFrFecModel, ids, aff, nil) } // DeleteAccountFrFec deletes an existing account.fr.fec record. @@ -79,10 +75,7 @@ func (c *Client) GetAccountFrFec(id int64) (*AccountFrFec, error) { if err != nil { return nil, err } - if affs != nil && len(*affs) > 0 { - return &((*affs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.fr.fec not found", id) + return &((*affs)[0]), nil } // GetAccountFrFecs gets account.fr.fec existing records. @@ -100,10 +93,7 @@ func (c *Client) FindAccountFrFec(criteria *Criteria) (*AccountFrFec, error) { if err := c.SearchRead(AccountFrFecModel, criteria, NewOptions().Limit(1), affs); err != nil { return nil, err } - if affs != nil && len(*affs) > 0 { - return &((*affs)[0]), nil - } - return nil, fmt.Errorf("account.fr.fec was not found with criteria %v", criteria) + return &((*affs)[0]), nil } // FindAccountFrFecs finds account.fr.fec records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindAccountFrFecs(criteria *Criteria, options *Options) (*Accou // FindAccountFrFecIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountFrFecIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountFrFecModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountFrFecModel, criteria, options) } // FindAccountFrFecId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindAccountFrFecId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.fr.fec was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_full_reconcile.go b/account_full_reconcile.go index 9575518d..4f803f7d 100644 --- a/account_full_reconcile.go +++ b/account_full_reconcile.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountFullReconcile represents account.full.reconcile model. type AccountFullReconcile struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateAccountFullReconciles(afrs []*AccountFullReconcile) ([]in for _, v := range afrs { vv = append(vv, v) } - return c.Create(AccountFullReconcileModel, vv) + return c.Create(AccountFullReconcileModel, vv, nil) } // UpdateAccountFullReconcile updates an existing account.full.reconcile record. @@ -59,7 +55,7 @@ func (c *Client) UpdateAccountFullReconcile(afr *AccountFullReconcile) error { // UpdateAccountFullReconciles updates existing account.full.reconcile records. // All records (represented by ids) will be updated by afr values. func (c *Client) UpdateAccountFullReconciles(ids []int64, afr *AccountFullReconcile) error { - return c.Update(AccountFullReconcileModel, ids, afr) + return c.Update(AccountFullReconcileModel, ids, afr, nil) } // DeleteAccountFullReconcile deletes an existing account.full.reconcile record. @@ -78,10 +74,7 @@ func (c *Client) GetAccountFullReconcile(id int64) (*AccountFullReconcile, error if err != nil { return nil, err } - if afrs != nil && len(*afrs) > 0 { - return &((*afrs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.full.reconcile not found", id) + return &((*afrs)[0]), nil } // GetAccountFullReconciles gets account.full.reconcile existing records. @@ -99,10 +92,7 @@ func (c *Client) FindAccountFullReconcile(criteria *Criteria) (*AccountFullRecon if err := c.SearchRead(AccountFullReconcileModel, criteria, NewOptions().Limit(1), afrs); err != nil { return nil, err } - if afrs != nil && len(*afrs) > 0 { - return &((*afrs)[0]), nil - } - return nil, fmt.Errorf("account.full.reconcile was not found with criteria %v", criteria) + return &((*afrs)[0]), nil } // FindAccountFullReconciles finds account.full.reconcile records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindAccountFullReconciles(criteria *Criteria, options *Options) // FindAccountFullReconcileIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountFullReconcileIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountFullReconcileModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountFullReconcileModel, criteria, options) } // FindAccountFullReconcileId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindAccountFullReconcileId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.full.reconcile was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_group.go b/account_group.go index 85b4615e..5d82d8bf 100644 --- a/account_group.go +++ b/account_group.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountGroup represents account.group model. type AccountGroup struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateAccountGroups(ags []*AccountGroup) ([]int64, error) { for _, v := range ags { vv = append(vv, v) } - return c.Create(AccountGroupModel, vv) + return c.Create(AccountGroupModel, vv, nil) } // UpdateAccountGroup updates an existing account.group record. @@ -60,7 +56,7 @@ func (c *Client) UpdateAccountGroup(ag *AccountGroup) error { // UpdateAccountGroups updates existing account.group records. // All records (represented by ids) will be updated by ag values. func (c *Client) UpdateAccountGroups(ids []int64, ag *AccountGroup) error { - return c.Update(AccountGroupModel, ids, ag) + return c.Update(AccountGroupModel, ids, ag, nil) } // DeleteAccountGroup deletes an existing account.group record. @@ -79,10 +75,7 @@ func (c *Client) GetAccountGroup(id int64) (*AccountGroup, error) { if err != nil { return nil, err } - if ags != nil && len(*ags) > 0 { - return &((*ags)[0]), nil - } - return nil, fmt.Errorf("id %v of account.group not found", id) + return &((*ags)[0]), nil } // GetAccountGroups gets account.group existing records. @@ -100,10 +93,7 @@ func (c *Client) FindAccountGroup(criteria *Criteria) (*AccountGroup, error) { if err := c.SearchRead(AccountGroupModel, criteria, NewOptions().Limit(1), ags); err != nil { return nil, err } - if ags != nil && len(*ags) > 0 { - return &((*ags)[0]), nil - } - return nil, fmt.Errorf("account.group was not found with criteria %v", criteria) + return &((*ags)[0]), nil } // FindAccountGroups finds account.group records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindAccountGroups(criteria *Criteria, options *Options) (*Accou // FindAccountGroupIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountGroupIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountGroupModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountGroupModel, criteria, options) } // FindAccountGroupId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindAccountGroupId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.group was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_invoice.go b/account_invoice.go index 013a799e..b027f253 100644 --- a/account_invoice.go +++ b/account_invoice.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountInvoice represents account.invoice model. type AccountInvoice struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -123,7 +119,7 @@ func (c *Client) CreateAccountInvoices(ais []*AccountInvoice) ([]int64, error) { for _, v := range ais { vv = append(vv, v) } - return c.Create(AccountInvoiceModel, vv) + return c.Create(AccountInvoiceModel, vv, nil) } // UpdateAccountInvoice updates an existing account.invoice record. @@ -134,7 +130,7 @@ func (c *Client) UpdateAccountInvoice(ai *AccountInvoice) error { // UpdateAccountInvoices updates existing account.invoice records. // All records (represented by ids) will be updated by ai values. func (c *Client) UpdateAccountInvoices(ids []int64, ai *AccountInvoice) error { - return c.Update(AccountInvoiceModel, ids, ai) + return c.Update(AccountInvoiceModel, ids, ai, nil) } // DeleteAccountInvoice deletes an existing account.invoice record. @@ -153,10 +149,7 @@ func (c *Client) GetAccountInvoice(id int64) (*AccountInvoice, error) { if err != nil { return nil, err } - if ais != nil && len(*ais) > 0 { - return &((*ais)[0]), nil - } - return nil, fmt.Errorf("id %v of account.invoice not found", id) + return &((*ais)[0]), nil } // GetAccountInvoices gets account.invoice existing records. @@ -174,10 +167,7 @@ func (c *Client) FindAccountInvoice(criteria *Criteria) (*AccountInvoice, error) if err := c.SearchRead(AccountInvoiceModel, criteria, NewOptions().Limit(1), ais); err != nil { return nil, err } - if ais != nil && len(*ais) > 0 { - return &((*ais)[0]), nil - } - return nil, fmt.Errorf("account.invoice was not found with criteria %v", criteria) + return &((*ais)[0]), nil } // FindAccountInvoices finds account.invoice records by querying it @@ -193,11 +183,7 @@ func (c *Client) FindAccountInvoices(criteria *Criteria, options *Options) (*Acc // 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 + return c.Search(AccountInvoiceModel, criteria, options) } // FindAccountInvoiceId finds record id by querying it with criteria. @@ -206,8 +192,5 @@ func (c *Client) FindAccountInvoiceId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.invoice was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_invoice_confirm.go b/account_invoice_confirm.go index fbc09915..126fb572 100644 --- a/account_invoice_confirm.go +++ b/account_invoice_confirm.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountInvoiceConfirm represents account.invoice.confirm model. type AccountInvoiceConfirm struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -44,7 +40,7 @@ func (c *Client) CreateAccountInvoiceConfirms(aics []*AccountInvoiceConfirm) ([] for _, v := range aics { vv = append(vv, v) } - return c.Create(AccountInvoiceConfirmModel, vv) + return c.Create(AccountInvoiceConfirmModel, vv, nil) } // UpdateAccountInvoiceConfirm updates an existing account.invoice.confirm record. @@ -55,7 +51,7 @@ func (c *Client) UpdateAccountInvoiceConfirm(aic *AccountInvoiceConfirm) error { // UpdateAccountInvoiceConfirms updates existing account.invoice.confirm records. // All records (represented by ids) will be updated by aic values. func (c *Client) UpdateAccountInvoiceConfirms(ids []int64, aic *AccountInvoiceConfirm) error { - return c.Update(AccountInvoiceConfirmModel, ids, aic) + return c.Update(AccountInvoiceConfirmModel, ids, aic, nil) } // DeleteAccountInvoiceConfirm deletes an existing account.invoice.confirm record. @@ -74,10 +70,7 @@ func (c *Client) GetAccountInvoiceConfirm(id int64) (*AccountInvoiceConfirm, err if err != nil { return nil, err } - if aics != nil && len(*aics) > 0 { - return &((*aics)[0]), nil - } - return nil, fmt.Errorf("id %v of account.invoice.confirm not found", id) + return &((*aics)[0]), nil } // GetAccountInvoiceConfirms gets account.invoice.confirm existing records. @@ -95,10 +88,7 @@ func (c *Client) FindAccountInvoiceConfirm(criteria *Criteria) (*AccountInvoiceC if err := c.SearchRead(AccountInvoiceConfirmModel, criteria, NewOptions().Limit(1), aics); err != nil { return nil, err } - if aics != nil && len(*aics) > 0 { - return &((*aics)[0]), nil - } - return nil, fmt.Errorf("account.invoice.confirm was not found with criteria %v", criteria) + return &((*aics)[0]), nil } // FindAccountInvoiceConfirms finds account.invoice.confirm records by querying it @@ -114,11 +104,7 @@ func (c *Client) FindAccountInvoiceConfirms(criteria *Criteria, options *Options // FindAccountInvoiceConfirmIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountInvoiceConfirmIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountInvoiceConfirmModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountInvoiceConfirmModel, criteria, options) } // FindAccountInvoiceConfirmId finds record id by querying it with criteria. @@ -127,8 +113,5 @@ func (c *Client) FindAccountInvoiceConfirmId(criteria *Criteria, options *Option if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.invoice.confirm was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_invoice_line.go b/account_invoice_line.go index 72d95181..3f47c647 100644 --- a/account_invoice_line.go +++ b/account_invoice_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountInvoiceLine represents account.invoice.line model. type AccountInvoiceLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -72,7 +68,7 @@ func (c *Client) CreateAccountInvoiceLines(ails []*AccountInvoiceLine) ([]int64, for _, v := range ails { vv = append(vv, v) } - return c.Create(AccountInvoiceLineModel, vv) + return c.Create(AccountInvoiceLineModel, vv, nil) } // UpdateAccountInvoiceLine updates an existing account.invoice.line record. @@ -83,7 +79,7 @@ func (c *Client) UpdateAccountInvoiceLine(ail *AccountInvoiceLine) error { // UpdateAccountInvoiceLines updates existing account.invoice.line records. // All records (represented by ids) will be updated by ail values. func (c *Client) UpdateAccountInvoiceLines(ids []int64, ail *AccountInvoiceLine) error { - return c.Update(AccountInvoiceLineModel, ids, ail) + return c.Update(AccountInvoiceLineModel, ids, ail, nil) } // DeleteAccountInvoiceLine deletes an existing account.invoice.line record. @@ -102,10 +98,7 @@ func (c *Client) GetAccountInvoiceLine(id int64) (*AccountInvoiceLine, error) { if err != nil { return nil, err } - if ails != nil && len(*ails) > 0 { - return &((*ails)[0]), nil - } - return nil, fmt.Errorf("id %v of account.invoice.line not found", id) + return &((*ails)[0]), nil } // GetAccountInvoiceLines gets account.invoice.line existing records. @@ -123,10 +116,7 @@ func (c *Client) FindAccountInvoiceLine(criteria *Criteria) (*AccountInvoiceLine if err := c.SearchRead(AccountInvoiceLineModel, criteria, NewOptions().Limit(1), ails); err != nil { return nil, err } - if ails != nil && len(*ails) > 0 { - return &((*ails)[0]), nil - } - return nil, fmt.Errorf("account.invoice.line was not found with criteria %v", criteria) + return &((*ails)[0]), nil } // FindAccountInvoiceLines finds account.invoice.line records by querying it @@ -142,11 +132,7 @@ func (c *Client) FindAccountInvoiceLines(criteria *Criteria, options *Options) ( // 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 + return c.Search(AccountInvoiceLineModel, criteria, options) } // FindAccountInvoiceLineId finds record id by querying it with criteria. @@ -155,8 +141,5 @@ func (c *Client) FindAccountInvoiceLineId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.invoice.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_invoice_refund.go b/account_invoice_refund.go index 16ac8496..63b8c259 100644 --- a/account_invoice_refund.go +++ b/account_invoice_refund.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountInvoiceRefund represents account.invoice.refund model. type AccountInvoiceRefund struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateAccountInvoiceRefunds(airs []*AccountInvoiceRefund) ([]in for _, v := range airs { vv = append(vv, v) } - return c.Create(AccountInvoiceRefundModel, vv) + return c.Create(AccountInvoiceRefundModel, vv, nil) } // UpdateAccountInvoiceRefund updates an existing account.invoice.refund record. @@ -60,7 +56,7 @@ func (c *Client) UpdateAccountInvoiceRefund(air *AccountInvoiceRefund) error { // UpdateAccountInvoiceRefunds updates existing account.invoice.refund records. // All records (represented by ids) will be updated by air values. func (c *Client) UpdateAccountInvoiceRefunds(ids []int64, air *AccountInvoiceRefund) error { - return c.Update(AccountInvoiceRefundModel, ids, air) + return c.Update(AccountInvoiceRefundModel, ids, air, nil) } // DeleteAccountInvoiceRefund deletes an existing account.invoice.refund record. @@ -79,10 +75,7 @@ func (c *Client) GetAccountInvoiceRefund(id int64) (*AccountInvoiceRefund, error if err != nil { return nil, err } - if airs != nil && len(*airs) > 0 { - return &((*airs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.invoice.refund not found", id) + return &((*airs)[0]), nil } // GetAccountInvoiceRefunds gets account.invoice.refund existing records. @@ -100,10 +93,7 @@ func (c *Client) FindAccountInvoiceRefund(criteria *Criteria) (*AccountInvoiceRe if err := c.SearchRead(AccountInvoiceRefundModel, criteria, NewOptions().Limit(1), airs); err != nil { return nil, err } - if airs != nil && len(*airs) > 0 { - return &((*airs)[0]), nil - } - return nil, fmt.Errorf("account.invoice.refund was not found with criteria %v", criteria) + return &((*airs)[0]), nil } // FindAccountInvoiceRefunds finds account.invoice.refund records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindAccountInvoiceRefunds(criteria *Criteria, options *Options) // FindAccountInvoiceRefundIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountInvoiceRefundIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountInvoiceRefundModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountInvoiceRefundModel, criteria, options) } // FindAccountInvoiceRefundId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindAccountInvoiceRefundId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.invoice.refund was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_invoice_report.go b/account_invoice_report.go index b0f9cd39..78b0c24f 100644 --- a/account_invoice_report.go +++ b/account_invoice_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountInvoiceReport represents account.invoice.report model. type AccountInvoiceReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -70,7 +66,7 @@ func (c *Client) CreateAccountInvoiceReports(airs []*AccountInvoiceReport) ([]in for _, v := range airs { vv = append(vv, v) } - return c.Create(AccountInvoiceReportModel, vv) + return c.Create(AccountInvoiceReportModel, vv, nil) } // UpdateAccountInvoiceReport updates an existing account.invoice.report record. @@ -81,7 +77,7 @@ func (c *Client) UpdateAccountInvoiceReport(air *AccountInvoiceReport) error { // UpdateAccountInvoiceReports updates existing account.invoice.report records. // All records (represented by ids) will be updated by air values. func (c *Client) UpdateAccountInvoiceReports(ids []int64, air *AccountInvoiceReport) error { - return c.Update(AccountInvoiceReportModel, ids, air) + return c.Update(AccountInvoiceReportModel, ids, air, nil) } // DeleteAccountInvoiceReport deletes an existing account.invoice.report record. @@ -100,10 +96,7 @@ func (c *Client) GetAccountInvoiceReport(id int64) (*AccountInvoiceReport, error if err != nil { return nil, err } - if airs != nil && len(*airs) > 0 { - return &((*airs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.invoice.report not found", id) + return &((*airs)[0]), nil } // GetAccountInvoiceReports gets account.invoice.report existing records. @@ -121,10 +114,7 @@ func (c *Client) FindAccountInvoiceReport(criteria *Criteria) (*AccountInvoiceRe if err := c.SearchRead(AccountInvoiceReportModel, criteria, NewOptions().Limit(1), airs); err != nil { return nil, err } - if airs != nil && len(*airs) > 0 { - return &((*airs)[0]), nil - } - return nil, fmt.Errorf("account.invoice.report was not found with criteria %v", criteria) + return &((*airs)[0]), nil } // FindAccountInvoiceReports finds account.invoice.report records by querying it @@ -140,11 +130,7 @@ func (c *Client) FindAccountInvoiceReports(criteria *Criteria, options *Options) // FindAccountInvoiceReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountInvoiceReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountInvoiceReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountInvoiceReportModel, criteria, options) } // FindAccountInvoiceReportId finds record id by querying it with criteria. @@ -153,8 +139,5 @@ func (c *Client) FindAccountInvoiceReportId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.invoice.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_invoice_tax.go b/account_invoice_tax.go index aeca95bd..a770a60f 100644 --- a/account_invoice_tax.go +++ b/account_invoice_tax.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountInvoiceTax represents account.invoice.tax model. type AccountInvoiceTax struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -57,7 +53,7 @@ func (c *Client) CreateAccountInvoiceTaxs(aits []*AccountInvoiceTax) ([]int64, e for _, v := range aits { vv = append(vv, v) } - return c.Create(AccountInvoiceTaxModel, vv) + return c.Create(AccountInvoiceTaxModel, vv, nil) } // UpdateAccountInvoiceTax updates an existing account.invoice.tax record. @@ -68,7 +64,7 @@ func (c *Client) UpdateAccountInvoiceTax(ait *AccountInvoiceTax) error { // UpdateAccountInvoiceTaxs updates existing account.invoice.tax records. // All records (represented by ids) will be updated by ait values. func (c *Client) UpdateAccountInvoiceTaxs(ids []int64, ait *AccountInvoiceTax) error { - return c.Update(AccountInvoiceTaxModel, ids, ait) + return c.Update(AccountInvoiceTaxModel, ids, ait, nil) } // DeleteAccountInvoiceTax deletes an existing account.invoice.tax record. @@ -87,10 +83,7 @@ func (c *Client) GetAccountInvoiceTax(id int64) (*AccountInvoiceTax, error) { if err != nil { return nil, err } - if aits != nil && len(*aits) > 0 { - return &((*aits)[0]), nil - } - return nil, fmt.Errorf("id %v of account.invoice.tax not found", id) + return &((*aits)[0]), nil } // GetAccountInvoiceTaxs gets account.invoice.tax existing records. @@ -108,10 +101,7 @@ func (c *Client) FindAccountInvoiceTax(criteria *Criteria) (*AccountInvoiceTax, if err := c.SearchRead(AccountInvoiceTaxModel, criteria, NewOptions().Limit(1), aits); err != nil { return nil, err } - if aits != nil && len(*aits) > 0 { - return &((*aits)[0]), nil - } - return nil, fmt.Errorf("account.invoice.tax was not found with criteria %v", criteria) + return &((*aits)[0]), nil } // FindAccountInvoiceTaxs finds account.invoice.tax records by querying it @@ -127,11 +117,7 @@ func (c *Client) FindAccountInvoiceTaxs(criteria *Criteria, options *Options) (* // FindAccountInvoiceTaxIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountInvoiceTaxIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountInvoiceTaxModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountInvoiceTaxModel, criteria, options) } // FindAccountInvoiceTaxId finds record id by querying it with criteria. @@ -140,8 +126,5 @@ func (c *Client) FindAccountInvoiceTaxId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.invoice.tax was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_journal.go b/account_journal.go index 0843f462..e5f5bccb 100644 --- a/account_journal.go +++ b/account_journal.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountJournal represents account.journal model. type AccountJournal struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -78,7 +74,7 @@ func (c *Client) CreateAccountJournals(ajs []*AccountJournal) ([]int64, error) { for _, v := range ajs { vv = append(vv, v) } - return c.Create(AccountJournalModel, vv) + return c.Create(AccountJournalModel, vv, nil) } // UpdateAccountJournal updates an existing account.journal record. @@ -89,7 +85,7 @@ func (c *Client) UpdateAccountJournal(aj *AccountJournal) error { // UpdateAccountJournals updates existing account.journal records. // All records (represented by ids) will be updated by aj values. func (c *Client) UpdateAccountJournals(ids []int64, aj *AccountJournal) error { - return c.Update(AccountJournalModel, ids, aj) + return c.Update(AccountJournalModel, ids, aj, nil) } // DeleteAccountJournal deletes an existing account.journal record. @@ -108,10 +104,7 @@ func (c *Client) GetAccountJournal(id int64) (*AccountJournal, error) { if err != nil { return nil, err } - if ajs != nil && len(*ajs) > 0 { - return &((*ajs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.journal not found", id) + return &((*ajs)[0]), nil } // GetAccountJournals gets account.journal existing records. @@ -129,10 +122,7 @@ func (c *Client) FindAccountJournal(criteria *Criteria) (*AccountJournal, error) if err := c.SearchRead(AccountJournalModel, criteria, NewOptions().Limit(1), ajs); err != nil { return nil, err } - if ajs != nil && len(*ajs) > 0 { - return &((*ajs)[0]), nil - } - return nil, fmt.Errorf("account.journal was not found with criteria %v", criteria) + return &((*ajs)[0]), nil } // FindAccountJournals finds account.journal records by querying it @@ -148,11 +138,7 @@ func (c *Client) FindAccountJournals(criteria *Criteria, options *Options) (*Acc // FindAccountJournalIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountJournalIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountJournalModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountJournalModel, criteria, options) } // FindAccountJournalId finds record id by querying it with criteria. @@ -161,8 +147,5 @@ func (c *Client) FindAccountJournalId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.journal was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_move.go b/account_move.go index 964cb3c1..173a3f3f 100644 --- a/account_move.go +++ b/account_move.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountMove represents account.move model. type AccountMove struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -59,7 +55,7 @@ func (c *Client) CreateAccountMoves(ams []*AccountMove) ([]int64, error) { for _, v := range ams { vv = append(vv, v) } - return c.Create(AccountMoveModel, vv) + return c.Create(AccountMoveModel, vv, nil) } // UpdateAccountMove updates an existing account.move record. @@ -70,7 +66,7 @@ func (c *Client) UpdateAccountMove(am *AccountMove) error { // UpdateAccountMoves updates existing account.move records. // All records (represented by ids) will be updated by am values. func (c *Client) UpdateAccountMoves(ids []int64, am *AccountMove) error { - return c.Update(AccountMoveModel, ids, am) + return c.Update(AccountMoveModel, ids, am, nil) } // DeleteAccountMove deletes an existing account.move record. @@ -89,10 +85,7 @@ func (c *Client) GetAccountMove(id int64) (*AccountMove, error) { if err != nil { return nil, err } - if ams != nil && len(*ams) > 0 { - return &((*ams)[0]), nil - } - return nil, fmt.Errorf("id %v of account.move not found", id) + return &((*ams)[0]), nil } // GetAccountMoves gets account.move existing records. @@ -110,10 +103,7 @@ func (c *Client) FindAccountMove(criteria *Criteria) (*AccountMove, error) { if err := c.SearchRead(AccountMoveModel, criteria, NewOptions().Limit(1), ams); err != nil { return nil, err } - if ams != nil && len(*ams) > 0 { - return &((*ams)[0]), nil - } - return nil, fmt.Errorf("account.move was not found with criteria %v", criteria) + return &((*ams)[0]), nil } // FindAccountMoves finds account.move records by querying it @@ -129,11 +119,7 @@ func (c *Client) FindAccountMoves(criteria *Criteria, options *Options) (*Accoun // FindAccountMoveIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountMoveIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountMoveModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountMoveModel, criteria, options) } // FindAccountMoveId finds record id by querying it with criteria. @@ -142,8 +128,5 @@ func (c *Client) FindAccountMoveId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.move was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_move_line.go b/account_move_line.go index 5ee18d53..8f4991c1 100644 --- a/account_move_line.go +++ b/account_move_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountMoveLine represents account.move.line model. type AccountMoveLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -88,7 +84,7 @@ func (c *Client) CreateAccountMoveLines(amls []*AccountMoveLine) ([]int64, error for _, v := range amls { vv = append(vv, v) } - return c.Create(AccountMoveLineModel, vv) + return c.Create(AccountMoveLineModel, vv, nil) } // UpdateAccountMoveLine updates an existing account.move.line record. @@ -99,7 +95,7 @@ func (c *Client) UpdateAccountMoveLine(aml *AccountMoveLine) error { // UpdateAccountMoveLines updates existing account.move.line records. // All records (represented by ids) will be updated by aml values. func (c *Client) UpdateAccountMoveLines(ids []int64, aml *AccountMoveLine) error { - return c.Update(AccountMoveLineModel, ids, aml) + return c.Update(AccountMoveLineModel, ids, aml, nil) } // DeleteAccountMoveLine deletes an existing account.move.line record. @@ -118,10 +114,7 @@ func (c *Client) GetAccountMoveLine(id int64) (*AccountMoveLine, error) { if err != nil { return nil, err } - if amls != nil && len(*amls) > 0 { - return &((*amls)[0]), nil - } - return nil, fmt.Errorf("id %v of account.move.line not found", id) + return &((*amls)[0]), nil } // GetAccountMoveLines gets account.move.line existing records. @@ -139,10 +132,7 @@ func (c *Client) FindAccountMoveLine(criteria *Criteria) (*AccountMoveLine, erro if err := c.SearchRead(AccountMoveLineModel, criteria, NewOptions().Limit(1), amls); err != nil { return nil, err } - if amls != nil && len(*amls) > 0 { - return &((*amls)[0]), nil - } - return nil, fmt.Errorf("account.move.line was not found with criteria %v", criteria) + return &((*amls)[0]), nil } // FindAccountMoveLines finds account.move.line records by querying it @@ -158,11 +148,7 @@ func (c *Client) FindAccountMoveLines(criteria *Criteria, options *Options) (*Ac // FindAccountMoveLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountMoveLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountMoveLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountMoveLineModel, criteria, options) } // FindAccountMoveLineId finds record id by querying it with criteria. @@ -171,8 +157,5 @@ func (c *Client) FindAccountMoveLineId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.move.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_move_line_reconcile.go b/account_move_line_reconcile.go index 44379d3d..bc63300d 100644 --- a/account_move_line_reconcile.go +++ b/account_move_line_reconcile.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountMoveLineReconcile represents account.move.line.reconcile model. type AccountMoveLineReconcile struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateAccountMoveLineReconciles(amlrs []*AccountMoveLineReconci for _, v := range amlrs { vv = append(vv, v) } - return c.Create(AccountMoveLineReconcileModel, vv) + return c.Create(AccountMoveLineReconcileModel, vv, nil) } // UpdateAccountMoveLineReconcile updates an existing account.move.line.reconcile record. @@ -60,7 +56,7 @@ func (c *Client) UpdateAccountMoveLineReconcile(amlr *AccountMoveLineReconcile) // UpdateAccountMoveLineReconciles updates existing account.move.line.reconcile records. // All records (represented by ids) will be updated by amlr values. func (c *Client) UpdateAccountMoveLineReconciles(ids []int64, amlr *AccountMoveLineReconcile) error { - return c.Update(AccountMoveLineReconcileModel, ids, amlr) + return c.Update(AccountMoveLineReconcileModel, ids, amlr, nil) } // DeleteAccountMoveLineReconcile deletes an existing account.move.line.reconcile record. @@ -79,10 +75,7 @@ func (c *Client) GetAccountMoveLineReconcile(id int64) (*AccountMoveLineReconcil if err != nil { return nil, err } - if amlrs != nil && len(*amlrs) > 0 { - return &((*amlrs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.move.line.reconcile not found", id) + return &((*amlrs)[0]), nil } // GetAccountMoveLineReconciles gets account.move.line.reconcile existing records. @@ -100,10 +93,7 @@ func (c *Client) FindAccountMoveLineReconcile(criteria *Criteria) (*AccountMoveL if err := c.SearchRead(AccountMoveLineReconcileModel, criteria, NewOptions().Limit(1), amlrs); err != nil { return nil, err } - if amlrs != nil && len(*amlrs) > 0 { - return &((*amlrs)[0]), nil - } - return nil, fmt.Errorf("account.move.line.reconcile was not found with criteria %v", criteria) + return &((*amlrs)[0]), nil } // FindAccountMoveLineReconciles finds account.move.line.reconcile records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindAccountMoveLineReconciles(criteria *Criteria, options *Opti // FindAccountMoveLineReconcileIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountMoveLineReconcileIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountMoveLineReconcileModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountMoveLineReconcileModel, criteria, options) } // FindAccountMoveLineReconcileId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindAccountMoveLineReconcileId(criteria *Criteria, options *Opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.move.line.reconcile was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_move_line_reconcile_writeoff.go b/account_move_line_reconcile_writeoff.go index 7817424e..623b72a7 100644 --- a/account_move_line_reconcile_writeoff.go +++ b/account_move_line_reconcile_writeoff.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountMoveLineReconcileWriteoff represents account.move.line.reconcile.writeoff model. type AccountMoveLineReconcileWriteoff struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateAccountMoveLineReconcileWriteoffs(amlrws []*AccountMoveLi for _, v := range amlrws { vv = append(vv, v) } - return c.Create(AccountMoveLineReconcileWriteoffModel, vv) + return c.Create(AccountMoveLineReconcileWriteoffModel, vv, nil) } // UpdateAccountMoveLineReconcileWriteoff updates an existing account.move.line.reconcile.writeoff record. @@ -60,7 +56,7 @@ func (c *Client) UpdateAccountMoveLineReconcileWriteoff(amlrw *AccountMoveLineRe // UpdateAccountMoveLineReconcileWriteoffs updates existing account.move.line.reconcile.writeoff records. // All records (represented by ids) will be updated by amlrw values. func (c *Client) UpdateAccountMoveLineReconcileWriteoffs(ids []int64, amlrw *AccountMoveLineReconcileWriteoff) error { - return c.Update(AccountMoveLineReconcileWriteoffModel, ids, amlrw) + return c.Update(AccountMoveLineReconcileWriteoffModel, ids, amlrw, nil) } // DeleteAccountMoveLineReconcileWriteoff deletes an existing account.move.line.reconcile.writeoff record. @@ -79,10 +75,7 @@ func (c *Client) GetAccountMoveLineReconcileWriteoff(id int64) (*AccountMoveLine if err != nil { return nil, err } - if amlrws != nil && len(*amlrws) > 0 { - return &((*amlrws)[0]), nil - } - return nil, fmt.Errorf("id %v of account.move.line.reconcile.writeoff not found", id) + return &((*amlrws)[0]), nil } // GetAccountMoveLineReconcileWriteoffs gets account.move.line.reconcile.writeoff existing records. @@ -100,10 +93,7 @@ func (c *Client) FindAccountMoveLineReconcileWriteoff(criteria *Criteria) (*Acco if err := c.SearchRead(AccountMoveLineReconcileWriteoffModel, criteria, NewOptions().Limit(1), amlrws); err != nil { return nil, err } - if amlrws != nil && len(*amlrws) > 0 { - return &((*amlrws)[0]), nil - } - return nil, fmt.Errorf("account.move.line.reconcile.writeoff was not found with criteria %v", criteria) + return &((*amlrws)[0]), nil } // FindAccountMoveLineReconcileWriteoffs finds account.move.line.reconcile.writeoff records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindAccountMoveLineReconcileWriteoffs(criteria *Criteria, optio // FindAccountMoveLineReconcileWriteoffIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountMoveLineReconcileWriteoffIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountMoveLineReconcileWriteoffModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountMoveLineReconcileWriteoffModel, criteria, options) } // FindAccountMoveLineReconcileWriteoffId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindAccountMoveLineReconcileWriteoffId(criteria *Criteria, opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.move.line.reconcile.writeoff was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_move_reversal.go b/account_move_reversal.go index 245ad36d..c41dadae 100644 --- a/account_move_reversal.go +++ b/account_move_reversal.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountMoveReversal represents account.move.reversal model. type AccountMoveReversal struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateAccountMoveReversals(amrs []*AccountMoveReversal) ([]int6 for _, v := range amrs { vv = append(vv, v) } - return c.Create(AccountMoveReversalModel, vv) + return c.Create(AccountMoveReversalModel, vv, nil) } // UpdateAccountMoveReversal updates an existing account.move.reversal record. @@ -57,7 +53,7 @@ func (c *Client) UpdateAccountMoveReversal(amr *AccountMoveReversal) error { // UpdateAccountMoveReversals updates existing account.move.reversal records. // All records (represented by ids) will be updated by amr values. func (c *Client) UpdateAccountMoveReversals(ids []int64, amr *AccountMoveReversal) error { - return c.Update(AccountMoveReversalModel, ids, amr) + return c.Update(AccountMoveReversalModel, ids, amr, nil) } // DeleteAccountMoveReversal deletes an existing account.move.reversal record. @@ -76,10 +72,7 @@ func (c *Client) GetAccountMoveReversal(id int64) (*AccountMoveReversal, error) if err != nil { return nil, err } - if amrs != nil && len(*amrs) > 0 { - return &((*amrs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.move.reversal not found", id) + return &((*amrs)[0]), nil } // GetAccountMoveReversals gets account.move.reversal existing records. @@ -97,10 +90,7 @@ func (c *Client) FindAccountMoveReversal(criteria *Criteria) (*AccountMoveRevers if err := c.SearchRead(AccountMoveReversalModel, criteria, NewOptions().Limit(1), amrs); err != nil { return nil, err } - if amrs != nil && len(*amrs) > 0 { - return &((*amrs)[0]), nil - } - return nil, fmt.Errorf("account.move.reversal was not found with criteria %v", criteria) + return &((*amrs)[0]), nil } // FindAccountMoveReversals finds account.move.reversal records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindAccountMoveReversals(criteria *Criteria, options *Options) // FindAccountMoveReversalIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountMoveReversalIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountMoveReversalModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountMoveReversalModel, criteria, options) } // FindAccountMoveReversalId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindAccountMoveReversalId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.move.reversal was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_opening.go b/account_opening.go index 21c0ed13..b2087279 100644 --- a/account_opening.go +++ b/account_opening.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountOpening represents account.opening model. type AccountOpening struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateAccountOpenings(aos []*AccountOpening) ([]int64, error) { for _, v := range aos { vv = append(vv, v) } - return c.Create(AccountOpeningModel, vv) + return c.Create(AccountOpeningModel, vv, nil) } // UpdateAccountOpening updates an existing account.opening record. @@ -61,7 +57,7 @@ func (c *Client) UpdateAccountOpening(ao *AccountOpening) error { // UpdateAccountOpenings updates existing account.opening records. // All records (represented by ids) will be updated by ao values. func (c *Client) UpdateAccountOpenings(ids []int64, ao *AccountOpening) error { - return c.Update(AccountOpeningModel, ids, ao) + return c.Update(AccountOpeningModel, ids, ao, nil) } // DeleteAccountOpening deletes an existing account.opening record. @@ -80,10 +76,7 @@ func (c *Client) GetAccountOpening(id int64) (*AccountOpening, error) { if err != nil { return nil, err } - if aos != nil && len(*aos) > 0 { - return &((*aos)[0]), nil - } - return nil, fmt.Errorf("id %v of account.opening not found", id) + return &((*aos)[0]), nil } // GetAccountOpenings gets account.opening existing records. @@ -101,10 +94,7 @@ func (c *Client) FindAccountOpening(criteria *Criteria) (*AccountOpening, error) if err := c.SearchRead(AccountOpeningModel, criteria, NewOptions().Limit(1), aos); err != nil { return nil, err } - if aos != nil && len(*aos) > 0 { - return &((*aos)[0]), nil - } - return nil, fmt.Errorf("account.opening was not found with criteria %v", criteria) + return &((*aos)[0]), nil } // FindAccountOpenings finds account.opening records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindAccountOpenings(criteria *Criteria, options *Options) (*Acc // FindAccountOpeningIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountOpeningIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountOpeningModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountOpeningModel, criteria, options) } // FindAccountOpeningId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindAccountOpeningId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.opening was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_partial_reconcile.go b/account_partial_reconcile.go index 3d5aeb33..39d42df7 100644 --- a/account_partial_reconcile.go +++ b/account_partial_reconcile.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountPartialReconcile represents account.partial.reconcile model. type AccountPartialReconcile struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -53,7 +49,7 @@ func (c *Client) CreateAccountPartialReconciles(aprs []*AccountPartialReconcile) for _, v := range aprs { vv = append(vv, v) } - return c.Create(AccountPartialReconcileModel, vv) + return c.Create(AccountPartialReconcileModel, vv, nil) } // UpdateAccountPartialReconcile updates an existing account.partial.reconcile record. @@ -64,7 +60,7 @@ func (c *Client) UpdateAccountPartialReconcile(apr *AccountPartialReconcile) err // UpdateAccountPartialReconciles updates existing account.partial.reconcile records. // All records (represented by ids) will be updated by apr values. func (c *Client) UpdateAccountPartialReconciles(ids []int64, apr *AccountPartialReconcile) error { - return c.Update(AccountPartialReconcileModel, ids, apr) + return c.Update(AccountPartialReconcileModel, ids, apr, nil) } // DeleteAccountPartialReconcile deletes an existing account.partial.reconcile record. @@ -83,10 +79,7 @@ func (c *Client) GetAccountPartialReconcile(id int64) (*AccountPartialReconcile, if err != nil { return nil, err } - if aprs != nil && len(*aprs) > 0 { - return &((*aprs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.partial.reconcile not found", id) + return &((*aprs)[0]), nil } // GetAccountPartialReconciles gets account.partial.reconcile existing records. @@ -104,10 +97,7 @@ func (c *Client) FindAccountPartialReconcile(criteria *Criteria) (*AccountPartia if err := c.SearchRead(AccountPartialReconcileModel, criteria, NewOptions().Limit(1), aprs); err != nil { return nil, err } - if aprs != nil && len(*aprs) > 0 { - return &((*aprs)[0]), nil - } - return nil, fmt.Errorf("account.partial.reconcile was not found with criteria %v", criteria) + return &((*aprs)[0]), nil } // FindAccountPartialReconciles finds account.partial.reconcile records by querying it @@ -123,11 +113,7 @@ func (c *Client) FindAccountPartialReconciles(criteria *Criteria, options *Optio // FindAccountPartialReconcileIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountPartialReconcileIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountPartialReconcileModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountPartialReconcileModel, criteria, options) } // FindAccountPartialReconcileId finds record id by querying it with criteria. @@ -136,8 +122,5 @@ func (c *Client) FindAccountPartialReconcileId(criteria *Criteria, options *Opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.partial.reconcile was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_payment.go b/account_payment.go index ab25d52e..5f9aa594 100644 --- a/account_payment.go +++ b/account_payment.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountPayment represents account.payment model. type AccountPayment struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -83,7 +79,7 @@ func (c *Client) CreateAccountPayments(aps []*AccountPayment) ([]int64, error) { for _, v := range aps { vv = append(vv, v) } - return c.Create(AccountPaymentModel, vv) + return c.Create(AccountPaymentModel, vv, nil) } // UpdateAccountPayment updates an existing account.payment record. @@ -94,7 +90,7 @@ func (c *Client) UpdateAccountPayment(ap *AccountPayment) error { // UpdateAccountPayments updates existing account.payment records. // All records (represented by ids) will be updated by ap values. func (c *Client) UpdateAccountPayments(ids []int64, ap *AccountPayment) error { - return c.Update(AccountPaymentModel, ids, ap) + return c.Update(AccountPaymentModel, ids, ap, nil) } // DeleteAccountPayment deletes an existing account.payment record. @@ -113,10 +109,7 @@ func (c *Client) GetAccountPayment(id int64) (*AccountPayment, error) { if err != nil { return nil, err } - if aps != nil && len(*aps) > 0 { - return &((*aps)[0]), nil - } - return nil, fmt.Errorf("id %v of account.payment not found", id) + return &((*aps)[0]), nil } // GetAccountPayments gets account.payment existing records. @@ -134,10 +127,7 @@ func (c *Client) FindAccountPayment(criteria *Criteria) (*AccountPayment, error) if err := c.SearchRead(AccountPaymentModel, criteria, NewOptions().Limit(1), aps); err != nil { return nil, err } - if aps != nil && len(*aps) > 0 { - return &((*aps)[0]), nil - } - return nil, fmt.Errorf("account.payment was not found with criteria %v", criteria) + return &((*aps)[0]), nil } // FindAccountPayments finds account.payment records by querying it @@ -153,11 +143,7 @@ func (c *Client) FindAccountPayments(criteria *Criteria, options *Options) (*Acc // FindAccountPaymentIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountPaymentIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountPaymentModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountPaymentModel, criteria, options) } // FindAccountPaymentId finds record id by querying it with criteria. @@ -166,8 +152,5 @@ func (c *Client) FindAccountPaymentId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.payment was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_payment_method.go b/account_payment_method.go index 97bed6f6..8ddf2e44 100644 --- a/account_payment_method.go +++ b/account_payment_method.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountPaymentMethod represents account.payment.method model. type AccountPaymentMethod struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateAccountPaymentMethods(apms []*AccountPaymentMethod) ([]in for _, v := range apms { vv = append(vv, v) } - return c.Create(AccountPaymentMethodModel, vv) + return c.Create(AccountPaymentMethodModel, vv, nil) } // UpdateAccountPaymentMethod updates an existing account.payment.method record. @@ -58,7 +54,7 @@ func (c *Client) UpdateAccountPaymentMethod(apm *AccountPaymentMethod) error { // UpdateAccountPaymentMethods updates existing account.payment.method records. // All records (represented by ids) will be updated by apm values. func (c *Client) UpdateAccountPaymentMethods(ids []int64, apm *AccountPaymentMethod) error { - return c.Update(AccountPaymentMethodModel, ids, apm) + return c.Update(AccountPaymentMethodModel, ids, apm, nil) } // DeleteAccountPaymentMethod deletes an existing account.payment.method record. @@ -77,10 +73,7 @@ func (c *Client) GetAccountPaymentMethod(id int64) (*AccountPaymentMethod, error if err != nil { return nil, err } - if apms != nil && len(*apms) > 0 { - return &((*apms)[0]), nil - } - return nil, fmt.Errorf("id %v of account.payment.method not found", id) + return &((*apms)[0]), nil } // GetAccountPaymentMethods gets account.payment.method existing records. @@ -98,10 +91,7 @@ func (c *Client) FindAccountPaymentMethod(criteria *Criteria) (*AccountPaymentMe if err := c.SearchRead(AccountPaymentMethodModel, criteria, NewOptions().Limit(1), apms); err != nil { return nil, err } - if apms != nil && len(*apms) > 0 { - return &((*apms)[0]), nil - } - return nil, fmt.Errorf("account.payment.method was not found with criteria %v", criteria) + return &((*apms)[0]), nil } // FindAccountPaymentMethods finds account.payment.method records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindAccountPaymentMethods(criteria *Criteria, options *Options) // FindAccountPaymentMethodIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountPaymentMethodIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountPaymentMethodModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountPaymentMethodModel, criteria, options) } // FindAccountPaymentMethodId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindAccountPaymentMethodId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.payment.method was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_payment_term.go b/account_payment_term.go index 5c26e39e..c1d34c89 100644 --- a/account_payment_term.go +++ b/account_payment_term.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountPaymentTerm represents account.payment.term model. type AccountPaymentTerm struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateAccountPaymentTerms(apts []*AccountPaymentTerm) ([]int64, for _, v := range apts { vv = append(vv, v) } - return c.Create(AccountPaymentTermModel, vv) + return c.Create(AccountPaymentTermModel, vv, nil) } // UpdateAccountPaymentTerm updates an existing account.payment.term record. @@ -61,7 +57,7 @@ func (c *Client) UpdateAccountPaymentTerm(apt *AccountPaymentTerm) error { // UpdateAccountPaymentTerms updates existing account.payment.term records. // All records (represented by ids) will be updated by apt values. func (c *Client) UpdateAccountPaymentTerms(ids []int64, apt *AccountPaymentTerm) error { - return c.Update(AccountPaymentTermModel, ids, apt) + return c.Update(AccountPaymentTermModel, ids, apt, nil) } // DeleteAccountPaymentTerm deletes an existing account.payment.term record. @@ -80,10 +76,7 @@ func (c *Client) GetAccountPaymentTerm(id int64) (*AccountPaymentTerm, error) { if err != nil { return nil, err } - if apts != nil && len(*apts) > 0 { - return &((*apts)[0]), nil - } - return nil, fmt.Errorf("id %v of account.payment.term not found", id) + return &((*apts)[0]), nil } // GetAccountPaymentTerms gets account.payment.term existing records. @@ -101,10 +94,7 @@ func (c *Client) FindAccountPaymentTerm(criteria *Criteria) (*AccountPaymentTerm if err := c.SearchRead(AccountPaymentTermModel, criteria, NewOptions().Limit(1), apts); err != nil { return nil, err } - if apts != nil && len(*apts) > 0 { - return &((*apts)[0]), nil - } - return nil, fmt.Errorf("account.payment.term was not found with criteria %v", criteria) + return &((*apts)[0]), nil } // FindAccountPaymentTerms finds account.payment.term records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindAccountPaymentTerms(criteria *Criteria, options *Options) ( // FindAccountPaymentTermIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountPaymentTermIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountPaymentTermModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountPaymentTermModel, criteria, options) } // FindAccountPaymentTermId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindAccountPaymentTermId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.payment.term was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_payment_term_line.go b/account_payment_term_line.go index 48612aa5..42ed5fe6 100644 --- a/account_payment_term_line.go +++ b/account_payment_term_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountPaymentTermLine represents account.payment.term.line model. type AccountPaymentTermLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateAccountPaymentTermLines(aptls []*AccountPaymentTermLine) for _, v := range aptls { vv = append(vv, v) } - return c.Create(AccountPaymentTermLineModel, vv) + return c.Create(AccountPaymentTermLineModel, vv, nil) } // UpdateAccountPaymentTermLine updates an existing account.payment.term.line record. @@ -61,7 +57,7 @@ func (c *Client) UpdateAccountPaymentTermLine(aptl *AccountPaymentTermLine) erro // UpdateAccountPaymentTermLines updates existing account.payment.term.line records. // All records (represented by ids) will be updated by aptl values. func (c *Client) UpdateAccountPaymentTermLines(ids []int64, aptl *AccountPaymentTermLine) error { - return c.Update(AccountPaymentTermLineModel, ids, aptl) + return c.Update(AccountPaymentTermLineModel, ids, aptl, nil) } // DeleteAccountPaymentTermLine deletes an existing account.payment.term.line record. @@ -80,10 +76,7 @@ func (c *Client) GetAccountPaymentTermLine(id int64) (*AccountPaymentTermLine, e if err != nil { return nil, err } - if aptls != nil && len(*aptls) > 0 { - return &((*aptls)[0]), nil - } - return nil, fmt.Errorf("id %v of account.payment.term.line not found", id) + return &((*aptls)[0]), nil } // GetAccountPaymentTermLines gets account.payment.term.line existing records. @@ -101,10 +94,7 @@ func (c *Client) FindAccountPaymentTermLine(criteria *Criteria) (*AccountPayment if err := c.SearchRead(AccountPaymentTermLineModel, criteria, NewOptions().Limit(1), aptls); err != nil { return nil, err } - if aptls != nil && len(*aptls) > 0 { - return &((*aptls)[0]), nil - } - return nil, fmt.Errorf("account.payment.term.line was not found with criteria %v", criteria) + return &((*aptls)[0]), nil } // FindAccountPaymentTermLines finds account.payment.term.line records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindAccountPaymentTermLines(criteria *Criteria, options *Option // FindAccountPaymentTermLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountPaymentTermLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountPaymentTermLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountPaymentTermLineModel, criteria, options) } // FindAccountPaymentTermLineId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindAccountPaymentTermLineId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.payment.term.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_print_journal.go b/account_print_journal.go index e7890b39..7cac94fe 100644 --- a/account_print_journal.go +++ b/account_print_journal.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountPrintJournal represents account.print.journal model. type AccountPrintJournal struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -51,7 +47,7 @@ func (c *Client) CreateAccountPrintJournals(apjs []*AccountPrintJournal) ([]int6 for _, v := range apjs { vv = append(vv, v) } - return c.Create(AccountPrintJournalModel, vv) + return c.Create(AccountPrintJournalModel, vv, nil) } // UpdateAccountPrintJournal updates an existing account.print.journal record. @@ -62,7 +58,7 @@ func (c *Client) UpdateAccountPrintJournal(apj *AccountPrintJournal) error { // UpdateAccountPrintJournals updates existing account.print.journal records. // All records (represented by ids) will be updated by apj values. func (c *Client) UpdateAccountPrintJournals(ids []int64, apj *AccountPrintJournal) error { - return c.Update(AccountPrintJournalModel, ids, apj) + return c.Update(AccountPrintJournalModel, ids, apj, nil) } // DeleteAccountPrintJournal deletes an existing account.print.journal record. @@ -81,10 +77,7 @@ func (c *Client) GetAccountPrintJournal(id int64) (*AccountPrintJournal, error) if err != nil { return nil, err } - if apjs != nil && len(*apjs) > 0 { - return &((*apjs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.print.journal not found", id) + return &((*apjs)[0]), nil } // GetAccountPrintJournals gets account.print.journal existing records. @@ -102,10 +95,7 @@ func (c *Client) FindAccountPrintJournal(criteria *Criteria) (*AccountPrintJourn if err := c.SearchRead(AccountPrintJournalModel, criteria, NewOptions().Limit(1), apjs); err != nil { return nil, err } - if apjs != nil && len(*apjs) > 0 { - return &((*apjs)[0]), nil - } - return nil, fmt.Errorf("account.print.journal was not found with criteria %v", criteria) + return &((*apjs)[0]), nil } // FindAccountPrintJournals finds account.print.journal records by querying it @@ -121,11 +111,7 @@ func (c *Client) FindAccountPrintJournals(criteria *Criteria, options *Options) // FindAccountPrintJournalIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountPrintJournalIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountPrintJournalModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountPrintJournalModel, criteria, options) } // FindAccountPrintJournalId finds record id by querying it with criteria. @@ -134,8 +120,5 @@ func (c *Client) FindAccountPrintJournalId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.print.journal was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_reconcile_model.go b/account_reconcile_model.go index 2f3e6360..5c08527e 100644 --- a/account_reconcile_model.go +++ b/account_reconcile_model.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountReconcileModel represents account.reconcile.model model. type AccountReconcileModel struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -62,7 +58,7 @@ func (c *Client) CreateAccountReconcileModels(arms []*AccountReconcileModel) ([] for _, v := range arms { vv = append(vv, v) } - return c.Create(AccountReconcileModelModel, vv) + return c.Create(AccountReconcileModelModel, vv, nil) } // UpdateAccountReconcileModel updates an existing account.reconcile.model record. @@ -73,7 +69,7 @@ func (c *Client) UpdateAccountReconcileModel(arm *AccountReconcileModel) error { // UpdateAccountReconcileModels updates existing account.reconcile.model records. // All records (represented by ids) will be updated by arm values. func (c *Client) UpdateAccountReconcileModels(ids []int64, arm *AccountReconcileModel) error { - return c.Update(AccountReconcileModelModel, ids, arm) + return c.Update(AccountReconcileModelModel, ids, arm, nil) } // DeleteAccountReconcileModel deletes an existing account.reconcile.model record. @@ -92,10 +88,7 @@ func (c *Client) GetAccountReconcileModel(id int64) (*AccountReconcileModel, err if err != nil { return nil, err } - if arms != nil && len(*arms) > 0 { - return &((*arms)[0]), nil - } - return nil, fmt.Errorf("id %v of account.reconcile.model not found", id) + return &((*arms)[0]), nil } // GetAccountReconcileModels gets account.reconcile.model existing records. @@ -113,10 +106,7 @@ func (c *Client) FindAccountReconcileModel(criteria *Criteria) (*AccountReconcil if err := c.SearchRead(AccountReconcileModelModel, criteria, NewOptions().Limit(1), arms); err != nil { return nil, err } - if arms != nil && len(*arms) > 0 { - return &((*arms)[0]), nil - } - return nil, fmt.Errorf("account.reconcile.model was not found with criteria %v", criteria) + return &((*arms)[0]), nil } // FindAccountReconcileModels finds account.reconcile.model records by querying it @@ -132,11 +122,7 @@ func (c *Client) FindAccountReconcileModels(criteria *Criteria, options *Options // FindAccountReconcileModelIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountReconcileModelIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountReconcileModelModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountReconcileModelModel, criteria, options) } // FindAccountReconcileModelId finds record id by querying it with criteria. @@ -145,8 +131,5 @@ func (c *Client) FindAccountReconcileModelId(criteria *Criteria, options *Option if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.reconcile.model was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_reconcile_model_template.go b/account_reconcile_model_template.go index 8640b4b9..5a6f8c43 100644 --- a/account_reconcile_model_template.go +++ b/account_reconcile_model_template.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountReconcileModelTemplate represents account.reconcile.model.template model. type AccountReconcileModelTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -58,7 +54,7 @@ func (c *Client) CreateAccountReconcileModelTemplates(armts []*AccountReconcileM for _, v := range armts { vv = append(vv, v) } - return c.Create(AccountReconcileModelTemplateModel, vv) + return c.Create(AccountReconcileModelTemplateModel, vv, nil) } // UpdateAccountReconcileModelTemplate updates an existing account.reconcile.model.template record. @@ -69,7 +65,7 @@ func (c *Client) UpdateAccountReconcileModelTemplate(armt *AccountReconcileModel // UpdateAccountReconcileModelTemplates updates existing account.reconcile.model.template records. // All records (represented by ids) will be updated by armt values. func (c *Client) UpdateAccountReconcileModelTemplates(ids []int64, armt *AccountReconcileModelTemplate) error { - return c.Update(AccountReconcileModelTemplateModel, ids, armt) + return c.Update(AccountReconcileModelTemplateModel, ids, armt, nil) } // DeleteAccountReconcileModelTemplate deletes an existing account.reconcile.model.template record. @@ -88,10 +84,7 @@ func (c *Client) GetAccountReconcileModelTemplate(id int64) (*AccountReconcileMo if err != nil { return nil, err } - if armts != nil && len(*armts) > 0 { - return &((*armts)[0]), nil - } - return nil, fmt.Errorf("id %v of account.reconcile.model.template not found", id) + return &((*armts)[0]), nil } // GetAccountReconcileModelTemplates gets account.reconcile.model.template existing records. @@ -109,10 +102,7 @@ func (c *Client) FindAccountReconcileModelTemplate(criteria *Criteria) (*Account if err := c.SearchRead(AccountReconcileModelTemplateModel, criteria, NewOptions().Limit(1), armts); err != nil { return nil, err } - if armts != nil && len(*armts) > 0 { - return &((*armts)[0]), nil - } - return nil, fmt.Errorf("account.reconcile.model.template was not found with criteria %v", criteria) + return &((*armts)[0]), nil } // FindAccountReconcileModelTemplates finds account.reconcile.model.template records by querying it @@ -128,11 +118,7 @@ func (c *Client) FindAccountReconcileModelTemplates(criteria *Criteria, options // FindAccountReconcileModelTemplateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountReconcileModelTemplateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountReconcileModelTemplateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountReconcileModelTemplateModel, criteria, options) } // FindAccountReconcileModelTemplateId finds record id by querying it with criteria. @@ -141,8 +127,5 @@ func (c *Client) FindAccountReconcileModelTemplateId(criteria *Criteria, options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.reconcile.model.template was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_register_payments.go b/account_register_payments.go index 422c7bb2..3be2a61c 100644 --- a/account_register_payments.go +++ b/account_register_payments.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountRegisterPayments represents account.register.payments model. type AccountRegisterPayments struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -58,7 +54,7 @@ func (c *Client) CreateAccountRegisterPaymentss(arps []*AccountRegisterPayments) for _, v := range arps { vv = append(vv, v) } - return c.Create(AccountRegisterPaymentsModel, vv) + return c.Create(AccountRegisterPaymentsModel, vv, nil) } // UpdateAccountRegisterPayments updates an existing account.register.payments record. @@ -69,7 +65,7 @@ func (c *Client) UpdateAccountRegisterPayments(arp *AccountRegisterPayments) err // UpdateAccountRegisterPaymentss updates existing account.register.payments records. // All records (represented by ids) will be updated by arp values. func (c *Client) UpdateAccountRegisterPaymentss(ids []int64, arp *AccountRegisterPayments) error { - return c.Update(AccountRegisterPaymentsModel, ids, arp) + return c.Update(AccountRegisterPaymentsModel, ids, arp, nil) } // DeleteAccountRegisterPayments deletes an existing account.register.payments record. @@ -88,10 +84,7 @@ func (c *Client) GetAccountRegisterPayments(id int64) (*AccountRegisterPayments, if err != nil { return nil, err } - if arps != nil && len(*arps) > 0 { - return &((*arps)[0]), nil - } - return nil, fmt.Errorf("id %v of account.register.payments not found", id) + return &((*arps)[0]), nil } // GetAccountRegisterPaymentss gets account.register.payments existing records. @@ -109,10 +102,7 @@ func (c *Client) FindAccountRegisterPayments(criteria *Criteria) (*AccountRegist if err := c.SearchRead(AccountRegisterPaymentsModel, criteria, NewOptions().Limit(1), arps); err != nil { return nil, err } - if arps != nil && len(*arps) > 0 { - return &((*arps)[0]), nil - } - return nil, fmt.Errorf("account.register.payments was not found with criteria %v", criteria) + return &((*arps)[0]), nil } // FindAccountRegisterPaymentss finds account.register.payments records by querying it @@ -128,11 +118,7 @@ func (c *Client) FindAccountRegisterPaymentss(criteria *Criteria, options *Optio // FindAccountRegisterPaymentsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountRegisterPaymentsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountRegisterPaymentsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountRegisterPaymentsModel, criteria, options) } // FindAccountRegisterPaymentsId finds record id by querying it with criteria. @@ -141,8 +127,5 @@ func (c *Client) FindAccountRegisterPaymentsId(criteria *Criteria, options *Opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.register.payments was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_report_general_ledger.go b/account_report_general_ledger.go index c4dcb42c..025efa59 100644 --- a/account_report_general_ledger.go +++ b/account_report_general_ledger.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountReportGeneralLedger represents account.report.general.ledger model. type AccountReportGeneralLedger struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -52,7 +48,7 @@ func (c *Client) CreateAccountReportGeneralLedgers(argls []*AccountReportGeneral for _, v := range argls { vv = append(vv, v) } - return c.Create(AccountReportGeneralLedgerModel, vv) + return c.Create(AccountReportGeneralLedgerModel, vv, nil) } // UpdateAccountReportGeneralLedger updates an existing account.report.general.ledger record. @@ -63,7 +59,7 @@ func (c *Client) UpdateAccountReportGeneralLedger(argl *AccountReportGeneralLedg // UpdateAccountReportGeneralLedgers updates existing account.report.general.ledger records. // All records (represented by ids) will be updated by argl values. func (c *Client) UpdateAccountReportGeneralLedgers(ids []int64, argl *AccountReportGeneralLedger) error { - return c.Update(AccountReportGeneralLedgerModel, ids, argl) + return c.Update(AccountReportGeneralLedgerModel, ids, argl, nil) } // DeleteAccountReportGeneralLedger deletes an existing account.report.general.ledger record. @@ -82,10 +78,7 @@ func (c *Client) GetAccountReportGeneralLedger(id int64) (*AccountReportGeneralL if err != nil { return nil, err } - if argls != nil && len(*argls) > 0 { - return &((*argls)[0]), nil - } - return nil, fmt.Errorf("id %v of account.report.general.ledger not found", id) + return &((*argls)[0]), nil } // GetAccountReportGeneralLedgers gets account.report.general.ledger existing records. @@ -103,10 +96,7 @@ func (c *Client) FindAccountReportGeneralLedger(criteria *Criteria) (*AccountRep if err := c.SearchRead(AccountReportGeneralLedgerModel, criteria, NewOptions().Limit(1), argls); err != nil { return nil, err } - if argls != nil && len(*argls) > 0 { - return &((*argls)[0]), nil - } - return nil, fmt.Errorf("account.report.general.ledger was not found with criteria %v", criteria) + return &((*argls)[0]), nil } // FindAccountReportGeneralLedgers finds account.report.general.ledger records by querying it @@ -122,11 +112,7 @@ func (c *Client) FindAccountReportGeneralLedgers(criteria *Criteria, options *Op // FindAccountReportGeneralLedgerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountReportGeneralLedgerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountReportGeneralLedgerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountReportGeneralLedgerModel, criteria, options) } // FindAccountReportGeneralLedgerId finds record id by querying it with criteria. @@ -135,8 +121,5 @@ func (c *Client) FindAccountReportGeneralLedgerId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.report.general.ledger was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_report_partner_ledger.go b/account_report_partner_ledger.go index d8e70b41..2a7c66fb 100644 --- a/account_report_partner_ledger.go +++ b/account_report_partner_ledger.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountReportPartnerLedger represents account.report.partner.ledger model. type AccountReportPartnerLedger struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -52,7 +48,7 @@ func (c *Client) CreateAccountReportPartnerLedgers(arpls []*AccountReportPartner for _, v := range arpls { vv = append(vv, v) } - return c.Create(AccountReportPartnerLedgerModel, vv) + return c.Create(AccountReportPartnerLedgerModel, vv, nil) } // UpdateAccountReportPartnerLedger updates an existing account.report.partner.ledger record. @@ -63,7 +59,7 @@ func (c *Client) UpdateAccountReportPartnerLedger(arpl *AccountReportPartnerLedg // UpdateAccountReportPartnerLedgers updates existing account.report.partner.ledger records. // All records (represented by ids) will be updated by arpl values. func (c *Client) UpdateAccountReportPartnerLedgers(ids []int64, arpl *AccountReportPartnerLedger) error { - return c.Update(AccountReportPartnerLedgerModel, ids, arpl) + return c.Update(AccountReportPartnerLedgerModel, ids, arpl, nil) } // DeleteAccountReportPartnerLedger deletes an existing account.report.partner.ledger record. @@ -82,10 +78,7 @@ func (c *Client) GetAccountReportPartnerLedger(id int64) (*AccountReportPartnerL if err != nil { return nil, err } - if arpls != nil && len(*arpls) > 0 { - return &((*arpls)[0]), nil - } - return nil, fmt.Errorf("id %v of account.report.partner.ledger not found", id) + return &((*arpls)[0]), nil } // GetAccountReportPartnerLedgers gets account.report.partner.ledger existing records. @@ -103,10 +96,7 @@ func (c *Client) FindAccountReportPartnerLedger(criteria *Criteria) (*AccountRep if err := c.SearchRead(AccountReportPartnerLedgerModel, criteria, NewOptions().Limit(1), arpls); err != nil { return nil, err } - if arpls != nil && len(*arpls) > 0 { - return &((*arpls)[0]), nil - } - return nil, fmt.Errorf("account.report.partner.ledger was not found with criteria %v", criteria) + return &((*arpls)[0]), nil } // FindAccountReportPartnerLedgers finds account.report.partner.ledger records by querying it @@ -122,11 +112,7 @@ func (c *Client) FindAccountReportPartnerLedgers(criteria *Criteria, options *Op // FindAccountReportPartnerLedgerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountReportPartnerLedgerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountReportPartnerLedgerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountReportPartnerLedgerModel, criteria, options) } // FindAccountReportPartnerLedgerId finds record id by querying it with criteria. @@ -135,8 +121,5 @@ func (c *Client) FindAccountReportPartnerLedgerId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.report.partner.ledger was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_tax.go b/account_tax.go index 171c0874..6b4ea497 100644 --- a/account_tax.go +++ b/account_tax.go @@ -1,39 +1,34 @@ package odoo -import ( - "fmt" -) - // AccountTax represents account.tax model. type AccountTax struct { - LastUpdate *Time `xmlrpc:"__last_update,omptempty"` - AccountId *Many2One `xmlrpc:"account_id,omptempty"` - Active *Bool `xmlrpc:"active,omptempty"` - Amount *Float `xmlrpc:"amount,omptempty"` - AmountType *Selection `xmlrpc:"amount_type,omptempty"` - Analytic *Bool `xmlrpc:"analytic,omptempty"` - CashBasisAccount *Many2One `xmlrpc:"cash_basis_account,omptempty"` - CashBasisBaseAccountId *Many2One `xmlrpc:"cash_basis_base_account_id,omptempty"` - ChildrenTaxIds *Relation `xmlrpc:"children_tax_ids,omptempty"` - CompanyId *Many2One `xmlrpc:"company_id,omptempty"` - CreateDate *Time `xmlrpc:"create_date,omptempty"` - CreateUid *Many2One `xmlrpc:"create_uid,omptempty"` - Description *String `xmlrpc:"description,omptempty"` - DisplayName *String `xmlrpc:"display_name,omptempty"` - HideTaxExigibility *Bool `xmlrpc:"hide_tax_exigibility,omptempty"` - Id *Int `xmlrpc:"id,omptempty"` - IncludeBaseAmount *Bool `xmlrpc:"include_base_amount,omptempty"` - Name *String `xmlrpc:"name,omptempty"` - PriceInclude *Bool `xmlrpc:"price_include,omptempty"` - RefundAccountId *Many2One `xmlrpc:"refund_account_id,omptempty"` - Sequence *Int `xmlrpc:"sequence,omptempty"` - TagIds *Relation `xmlrpc:"tag_ids,omptempty"` - TaxAdjustment *Bool `xmlrpc:"tax_adjustment,omptempty"` - TaxExigibility *Selection `xmlrpc:"tax_exigibility,omptempty"` - TaxGroupId *Many2One `xmlrpc:"tax_group_id,omptempty"` - TypeTaxUse *Selection `xmlrpc:"type_tax_use,omptempty"` - WriteDate *Time `xmlrpc:"write_date,omptempty"` - WriteUid *Many2One `xmlrpc:"write_uid,omptempty"` + LastUpdate *Time `xmlrpc:"__last_update,omptempty"` + AccountId *Many2One `xmlrpc:"account_id,omptempty"` + Active *Bool `xmlrpc:"active,omptempty"` + Amount *Float `xmlrpc:"amount,omptempty"` + AmountType *Selection `xmlrpc:"amount_type,omptempty"` + Analytic *Bool `xmlrpc:"analytic,omptempty"` + CashBasisAccount *Many2One `xmlrpc:"cash_basis_account,omptempty"` + ChildrenTaxIds *Relation `xmlrpc:"children_tax_ids,omptempty"` + CompanyId *Many2One `xmlrpc:"company_id,omptempty"` + CreateDate *Time `xmlrpc:"create_date,omptempty"` + CreateUid *Many2One `xmlrpc:"create_uid,omptempty"` + Description *String `xmlrpc:"description,omptempty"` + DisplayName *String `xmlrpc:"display_name,omptempty"` + HideTaxExigibility *Bool `xmlrpc:"hide_tax_exigibility,omptempty"` + Id *Int `xmlrpc:"id,omptempty"` + IncludeBaseAmount *Bool `xmlrpc:"include_base_amount,omptempty"` + Name *String `xmlrpc:"name,omptempty"` + PriceInclude *Bool `xmlrpc:"price_include,omptempty"` + RefundAccountId *Many2One `xmlrpc:"refund_account_id,omptempty"` + Sequence *Int `xmlrpc:"sequence,omptempty"` + TagIds *Relation `xmlrpc:"tag_ids,omptempty"` + TaxAdjustment *Bool `xmlrpc:"tax_adjustment,omptempty"` + TaxExigibility *Selection `xmlrpc:"tax_exigibility,omptempty"` + TaxGroupId *Many2One `xmlrpc:"tax_group_id,omptempty"` + TypeTaxUse *Selection `xmlrpc:"type_tax_use,omptempty"` + WriteDate *Time `xmlrpc:"write_date,omptempty"` + WriteUid *Many2One `xmlrpc:"write_uid,omptempty"` } // AccountTaxs represents array of account.tax model. @@ -65,7 +60,7 @@ func (c *Client) CreateAccountTaxs(ats []*AccountTax) ([]int64, error) { for _, v := range ats { vv = append(vv, v) } - return c.Create(AccountTaxModel, vv) + return c.Create(AccountTaxModel, vv, nil) } // UpdateAccountTax updates an existing account.tax record. @@ -76,7 +71,7 @@ func (c *Client) UpdateAccountTax(at *AccountTax) error { // UpdateAccountTaxs updates existing account.tax records. // All records (represented by ids) will be updated by at values. func (c *Client) UpdateAccountTaxs(ids []int64, at *AccountTax) error { - return c.Update(AccountTaxModel, ids, at) + return c.Update(AccountTaxModel, ids, at, nil) } // DeleteAccountTax deletes an existing account.tax record. @@ -95,10 +90,7 @@ func (c *Client) GetAccountTax(id int64) (*AccountTax, error) { if err != nil { return nil, err } - if ats != nil && len(*ats) > 0 { - return &((*ats)[0]), nil - } - return nil, fmt.Errorf("id %v of account.tax not found", id) + return &((*ats)[0]), nil } // GetAccountTaxs gets account.tax existing records. @@ -116,10 +108,7 @@ func (c *Client) FindAccountTax(criteria *Criteria) (*AccountTax, error) { if err := c.SearchRead(AccountTaxModel, criteria, NewOptions().Limit(1), ats); err != nil { return nil, err } - if ats != nil && len(*ats) > 0 { - return &((*ats)[0]), nil - } - return nil, fmt.Errorf("account.tax was not found with criteria %v", criteria) + return &((*ats)[0]), nil } // FindAccountTaxs finds account.tax records by querying it @@ -135,11 +124,7 @@ func (c *Client) FindAccountTaxs(criteria *Criteria, options *Options) (*Account // FindAccountTaxIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountTaxIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountTaxModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountTaxModel, criteria, options) } // FindAccountTaxId finds record id by querying it with criteria. @@ -148,8 +133,5 @@ func (c *Client) FindAccountTaxId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.tax was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_tax_group.go b/account_tax_group.go index 4f171248..deea6b3e 100644 --- a/account_tax_group.go +++ b/account_tax_group.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountTaxGroup represents account.tax.group model. type AccountTaxGroup struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateAccountTaxGroups(atgs []*AccountTaxGroup) ([]int64, error for _, v := range atgs { vv = append(vv, v) } - return c.Create(AccountTaxGroupModel, vv) + return c.Create(AccountTaxGroupModel, vv, nil) } // UpdateAccountTaxGroup updates an existing account.tax.group record. @@ -57,7 +53,7 @@ func (c *Client) UpdateAccountTaxGroup(atg *AccountTaxGroup) error { // UpdateAccountTaxGroups updates existing account.tax.group records. // All records (represented by ids) will be updated by atg values. func (c *Client) UpdateAccountTaxGroups(ids []int64, atg *AccountTaxGroup) error { - return c.Update(AccountTaxGroupModel, ids, atg) + return c.Update(AccountTaxGroupModel, ids, atg, nil) } // DeleteAccountTaxGroup deletes an existing account.tax.group record. @@ -76,10 +72,7 @@ func (c *Client) GetAccountTaxGroup(id int64) (*AccountTaxGroup, error) { if err != nil { return nil, err } - if atgs != nil && len(*atgs) > 0 { - return &((*atgs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.tax.group not found", id) + return &((*atgs)[0]), nil } // GetAccountTaxGroups gets account.tax.group existing records. @@ -97,10 +90,7 @@ func (c *Client) FindAccountTaxGroup(criteria *Criteria) (*AccountTaxGroup, erro if err := c.SearchRead(AccountTaxGroupModel, criteria, NewOptions().Limit(1), atgs); err != nil { return nil, err } - if atgs != nil && len(*atgs) > 0 { - return &((*atgs)[0]), nil - } - return nil, fmt.Errorf("account.tax.group was not found with criteria %v", criteria) + return &((*atgs)[0]), nil } // FindAccountTaxGroups finds account.tax.group records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindAccountTaxGroups(criteria *Criteria, options *Options) (*Ac // FindAccountTaxGroupIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountTaxGroupIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountTaxGroupModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountTaxGroupModel, criteria, options) } // FindAccountTaxGroupId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindAccountTaxGroupId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.tax.group was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_tax_report.go b/account_tax_report.go index 89d7891a..b96d128f 100644 --- a/account_tax_report.go +++ b/account_tax_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountTaxReport represents account.tax.report model. type AccountTaxReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateAccountTaxReports(atrs []*AccountTaxReport) ([]int64, err for _, v := range atrs { vv = append(vv, v) } - return c.Create(AccountTaxReportModel, vv) + return c.Create(AccountTaxReportModel, vv, nil) } // UpdateAccountTaxReport updates an existing account.tax.report record. @@ -60,7 +56,7 @@ func (c *Client) UpdateAccountTaxReport(atr *AccountTaxReport) error { // UpdateAccountTaxReports updates existing account.tax.report records. // All records (represented by ids) will be updated by atr values. func (c *Client) UpdateAccountTaxReports(ids []int64, atr *AccountTaxReport) error { - return c.Update(AccountTaxReportModel, ids, atr) + return c.Update(AccountTaxReportModel, ids, atr, nil) } // DeleteAccountTaxReport deletes an existing account.tax.report record. @@ -79,10 +75,7 @@ func (c *Client) GetAccountTaxReport(id int64) (*AccountTaxReport, error) { if err != nil { return nil, err } - if atrs != nil && len(*atrs) > 0 { - return &((*atrs)[0]), nil - } - return nil, fmt.Errorf("id %v of account.tax.report not found", id) + return &((*atrs)[0]), nil } // GetAccountTaxReports gets account.tax.report existing records. @@ -100,10 +93,7 @@ func (c *Client) FindAccountTaxReport(criteria *Criteria) (*AccountTaxReport, er if err := c.SearchRead(AccountTaxReportModel, criteria, NewOptions().Limit(1), atrs); err != nil { return nil, err } - if atrs != nil && len(*atrs) > 0 { - return &((*atrs)[0]), nil - } - return nil, fmt.Errorf("account.tax.report was not found with criteria %v", criteria) + return &((*atrs)[0]), nil } // FindAccountTaxReports finds account.tax.report records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindAccountTaxReports(criteria *Criteria, options *Options) (*A // FindAccountTaxReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountTaxReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountTaxReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountTaxReportModel, criteria, options) } // FindAccountTaxReportId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindAccountTaxReportId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.tax.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_tax_template.go b/account_tax_template.go index a4e60732..c9fa2ae2 100644 --- a/account_tax_template.go +++ b/account_tax_template.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountTaxTemplate represents account.tax.template model. type AccountTaxTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -64,7 +60,7 @@ func (c *Client) CreateAccountTaxTemplates(atts []*AccountTaxTemplate) ([]int64, for _, v := range atts { vv = append(vv, v) } - return c.Create(AccountTaxTemplateModel, vv) + return c.Create(AccountTaxTemplateModel, vv, nil) } // UpdateAccountTaxTemplate updates an existing account.tax.template record. @@ -75,7 +71,7 @@ func (c *Client) UpdateAccountTaxTemplate(att *AccountTaxTemplate) error { // UpdateAccountTaxTemplates updates existing account.tax.template records. // All records (represented by ids) will be updated by att values. func (c *Client) UpdateAccountTaxTemplates(ids []int64, att *AccountTaxTemplate) error { - return c.Update(AccountTaxTemplateModel, ids, att) + return c.Update(AccountTaxTemplateModel, ids, att, nil) } // DeleteAccountTaxTemplate deletes an existing account.tax.template record. @@ -94,10 +90,7 @@ func (c *Client) GetAccountTaxTemplate(id int64) (*AccountTaxTemplate, error) { if err != nil { return nil, err } - if atts != nil && len(*atts) > 0 { - return &((*atts)[0]), nil - } - return nil, fmt.Errorf("id %v of account.tax.template not found", id) + return &((*atts)[0]), nil } // GetAccountTaxTemplates gets account.tax.template existing records. @@ -115,10 +108,7 @@ func (c *Client) FindAccountTaxTemplate(criteria *Criteria) (*AccountTaxTemplate if err := c.SearchRead(AccountTaxTemplateModel, criteria, NewOptions().Limit(1), atts); err != nil { return nil, err } - if atts != nil && len(*atts) > 0 { - return &((*atts)[0]), nil - } - return nil, fmt.Errorf("account.tax.template was not found with criteria %v", criteria) + return &((*atts)[0]), nil } // FindAccountTaxTemplates finds account.tax.template records by querying it @@ -134,11 +124,7 @@ func (c *Client) FindAccountTaxTemplates(criteria *Criteria, options *Options) ( // FindAccountTaxTemplateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountTaxTemplateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountTaxTemplateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountTaxTemplateModel, criteria, options) } // FindAccountTaxTemplateId finds record id by querying it with criteria. @@ -147,8 +133,5 @@ func (c *Client) FindAccountTaxTemplateId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.tax.template was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/account_unreconcile.go b/account_unreconcile.go index 80b95561..564aa368 100644 --- a/account_unreconcile.go +++ b/account_unreconcile.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountUnreconcile represents account.unreconcile model. type AccountUnreconcile struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -44,7 +40,7 @@ func (c *Client) CreateAccountUnreconciles(aus []*AccountUnreconcile) ([]int64, for _, v := range aus { vv = append(vv, v) } - return c.Create(AccountUnreconcileModel, vv) + return c.Create(AccountUnreconcileModel, vv, nil) } // UpdateAccountUnreconcile updates an existing account.unreconcile record. @@ -55,7 +51,7 @@ func (c *Client) UpdateAccountUnreconcile(au *AccountUnreconcile) error { // UpdateAccountUnreconciles updates existing account.unreconcile records. // All records (represented by ids) will be updated by au values. func (c *Client) UpdateAccountUnreconciles(ids []int64, au *AccountUnreconcile) error { - return c.Update(AccountUnreconcileModel, ids, au) + return c.Update(AccountUnreconcileModel, ids, au, nil) } // DeleteAccountUnreconcile deletes an existing account.unreconcile record. @@ -74,10 +70,7 @@ func (c *Client) GetAccountUnreconcile(id int64) (*AccountUnreconcile, error) { if err != nil { return nil, err } - if aus != nil && len(*aus) > 0 { - return &((*aus)[0]), nil - } - return nil, fmt.Errorf("id %v of account.unreconcile not found", id) + return &((*aus)[0]), nil } // GetAccountUnreconciles gets account.unreconcile existing records. @@ -95,10 +88,7 @@ func (c *Client) FindAccountUnreconcile(criteria *Criteria) (*AccountUnreconcile if err := c.SearchRead(AccountUnreconcileModel, criteria, NewOptions().Limit(1), aus); err != nil { return nil, err } - if aus != nil && len(*aus) > 0 { - return &((*aus)[0]), nil - } - return nil, fmt.Errorf("account.unreconcile was not found with criteria %v", criteria) + return &((*aus)[0]), nil } // FindAccountUnreconciles finds account.unreconcile records by querying it @@ -114,11 +104,7 @@ func (c *Client) FindAccountUnreconciles(criteria *Criteria, options *Options) ( // FindAccountUnreconcileIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountUnreconcileIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountUnreconcileModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountUnreconcileModel, criteria, options) } // FindAccountUnreconcileId finds record id by querying it with criteria. @@ -127,8 +113,5 @@ func (c *Client) FindAccountUnreconcileId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("account.unreconcile was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/accounting_report.go b/accounting_report.go index 994d9879..3ddab39f 100644 --- a/accounting_report.go +++ b/accounting_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AccountingReport represents accounting.report model. type AccountingReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -56,7 +52,7 @@ func (c *Client) CreateAccountingReports(ars []*AccountingReport) ([]int64, erro for _, v := range ars { vv = append(vv, v) } - return c.Create(AccountingReportModel, vv) + return c.Create(AccountingReportModel, vv, nil) } // UpdateAccountingReport updates an existing accounting.report record. @@ -67,7 +63,7 @@ func (c *Client) UpdateAccountingReport(ar *AccountingReport) error { // UpdateAccountingReports updates existing accounting.report records. // All records (represented by ids) will be updated by ar values. func (c *Client) UpdateAccountingReports(ids []int64, ar *AccountingReport) error { - return c.Update(AccountingReportModel, ids, ar) + return c.Update(AccountingReportModel, ids, ar, nil) } // DeleteAccountingReport deletes an existing accounting.report record. @@ -86,10 +82,7 @@ func (c *Client) GetAccountingReport(id int64) (*AccountingReport, error) { if err != nil { return nil, err } - if ars != nil && len(*ars) > 0 { - return &((*ars)[0]), nil - } - return nil, fmt.Errorf("id %v of accounting.report not found", id) + return &((*ars)[0]), nil } // GetAccountingReports gets accounting.report existing records. @@ -107,10 +100,7 @@ func (c *Client) FindAccountingReport(criteria *Criteria) (*AccountingReport, er if err := c.SearchRead(AccountingReportModel, criteria, NewOptions().Limit(1), ars); err != nil { return nil, err } - if ars != nil && len(*ars) > 0 { - return &((*ars)[0]), nil - } - return nil, fmt.Errorf("accounting.report was not found with criteria %v", criteria) + return &((*ars)[0]), nil } // FindAccountingReports finds accounting.report records by querying it @@ -126,11 +116,7 @@ func (c *Client) FindAccountingReports(criteria *Criteria, options *Options) (*A // FindAccountingReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAccountingReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AccountingReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AccountingReportModel, criteria, options) } // FindAccountingReportId finds record id by querying it with criteria. @@ -139,8 +125,5 @@ func (c *Client) FindAccountingReportId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("accounting.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/autosales_config.go b/autosales_config.go index ef2f83c4..15508f8f 100644 --- a/autosales_config.go +++ b/autosales_config.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AutosalesConfig represents autosales.config model. type AutosalesConfig struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateAutosalesConfigs(acs []*AutosalesConfig) ([]int64, error) for _, v := range acs { vv = append(vv, v) } - return c.Create(AutosalesConfigModel, vv) + return c.Create(AutosalesConfigModel, vv, nil) } // UpdateAutosalesConfig updates an existing autosales.config record. @@ -58,7 +54,7 @@ func (c *Client) UpdateAutosalesConfig(ac *AutosalesConfig) error { // UpdateAutosalesConfigs updates existing autosales.config records. // All records (represented by ids) will be updated by ac values. func (c *Client) UpdateAutosalesConfigs(ids []int64, ac *AutosalesConfig) error { - return c.Update(AutosalesConfigModel, ids, ac) + return c.Update(AutosalesConfigModel, ids, ac, nil) } // DeleteAutosalesConfig deletes an existing autosales.config record. @@ -77,10 +73,7 @@ func (c *Client) GetAutosalesConfig(id int64) (*AutosalesConfig, error) { if err != nil { return nil, err } - if acs != nil && len(*acs) > 0 { - return &((*acs)[0]), nil - } - return nil, fmt.Errorf("id %v of autosales.config not found", id) + return &((*acs)[0]), nil } // GetAutosalesConfigs gets autosales.config existing records. @@ -98,10 +91,7 @@ func (c *Client) FindAutosalesConfig(criteria *Criteria) (*AutosalesConfig, erro if err := c.SearchRead(AutosalesConfigModel, criteria, NewOptions().Limit(1), acs); err != nil { return nil, err } - if acs != nil && len(*acs) > 0 { - return &((*acs)[0]), nil - } - return nil, fmt.Errorf("autosales.config was not found with criteria %v", criteria) + return &((*acs)[0]), nil } // FindAutosalesConfigs finds autosales.config records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindAutosalesConfigs(criteria *Criteria, options *Options) (*Au // FindAutosalesConfigIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAutosalesConfigIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AutosalesConfigModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AutosalesConfigModel, criteria, options) } // FindAutosalesConfigId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindAutosalesConfigId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("autosales.config was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/autosales_config_line.go b/autosales_config_line.go index 6f037df2..d4d02825 100644 --- a/autosales_config_line.go +++ b/autosales_config_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // AutosalesConfigLine represents autosales.config.line model. type AutosalesConfigLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateAutosalesConfigLines(acls []*AutosalesConfigLine) ([]int6 for _, v := range acls { vv = append(vv, v) } - return c.Create(AutosalesConfigLineModel, vv) + return c.Create(AutosalesConfigLineModel, vv, nil) } // UpdateAutosalesConfigLine updates an existing autosales.config.line record. @@ -60,7 +56,7 @@ func (c *Client) UpdateAutosalesConfigLine(acl *AutosalesConfigLine) error { // UpdateAutosalesConfigLines updates existing autosales.config.line records. // All records (represented by ids) will be updated by acl values. func (c *Client) UpdateAutosalesConfigLines(ids []int64, acl *AutosalesConfigLine) error { - return c.Update(AutosalesConfigLineModel, ids, acl) + return c.Update(AutosalesConfigLineModel, ids, acl, nil) } // DeleteAutosalesConfigLine deletes an existing autosales.config.line record. @@ -79,10 +75,7 @@ func (c *Client) GetAutosalesConfigLine(id int64) (*AutosalesConfigLine, error) if err != nil { return nil, err } - if acls != nil && len(*acls) > 0 { - return &((*acls)[0]), nil - } - return nil, fmt.Errorf("id %v of autosales.config.line not found", id) + return &((*acls)[0]), nil } // GetAutosalesConfigLines gets autosales.config.line existing records. @@ -100,10 +93,7 @@ func (c *Client) FindAutosalesConfigLine(criteria *Criteria) (*AutosalesConfigLi if err := c.SearchRead(AutosalesConfigLineModel, criteria, NewOptions().Limit(1), acls); err != nil { return nil, err } - if acls != nil && len(*acls) > 0 { - return &((*acls)[0]), nil - } - return nil, fmt.Errorf("autosales.config.line was not found with criteria %v", criteria) + return &((*acls)[0]), nil } // FindAutosalesConfigLines finds autosales.config.line records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindAutosalesConfigLines(criteria *Criteria, options *Options) // FindAutosalesConfigLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindAutosalesConfigLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(AutosalesConfigLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(AutosalesConfigLineModel, criteria, options) } // FindAutosalesConfigLineId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindAutosalesConfigLineId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("autosales.config.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/barcode_nomenclature.go b/barcode_nomenclature.go index 52030baf..a3e278d6 100644 --- a/barcode_nomenclature.go +++ b/barcode_nomenclature.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BarcodeNomenclature represents barcode.nomenclature model. type BarcodeNomenclature struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateBarcodeNomenclatures(bns []*BarcodeNomenclature) ([]int64 for _, v := range bns { vv = append(vv, v) } - return c.Create(BarcodeNomenclatureModel, vv) + return c.Create(BarcodeNomenclatureModel, vv, nil) } // UpdateBarcodeNomenclature updates an existing barcode.nomenclature record. @@ -58,7 +54,7 @@ func (c *Client) UpdateBarcodeNomenclature(bn *BarcodeNomenclature) error { // UpdateBarcodeNomenclatures updates existing barcode.nomenclature records. // All records (represented by ids) will be updated by bn values. func (c *Client) UpdateBarcodeNomenclatures(ids []int64, bn *BarcodeNomenclature) error { - return c.Update(BarcodeNomenclatureModel, ids, bn) + return c.Update(BarcodeNomenclatureModel, ids, bn, nil) } // DeleteBarcodeNomenclature deletes an existing barcode.nomenclature record. @@ -77,10 +73,7 @@ func (c *Client) GetBarcodeNomenclature(id int64) (*BarcodeNomenclature, error) if err != nil { return nil, err } - if bns != nil && len(*bns) > 0 { - return &((*bns)[0]), nil - } - return nil, fmt.Errorf("id %v of barcode.nomenclature not found", id) + return &((*bns)[0]), nil } // GetBarcodeNomenclatures gets barcode.nomenclature existing records. @@ -98,10 +91,7 @@ func (c *Client) FindBarcodeNomenclature(criteria *Criteria) (*BarcodeNomenclatu if err := c.SearchRead(BarcodeNomenclatureModel, criteria, NewOptions().Limit(1), bns); err != nil { return nil, err } - if bns != nil && len(*bns) > 0 { - return &((*bns)[0]), nil - } - return nil, fmt.Errorf("barcode.nomenclature was not found with criteria %v", criteria) + return &((*bns)[0]), nil } // FindBarcodeNomenclatures finds barcode.nomenclature records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindBarcodeNomenclatures(criteria *Criteria, options *Options) // FindBarcodeNomenclatureIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBarcodeNomenclatureIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BarcodeNomenclatureModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BarcodeNomenclatureModel, criteria, options) } // FindBarcodeNomenclatureId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindBarcodeNomenclatureId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("barcode.nomenclature was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/barcode_rule.go b/barcode_rule.go index d3b6b79c..f3526428 100644 --- a/barcode_rule.go +++ b/barcode_rule.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BarcodeRule represents barcode.rule model. type BarcodeRule struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -51,7 +47,7 @@ func (c *Client) CreateBarcodeRules(brs []*BarcodeRule) ([]int64, error) { for _, v := range brs { vv = append(vv, v) } - return c.Create(BarcodeRuleModel, vv) + return c.Create(BarcodeRuleModel, vv, nil) } // UpdateBarcodeRule updates an existing barcode.rule record. @@ -62,7 +58,7 @@ func (c *Client) UpdateBarcodeRule(br *BarcodeRule) error { // UpdateBarcodeRules updates existing barcode.rule records. // All records (represented by ids) will be updated by br values. func (c *Client) UpdateBarcodeRules(ids []int64, br *BarcodeRule) error { - return c.Update(BarcodeRuleModel, ids, br) + return c.Update(BarcodeRuleModel, ids, br, nil) } // DeleteBarcodeRule deletes an existing barcode.rule record. @@ -81,10 +77,7 @@ func (c *Client) GetBarcodeRule(id int64) (*BarcodeRule, error) { if err != nil { return nil, err } - if brs != nil && len(*brs) > 0 { - return &((*brs)[0]), nil - } - return nil, fmt.Errorf("id %v of barcode.rule not found", id) + return &((*brs)[0]), nil } // GetBarcodeRules gets barcode.rule existing records. @@ -102,10 +95,7 @@ func (c *Client) FindBarcodeRule(criteria *Criteria) (*BarcodeRule, error) { if err := c.SearchRead(BarcodeRuleModel, criteria, NewOptions().Limit(1), brs); err != nil { return nil, err } - if brs != nil && len(*brs) > 0 { - return &((*brs)[0]), nil - } - return nil, fmt.Errorf("barcode.rule was not found with criteria %v", criteria) + return &((*brs)[0]), nil } // FindBarcodeRules finds barcode.rule records by querying it @@ -121,11 +111,7 @@ func (c *Client) FindBarcodeRules(criteria *Criteria, options *Options) (*Barcod // FindBarcodeRuleIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBarcodeRuleIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BarcodeRuleModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BarcodeRuleModel, criteria, options) } // FindBarcodeRuleId finds record id by querying it with criteria. @@ -134,8 +120,5 @@ func (c *Client) FindBarcodeRuleId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("barcode.rule was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/barcodes_barcode_events_mixin.go b/barcodes_barcode_events_mixin.go index 4f4d4d97..60eb2c75 100644 --- a/barcodes_barcode_events_mixin.go +++ b/barcodes_barcode_events_mixin.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BarcodesBarcodeEventsMixin represents barcodes.barcode_events_mixin model. type BarcodesBarcodeEventsMixin struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -41,7 +37,7 @@ func (c *Client) CreateBarcodesBarcodeEventsMixins(bbs []*BarcodesBarcodeEventsM for _, v := range bbs { vv = append(vv, v) } - return c.Create(BarcodesBarcodeEventsMixinModel, vv) + return c.Create(BarcodesBarcodeEventsMixinModel, vv, nil) } // UpdateBarcodesBarcodeEventsMixin updates an existing barcodes.barcode_events_mixin record. @@ -52,7 +48,7 @@ func (c *Client) UpdateBarcodesBarcodeEventsMixin(bb *BarcodesBarcodeEventsMixin // UpdateBarcodesBarcodeEventsMixins updates existing barcodes.barcode_events_mixin records. // All records (represented by ids) will be updated by bb values. func (c *Client) UpdateBarcodesBarcodeEventsMixins(ids []int64, bb *BarcodesBarcodeEventsMixin) error { - return c.Update(BarcodesBarcodeEventsMixinModel, ids, bb) + return c.Update(BarcodesBarcodeEventsMixinModel, ids, bb, nil) } // DeleteBarcodesBarcodeEventsMixin deletes an existing barcodes.barcode_events_mixin record. @@ -71,10 +67,7 @@ func (c *Client) GetBarcodesBarcodeEventsMixin(id int64) (*BarcodesBarcodeEvents if err != nil { return nil, err } - if bbs != nil && len(*bbs) > 0 { - return &((*bbs)[0]), nil - } - return nil, fmt.Errorf("id %v of barcodes.barcode_events_mixin not found", id) + return &((*bbs)[0]), nil } // GetBarcodesBarcodeEventsMixins gets barcodes.barcode_events_mixin existing records. @@ -92,10 +85,7 @@ func (c *Client) FindBarcodesBarcodeEventsMixin(criteria *Criteria) (*BarcodesBa if err := c.SearchRead(BarcodesBarcodeEventsMixinModel, criteria, NewOptions().Limit(1), bbs); err != nil { return nil, err } - if bbs != nil && len(*bbs) > 0 { - return &((*bbs)[0]), nil - } - return nil, fmt.Errorf("barcodes.barcode_events_mixin was not found with criteria %v", criteria) + return &((*bbs)[0]), nil } // FindBarcodesBarcodeEventsMixins finds barcodes.barcode_events_mixin records by querying it @@ -111,11 +101,7 @@ func (c *Client) FindBarcodesBarcodeEventsMixins(criteria *Criteria, options *Op // FindBarcodesBarcodeEventsMixinIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBarcodesBarcodeEventsMixinIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BarcodesBarcodeEventsMixinModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BarcodesBarcodeEventsMixinModel, criteria, options) } // FindBarcodesBarcodeEventsMixinId finds record id by querying it with criteria. @@ -124,8 +110,5 @@ func (c *Client) FindBarcodesBarcodeEventsMixinId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("barcodes.barcode_events_mixin was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base.go b/base.go index d1c7fcb3..3265b19d 100644 --- a/base.go +++ b/base.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // Base represents base model. type Base struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateBases(bs []*Base) ([]int64, error) { for _, v := range bs { vv = append(vv, v) } - return c.Create(BaseModel, vv) + return c.Create(BaseModel, vv, nil) } // UpdateBase updates an existing base record. @@ -51,7 +47,7 @@ func (c *Client) UpdateBase(b *Base) error { // UpdateBases updates existing base records. // All records (represented by ids) will be updated by b values. func (c *Client) UpdateBases(ids []int64, b *Base) error { - return c.Update(BaseModel, ids, b) + return c.Update(BaseModel, ids, b, nil) } // DeleteBase deletes an existing base record. @@ -70,10 +66,7 @@ func (c *Client) GetBase(id int64) (*Base, error) { if err != nil { return nil, err } - if bs != nil && len(*bs) > 0 { - return &((*bs)[0]), nil - } - return nil, fmt.Errorf("id %v of base not found", id) + return &((*bs)[0]), nil } // GetBases gets base existing records. @@ -91,10 +84,7 @@ func (c *Client) FindBase(criteria *Criteria) (*Base, error) { if err := c.SearchRead(BaseModel, criteria, NewOptions().Limit(1), bs); err != nil { return nil, err } - if bs != nil && len(*bs) > 0 { - return &((*bs)[0]), nil - } - return nil, fmt.Errorf("base was not found with criteria %v", criteria) + return &((*bs)[0]), nil } // FindBases finds base records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindBases(criteria *Criteria, options *Options) (*Bases, error) // FindBaseIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseModel, criteria, options) } // FindBaseId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindBaseId(criteria *Criteria, options *Options) (int64, error) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_import.go b/base_import_import.go index 40654ff2..149d43e4 100644 --- a/base_import_import.go +++ b/base_import_import.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportImport represents base_import.import model. type BaseImportImport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateBaseImportImports(bis []*BaseImportImport) ([]int64, erro for _, v := range bis { vv = append(vv, v) } - return c.Create(BaseImportImportModel, vv) + return c.Create(BaseImportImportModel, vv, nil) } // UpdateBaseImportImport updates an existing base_import.import record. @@ -59,7 +55,7 @@ func (c *Client) UpdateBaseImportImport(bi *BaseImportImport) error { // UpdateBaseImportImports updates existing base_import.import records. // All records (represented by ids) will be updated by bi values. func (c *Client) UpdateBaseImportImports(ids []int64, bi *BaseImportImport) error { - return c.Update(BaseImportImportModel, ids, bi) + return c.Update(BaseImportImportModel, ids, bi, nil) } // DeleteBaseImportImport deletes an existing base_import.import record. @@ -78,10 +74,7 @@ func (c *Client) GetBaseImportImport(id int64) (*BaseImportImport, error) { if err != nil { return nil, err } - if bis != nil && len(*bis) > 0 { - return &((*bis)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.import not found", id) + return &((*bis)[0]), nil } // GetBaseImportImports gets base_import.import existing records. @@ -99,10 +92,7 @@ func (c *Client) FindBaseImportImport(criteria *Criteria) (*BaseImportImport, er if err := c.SearchRead(BaseImportImportModel, criteria, NewOptions().Limit(1), bis); err != nil { return nil, err } - if bis != nil && len(*bis) > 0 { - return &((*bis)[0]), nil - } - return nil, fmt.Errorf("base_import.import was not found with criteria %v", criteria) + return &((*bis)[0]), nil } // FindBaseImportImports finds base_import.import records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindBaseImportImports(criteria *Criteria, options *Options) (*B // FindBaseImportImportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportImportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportImportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportImportModel, criteria, options) } // FindBaseImportImportId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindBaseImportImportId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.import was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_char.go b/base_import_tests_models_char.go index 3ea7a478..b7592fac 100644 --- a/base_import_tests_models_char.go +++ b/base_import_tests_models_char.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsChar represents base_import.tests.models.char model. type BaseImportTestsModelsChar struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseImportTestsModelsChars(btmcs []*BaseImportTestsModels for _, v := range btmcs { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsCharModel, vv) + return c.Create(BaseImportTestsModelsCharModel, vv, nil) } // UpdateBaseImportTestsModelsChar updates an existing base_import.tests.models.char record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseImportTestsModelsChar(btmc *BaseImportTestsModelsChar // UpdateBaseImportTestsModelsChars updates existing base_import.tests.models.char records. // All records (represented by ids) will be updated by btmc values. func (c *Client) UpdateBaseImportTestsModelsChars(ids []int64, btmc *BaseImportTestsModelsChar) error { - return c.Update(BaseImportTestsModelsCharModel, ids, btmc) + return c.Update(BaseImportTestsModelsCharModel, ids, btmc, nil) } // DeleteBaseImportTestsModelsChar deletes an existing base_import.tests.models.char record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseImportTestsModelsChar(id int64) (*BaseImportTestsModelsC if err != nil { return nil, err } - if btmcs != nil && len(*btmcs) > 0 { - return &((*btmcs)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.char not found", id) + return &((*btmcs)[0]), nil } // GetBaseImportTestsModelsChars gets base_import.tests.models.char existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseImportTestsModelsChar(criteria *Criteria) (*BaseImportT if err := c.SearchRead(BaseImportTestsModelsCharModel, criteria, NewOptions().Limit(1), btmcs); err != nil { return nil, err } - if btmcs != nil && len(*btmcs) > 0 { - return &((*btmcs)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.char was not found with criteria %v", criteria) + return &((*btmcs)[0]), nil } // FindBaseImportTestsModelsChars finds base_import.tests.models.char records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseImportTestsModelsChars(criteria *Criteria, options *Opt // FindBaseImportTestsModelsCharIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsCharIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsCharModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsCharModel, criteria, options) } // FindBaseImportTestsModelsCharId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseImportTestsModelsCharId(criteria *Criteria, options *Op if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.char was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_char_noreadonly.go b/base_import_tests_models_char_noreadonly.go index e28c04bb..48a50b11 100644 --- a/base_import_tests_models_char_noreadonly.go +++ b/base_import_tests_models_char_noreadonly.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsCharNoreadonly represents base_import.tests.models.char.noreadonly model. type BaseImportTestsModelsCharNoreadonly struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseImportTestsModelsCharNoreadonlys(btmcns []*BaseImport for _, v := range btmcns { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsCharNoreadonlyModel, vv) + return c.Create(BaseImportTestsModelsCharNoreadonlyModel, vv, nil) } // UpdateBaseImportTestsModelsCharNoreadonly updates an existing base_import.tests.models.char.noreadonly record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseImportTestsModelsCharNoreadonly(btmcn *BaseImportTest // UpdateBaseImportTestsModelsCharNoreadonlys updates existing base_import.tests.models.char.noreadonly records. // All records (represented by ids) will be updated by btmcn values. func (c *Client) UpdateBaseImportTestsModelsCharNoreadonlys(ids []int64, btmcn *BaseImportTestsModelsCharNoreadonly) error { - return c.Update(BaseImportTestsModelsCharNoreadonlyModel, ids, btmcn) + return c.Update(BaseImportTestsModelsCharNoreadonlyModel, ids, btmcn, nil) } // DeleteBaseImportTestsModelsCharNoreadonly deletes an existing base_import.tests.models.char.noreadonly record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseImportTestsModelsCharNoreadonly(id int64) (*BaseImportTe if err != nil { return nil, err } - if btmcns != nil && len(*btmcns) > 0 { - return &((*btmcns)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.char.noreadonly not found", id) + return &((*btmcns)[0]), nil } // GetBaseImportTestsModelsCharNoreadonlys gets base_import.tests.models.char.noreadonly existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseImportTestsModelsCharNoreadonly(criteria *Criteria) (*B if err := c.SearchRead(BaseImportTestsModelsCharNoreadonlyModel, criteria, NewOptions().Limit(1), btmcns); err != nil { return nil, err } - if btmcns != nil && len(*btmcns) > 0 { - return &((*btmcns)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.char.noreadonly was not found with criteria %v", criteria) + return &((*btmcns)[0]), nil } // FindBaseImportTestsModelsCharNoreadonlys finds base_import.tests.models.char.noreadonly records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseImportTestsModelsCharNoreadonlys(criteria *Criteria, op // FindBaseImportTestsModelsCharNoreadonlyIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsCharNoreadonlyIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsCharNoreadonlyModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsCharNoreadonlyModel, criteria, options) } // FindBaseImportTestsModelsCharNoreadonlyId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseImportTestsModelsCharNoreadonlyId(criteria *Criteria, o if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.char.noreadonly was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_char_readonly.go b/base_import_tests_models_char_readonly.go index 1e20ee38..a7e1b295 100644 --- a/base_import_tests_models_char_readonly.go +++ b/base_import_tests_models_char_readonly.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsCharReadonly represents base_import.tests.models.char.readonly model. type BaseImportTestsModelsCharReadonly struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseImportTestsModelsCharReadonlys(btmcrs []*BaseImportTe for _, v := range btmcrs { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsCharReadonlyModel, vv) + return c.Create(BaseImportTestsModelsCharReadonlyModel, vv, nil) } // UpdateBaseImportTestsModelsCharReadonly updates an existing base_import.tests.models.char.readonly record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseImportTestsModelsCharReadonly(btmcr *BaseImportTestsM // UpdateBaseImportTestsModelsCharReadonlys updates existing base_import.tests.models.char.readonly records. // All records (represented by ids) will be updated by btmcr values. func (c *Client) UpdateBaseImportTestsModelsCharReadonlys(ids []int64, btmcr *BaseImportTestsModelsCharReadonly) error { - return c.Update(BaseImportTestsModelsCharReadonlyModel, ids, btmcr) + return c.Update(BaseImportTestsModelsCharReadonlyModel, ids, btmcr, nil) } // DeleteBaseImportTestsModelsCharReadonly deletes an existing base_import.tests.models.char.readonly record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseImportTestsModelsCharReadonly(id int64) (*BaseImportTest if err != nil { return nil, err } - if btmcrs != nil && len(*btmcrs) > 0 { - return &((*btmcrs)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.char.readonly not found", id) + return &((*btmcrs)[0]), nil } // GetBaseImportTestsModelsCharReadonlys gets base_import.tests.models.char.readonly existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseImportTestsModelsCharReadonly(criteria *Criteria) (*Bas if err := c.SearchRead(BaseImportTestsModelsCharReadonlyModel, criteria, NewOptions().Limit(1), btmcrs); err != nil { return nil, err } - if btmcrs != nil && len(*btmcrs) > 0 { - return &((*btmcrs)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.char.readonly was not found with criteria %v", criteria) + return &((*btmcrs)[0]), nil } // FindBaseImportTestsModelsCharReadonlys finds base_import.tests.models.char.readonly records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseImportTestsModelsCharReadonlys(criteria *Criteria, opti // FindBaseImportTestsModelsCharReadonlyIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsCharReadonlyIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsCharReadonlyModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsCharReadonlyModel, criteria, options) } // FindBaseImportTestsModelsCharReadonlyId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseImportTestsModelsCharReadonlyId(criteria *Criteria, opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.char.readonly was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_char_required.go b/base_import_tests_models_char_required.go index a42a1d9e..139ffb18 100644 --- a/base_import_tests_models_char_required.go +++ b/base_import_tests_models_char_required.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsCharRequired represents base_import.tests.models.char.required model. type BaseImportTestsModelsCharRequired struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseImportTestsModelsCharRequireds(btmcrs []*BaseImportTe for _, v := range btmcrs { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsCharRequiredModel, vv) + return c.Create(BaseImportTestsModelsCharRequiredModel, vv, nil) } // UpdateBaseImportTestsModelsCharRequired updates an existing base_import.tests.models.char.required record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseImportTestsModelsCharRequired(btmcr *BaseImportTestsM // UpdateBaseImportTestsModelsCharRequireds updates existing base_import.tests.models.char.required records. // All records (represented by ids) will be updated by btmcr values. func (c *Client) UpdateBaseImportTestsModelsCharRequireds(ids []int64, btmcr *BaseImportTestsModelsCharRequired) error { - return c.Update(BaseImportTestsModelsCharRequiredModel, ids, btmcr) + return c.Update(BaseImportTestsModelsCharRequiredModel, ids, btmcr, nil) } // DeleteBaseImportTestsModelsCharRequired deletes an existing base_import.tests.models.char.required record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseImportTestsModelsCharRequired(id int64) (*BaseImportTest if err != nil { return nil, err } - if btmcrs != nil && len(*btmcrs) > 0 { - return &((*btmcrs)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.char.required not found", id) + return &((*btmcrs)[0]), nil } // GetBaseImportTestsModelsCharRequireds gets base_import.tests.models.char.required existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseImportTestsModelsCharRequired(criteria *Criteria) (*Bas if err := c.SearchRead(BaseImportTestsModelsCharRequiredModel, criteria, NewOptions().Limit(1), btmcrs); err != nil { return nil, err } - if btmcrs != nil && len(*btmcrs) > 0 { - return &((*btmcrs)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.char.required was not found with criteria %v", criteria) + return &((*btmcrs)[0]), nil } // FindBaseImportTestsModelsCharRequireds finds base_import.tests.models.char.required records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseImportTestsModelsCharRequireds(criteria *Criteria, opti // FindBaseImportTestsModelsCharRequiredIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsCharRequiredIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsCharRequiredModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsCharRequiredModel, criteria, options) } // FindBaseImportTestsModelsCharRequiredId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseImportTestsModelsCharRequiredId(criteria *Criteria, opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.char.required was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_char_states.go b/base_import_tests_models_char_states.go index f6c47ff8..4dad937f 100644 --- a/base_import_tests_models_char_states.go +++ b/base_import_tests_models_char_states.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsCharStates represents base_import.tests.models.char.states model. type BaseImportTestsModelsCharStates struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseImportTestsModelsCharStatess(btmcss []*BaseImportTest for _, v := range btmcss { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsCharStatesModel, vv) + return c.Create(BaseImportTestsModelsCharStatesModel, vv, nil) } // UpdateBaseImportTestsModelsCharStates updates an existing base_import.tests.models.char.states record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseImportTestsModelsCharStates(btmcs *BaseImportTestsMod // UpdateBaseImportTestsModelsCharStatess updates existing base_import.tests.models.char.states records. // All records (represented by ids) will be updated by btmcs values. func (c *Client) UpdateBaseImportTestsModelsCharStatess(ids []int64, btmcs *BaseImportTestsModelsCharStates) error { - return c.Update(BaseImportTestsModelsCharStatesModel, ids, btmcs) + return c.Update(BaseImportTestsModelsCharStatesModel, ids, btmcs, nil) } // DeleteBaseImportTestsModelsCharStates deletes an existing base_import.tests.models.char.states record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseImportTestsModelsCharStates(id int64) (*BaseImportTestsM if err != nil { return nil, err } - if btmcss != nil && len(*btmcss) > 0 { - return &((*btmcss)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.char.states not found", id) + return &((*btmcss)[0]), nil } // GetBaseImportTestsModelsCharStatess gets base_import.tests.models.char.states existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseImportTestsModelsCharStates(criteria *Criteria) (*BaseI if err := c.SearchRead(BaseImportTestsModelsCharStatesModel, criteria, NewOptions().Limit(1), btmcss); err != nil { return nil, err } - if btmcss != nil && len(*btmcss) > 0 { - return &((*btmcss)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.char.states was not found with criteria %v", criteria) + return &((*btmcss)[0]), nil } // FindBaseImportTestsModelsCharStatess finds base_import.tests.models.char.states records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseImportTestsModelsCharStatess(criteria *Criteria, option // FindBaseImportTestsModelsCharStatesIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsCharStatesIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsCharStatesModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsCharStatesModel, criteria, options) } // FindBaseImportTestsModelsCharStatesId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseImportTestsModelsCharStatesId(criteria *Criteria, optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.char.states was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_char_stillreadonly.go b/base_import_tests_models_char_stillreadonly.go index 9b40931b..a4587f7a 100644 --- a/base_import_tests_models_char_stillreadonly.go +++ b/base_import_tests_models_char_stillreadonly.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsCharStillreadonly represents base_import.tests.models.char.stillreadonly model. type BaseImportTestsModelsCharStillreadonly struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseImportTestsModelsCharStillreadonlys(btmcss []*BaseImp for _, v := range btmcss { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsCharStillreadonlyModel, vv) + return c.Create(BaseImportTestsModelsCharStillreadonlyModel, vv, nil) } // UpdateBaseImportTestsModelsCharStillreadonly updates an existing base_import.tests.models.char.stillreadonly record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseImportTestsModelsCharStillreadonly(btmcs *BaseImportT // UpdateBaseImportTestsModelsCharStillreadonlys updates existing base_import.tests.models.char.stillreadonly records. // All records (represented by ids) will be updated by btmcs values. func (c *Client) UpdateBaseImportTestsModelsCharStillreadonlys(ids []int64, btmcs *BaseImportTestsModelsCharStillreadonly) error { - return c.Update(BaseImportTestsModelsCharStillreadonlyModel, ids, btmcs) + return c.Update(BaseImportTestsModelsCharStillreadonlyModel, ids, btmcs, nil) } // DeleteBaseImportTestsModelsCharStillreadonly deletes an existing base_import.tests.models.char.stillreadonly record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseImportTestsModelsCharStillreadonly(id int64) (*BaseImpor if err != nil { return nil, err } - if btmcss != nil && len(*btmcss) > 0 { - return &((*btmcss)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.char.stillreadonly not found", id) + return &((*btmcss)[0]), nil } // GetBaseImportTestsModelsCharStillreadonlys gets base_import.tests.models.char.stillreadonly existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseImportTestsModelsCharStillreadonly(criteria *Criteria) if err := c.SearchRead(BaseImportTestsModelsCharStillreadonlyModel, criteria, NewOptions().Limit(1), btmcss); err != nil { return nil, err } - if btmcss != nil && len(*btmcss) > 0 { - return &((*btmcss)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.char.stillreadonly was not found with criteria %v", criteria) + return &((*btmcss)[0]), nil } // FindBaseImportTestsModelsCharStillreadonlys finds base_import.tests.models.char.stillreadonly records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseImportTestsModelsCharStillreadonlys(criteria *Criteria, // FindBaseImportTestsModelsCharStillreadonlyIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsCharStillreadonlyIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsCharStillreadonlyModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsCharStillreadonlyModel, criteria, options) } // FindBaseImportTestsModelsCharStillreadonlyId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseImportTestsModelsCharStillreadonlyId(criteria *Criteria if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.char.stillreadonly was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_m2o.go b/base_import_tests_models_m2o.go index 5487b46d..1525ebed 100644 --- a/base_import_tests_models_m2o.go +++ b/base_import_tests_models_m2o.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsM2O represents base_import.tests.models.m2o model. type BaseImportTestsModelsM2O struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseImportTestsModelsM2Os(btmms []*BaseImportTestsModelsM for _, v := range btmms { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsM2OModel, vv) + return c.Create(BaseImportTestsModelsM2OModel, vv, nil) } // UpdateBaseImportTestsModelsM2O updates an existing base_import.tests.models.m2o record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseImportTestsModelsM2O(btmm *BaseImportTestsModelsM2O) // UpdateBaseImportTestsModelsM2Os updates existing base_import.tests.models.m2o records. // All records (represented by ids) will be updated by btmm values. func (c *Client) UpdateBaseImportTestsModelsM2Os(ids []int64, btmm *BaseImportTestsModelsM2O) error { - return c.Update(BaseImportTestsModelsM2OModel, ids, btmm) + return c.Update(BaseImportTestsModelsM2OModel, ids, btmm, nil) } // DeleteBaseImportTestsModelsM2O deletes an existing base_import.tests.models.m2o record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseImportTestsModelsM2O(id int64) (*BaseImportTestsModelsM2 if err != nil { return nil, err } - if btmms != nil && len(*btmms) > 0 { - return &((*btmms)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.m2o not found", id) + return &((*btmms)[0]), nil } // GetBaseImportTestsModelsM2Os gets base_import.tests.models.m2o existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseImportTestsModelsM2O(criteria *Criteria) (*BaseImportTe if err := c.SearchRead(BaseImportTestsModelsM2OModel, criteria, NewOptions().Limit(1), btmms); err != nil { return nil, err } - if btmms != nil && len(*btmms) > 0 { - return &((*btmms)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.m2o was not found with criteria %v", criteria) + return &((*btmms)[0]), nil } // FindBaseImportTestsModelsM2Os finds base_import.tests.models.m2o records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseImportTestsModelsM2Os(criteria *Criteria, options *Opti // FindBaseImportTestsModelsM2OIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsM2OIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsM2OModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsM2OModel, criteria, options) } // FindBaseImportTestsModelsM2OId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseImportTestsModelsM2OId(criteria *Criteria, options *Opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.m2o was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_m2o_related.go b/base_import_tests_models_m2o_related.go index d97b1fb2..0e62ea29 100644 --- a/base_import_tests_models_m2o_related.go +++ b/base_import_tests_models_m2o_related.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsM2ORelated represents base_import.tests.models.m2o.related model. type BaseImportTestsModelsM2ORelated struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseImportTestsModelsM2ORelateds(btmmrs []*BaseImportTest for _, v := range btmmrs { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsM2ORelatedModel, vv) + return c.Create(BaseImportTestsModelsM2ORelatedModel, vv, nil) } // UpdateBaseImportTestsModelsM2ORelated updates an existing base_import.tests.models.m2o.related record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseImportTestsModelsM2ORelated(btmmr *BaseImportTestsMod // UpdateBaseImportTestsModelsM2ORelateds updates existing base_import.tests.models.m2o.related records. // All records (represented by ids) will be updated by btmmr values. func (c *Client) UpdateBaseImportTestsModelsM2ORelateds(ids []int64, btmmr *BaseImportTestsModelsM2ORelated) error { - return c.Update(BaseImportTestsModelsM2ORelatedModel, ids, btmmr) + return c.Update(BaseImportTestsModelsM2ORelatedModel, ids, btmmr, nil) } // DeleteBaseImportTestsModelsM2ORelated deletes an existing base_import.tests.models.m2o.related record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseImportTestsModelsM2ORelated(id int64) (*BaseImportTestsM if err != nil { return nil, err } - if btmmrs != nil && len(*btmmrs) > 0 { - return &((*btmmrs)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.m2o.related not found", id) + return &((*btmmrs)[0]), nil } // GetBaseImportTestsModelsM2ORelateds gets base_import.tests.models.m2o.related existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseImportTestsModelsM2ORelated(criteria *Criteria) (*BaseI if err := c.SearchRead(BaseImportTestsModelsM2ORelatedModel, criteria, NewOptions().Limit(1), btmmrs); err != nil { return nil, err } - if btmmrs != nil && len(*btmmrs) > 0 { - return &((*btmmrs)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.m2o.related was not found with criteria %v", criteria) + return &((*btmmrs)[0]), nil } // FindBaseImportTestsModelsM2ORelateds finds base_import.tests.models.m2o.related records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseImportTestsModelsM2ORelateds(criteria *Criteria, option // FindBaseImportTestsModelsM2ORelatedIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsM2ORelatedIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsM2ORelatedModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsM2ORelatedModel, criteria, options) } // FindBaseImportTestsModelsM2ORelatedId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseImportTestsModelsM2ORelatedId(criteria *Criteria, optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.m2o.related was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_m2o_required.go b/base_import_tests_models_m2o_required.go index 9854c788..218e8d24 100644 --- a/base_import_tests_models_m2o_required.go +++ b/base_import_tests_models_m2o_required.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsM2ORequired represents base_import.tests.models.m2o.required model. type BaseImportTestsModelsM2ORequired struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseImportTestsModelsM2ORequireds(btmmrs []*BaseImportTes for _, v := range btmmrs { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsM2ORequiredModel, vv) + return c.Create(BaseImportTestsModelsM2ORequiredModel, vv, nil) } // UpdateBaseImportTestsModelsM2ORequired updates an existing base_import.tests.models.m2o.required record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseImportTestsModelsM2ORequired(btmmr *BaseImportTestsMo // UpdateBaseImportTestsModelsM2ORequireds updates existing base_import.tests.models.m2o.required records. // All records (represented by ids) will be updated by btmmr values. func (c *Client) UpdateBaseImportTestsModelsM2ORequireds(ids []int64, btmmr *BaseImportTestsModelsM2ORequired) error { - return c.Update(BaseImportTestsModelsM2ORequiredModel, ids, btmmr) + return c.Update(BaseImportTestsModelsM2ORequiredModel, ids, btmmr, nil) } // DeleteBaseImportTestsModelsM2ORequired deletes an existing base_import.tests.models.m2o.required record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseImportTestsModelsM2ORequired(id int64) (*BaseImportTests if err != nil { return nil, err } - if btmmrs != nil && len(*btmmrs) > 0 { - return &((*btmmrs)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.m2o.required not found", id) + return &((*btmmrs)[0]), nil } // GetBaseImportTestsModelsM2ORequireds gets base_import.tests.models.m2o.required existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseImportTestsModelsM2ORequired(criteria *Criteria) (*Base if err := c.SearchRead(BaseImportTestsModelsM2ORequiredModel, criteria, NewOptions().Limit(1), btmmrs); err != nil { return nil, err } - if btmmrs != nil && len(*btmmrs) > 0 { - return &((*btmmrs)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.m2o.required was not found with criteria %v", criteria) + return &((*btmmrs)[0]), nil } // FindBaseImportTestsModelsM2ORequireds finds base_import.tests.models.m2o.required records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseImportTestsModelsM2ORequireds(criteria *Criteria, optio // FindBaseImportTestsModelsM2ORequiredIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsM2ORequiredIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsM2ORequiredModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsM2ORequiredModel, criteria, options) } // FindBaseImportTestsModelsM2ORequiredId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseImportTestsModelsM2ORequiredId(criteria *Criteria, opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.m2o.required was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_m2o_required_related.go b/base_import_tests_models_m2o_required_related.go index 2be21bbe..9c7eb377 100644 --- a/base_import_tests_models_m2o_required_related.go +++ b/base_import_tests_models_m2o_required_related.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsM2ORequiredRelated represents base_import.tests.models.m2o.required.related model. type BaseImportTestsModelsM2ORequiredRelated struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseImportTestsModelsM2ORequiredRelateds(btmmrrs []*BaseI for _, v := range btmmrrs { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsM2ORequiredRelatedModel, vv) + return c.Create(BaseImportTestsModelsM2ORequiredRelatedModel, vv, nil) } // UpdateBaseImportTestsModelsM2ORequiredRelated updates an existing base_import.tests.models.m2o.required.related record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseImportTestsModelsM2ORequiredRelated(btmmrr *BaseImpor // UpdateBaseImportTestsModelsM2ORequiredRelateds updates existing base_import.tests.models.m2o.required.related records. // All records (represented by ids) will be updated by btmmrr values. func (c *Client) UpdateBaseImportTestsModelsM2ORequiredRelateds(ids []int64, btmmrr *BaseImportTestsModelsM2ORequiredRelated) error { - return c.Update(BaseImportTestsModelsM2ORequiredRelatedModel, ids, btmmrr) + return c.Update(BaseImportTestsModelsM2ORequiredRelatedModel, ids, btmmrr, nil) } // DeleteBaseImportTestsModelsM2ORequiredRelated deletes an existing base_import.tests.models.m2o.required.related record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseImportTestsModelsM2ORequiredRelated(id int64) (*BaseImpo if err != nil { return nil, err } - if btmmrrs != nil && len(*btmmrrs) > 0 { - return &((*btmmrrs)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.m2o.required.related not found", id) + return &((*btmmrrs)[0]), nil } // GetBaseImportTestsModelsM2ORequiredRelateds gets base_import.tests.models.m2o.required.related existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseImportTestsModelsM2ORequiredRelated(criteria *Criteria) if err := c.SearchRead(BaseImportTestsModelsM2ORequiredRelatedModel, criteria, NewOptions().Limit(1), btmmrrs); err != nil { return nil, err } - if btmmrrs != nil && len(*btmmrrs) > 0 { - return &((*btmmrrs)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.m2o.required.related was not found with criteria %v", criteria) + return &((*btmmrrs)[0]), nil } // FindBaseImportTestsModelsM2ORequiredRelateds finds base_import.tests.models.m2o.required.related records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseImportTestsModelsM2ORequiredRelateds(criteria *Criteria // FindBaseImportTestsModelsM2ORequiredRelatedIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsM2ORequiredRelatedIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsM2ORequiredRelatedModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsM2ORequiredRelatedModel, criteria, options) } // FindBaseImportTestsModelsM2ORequiredRelatedId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseImportTestsModelsM2ORequiredRelatedId(criteria *Criteri if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.m2o.required.related was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_o2m.go b/base_import_tests_models_o2m.go index a68c24d8..cd02a892 100644 --- a/base_import_tests_models_o2m.go +++ b/base_import_tests_models_o2m.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsO2M represents base_import.tests.models.o2m model. type BaseImportTestsModelsO2M struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseImportTestsModelsO2Ms(btmos []*BaseImportTestsModelsO for _, v := range btmos { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsO2MModel, vv) + return c.Create(BaseImportTestsModelsO2MModel, vv, nil) } // UpdateBaseImportTestsModelsO2M updates an existing base_import.tests.models.o2m record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseImportTestsModelsO2M(btmo *BaseImportTestsModelsO2M) // UpdateBaseImportTestsModelsO2Ms updates existing base_import.tests.models.o2m records. // All records (represented by ids) will be updated by btmo values. func (c *Client) UpdateBaseImportTestsModelsO2Ms(ids []int64, btmo *BaseImportTestsModelsO2M) error { - return c.Update(BaseImportTestsModelsO2MModel, ids, btmo) + return c.Update(BaseImportTestsModelsO2MModel, ids, btmo, nil) } // DeleteBaseImportTestsModelsO2M deletes an existing base_import.tests.models.o2m record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseImportTestsModelsO2M(id int64) (*BaseImportTestsModelsO2 if err != nil { return nil, err } - if btmos != nil && len(*btmos) > 0 { - return &((*btmos)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.o2m not found", id) + return &((*btmos)[0]), nil } // GetBaseImportTestsModelsO2Ms gets base_import.tests.models.o2m existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseImportTestsModelsO2M(criteria *Criteria) (*BaseImportTe if err := c.SearchRead(BaseImportTestsModelsO2MModel, criteria, NewOptions().Limit(1), btmos); err != nil { return nil, err } - if btmos != nil && len(*btmos) > 0 { - return &((*btmos)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.o2m was not found with criteria %v", criteria) + return &((*btmos)[0]), nil } // FindBaseImportTestsModelsO2Ms finds base_import.tests.models.o2m records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseImportTestsModelsO2Ms(criteria *Criteria, options *Opti // FindBaseImportTestsModelsO2MIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsO2MIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsO2MModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsO2MModel, criteria, options) } // FindBaseImportTestsModelsO2MId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseImportTestsModelsO2MId(criteria *Criteria, options *Opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.o2m was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_o2m_child.go b/base_import_tests_models_o2m_child.go index 15641623..9517e16e 100644 --- a/base_import_tests_models_o2m_child.go +++ b/base_import_tests_models_o2m_child.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsO2MChild represents base_import.tests.models.o2m.child model. type BaseImportTestsModelsO2MChild struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateBaseImportTestsModelsO2MChilds(btmocs []*BaseImportTestsM for _, v := range btmocs { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsO2MChildModel, vv) + return c.Create(BaseImportTestsModelsO2MChildModel, vv, nil) } // UpdateBaseImportTestsModelsO2MChild updates an existing base_import.tests.models.o2m.child record. @@ -57,7 +53,7 @@ func (c *Client) UpdateBaseImportTestsModelsO2MChild(btmoc *BaseImportTestsModel // UpdateBaseImportTestsModelsO2MChilds updates existing base_import.tests.models.o2m.child records. // All records (represented by ids) will be updated by btmoc values. func (c *Client) UpdateBaseImportTestsModelsO2MChilds(ids []int64, btmoc *BaseImportTestsModelsO2MChild) error { - return c.Update(BaseImportTestsModelsO2MChildModel, ids, btmoc) + return c.Update(BaseImportTestsModelsO2MChildModel, ids, btmoc, nil) } // DeleteBaseImportTestsModelsO2MChild deletes an existing base_import.tests.models.o2m.child record. @@ -76,10 +72,7 @@ func (c *Client) GetBaseImportTestsModelsO2MChild(id int64) (*BaseImportTestsMod if err != nil { return nil, err } - if btmocs != nil && len(*btmocs) > 0 { - return &((*btmocs)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.o2m.child not found", id) + return &((*btmocs)[0]), nil } // GetBaseImportTestsModelsO2MChilds gets base_import.tests.models.o2m.child existing records. @@ -97,10 +90,7 @@ func (c *Client) FindBaseImportTestsModelsO2MChild(criteria *Criteria) (*BaseImp if err := c.SearchRead(BaseImportTestsModelsO2MChildModel, criteria, NewOptions().Limit(1), btmocs); err != nil { return nil, err } - if btmocs != nil && len(*btmocs) > 0 { - return &((*btmocs)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.o2m.child was not found with criteria %v", criteria) + return &((*btmocs)[0]), nil } // FindBaseImportTestsModelsO2MChilds finds base_import.tests.models.o2m.child records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindBaseImportTestsModelsO2MChilds(criteria *Criteria, options // FindBaseImportTestsModelsO2MChildIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsO2MChildIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsO2MChildModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsO2MChildModel, criteria, options) } // FindBaseImportTestsModelsO2MChildId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindBaseImportTestsModelsO2MChildId(criteria *Criteria, options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.o2m.child was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_import_tests_models_preview.go b/base_import_tests_models_preview.go index 8faf7de3..39b43d96 100644 --- a/base_import_tests_models_preview.go +++ b/base_import_tests_models_preview.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseImportTestsModelsPreview represents base_import.tests.models.preview model. type BaseImportTestsModelsPreview struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateBaseImportTestsModelsPreviews(btmps []*BaseImportTestsMod for _, v := range btmps { vv = append(vv, v) } - return c.Create(BaseImportTestsModelsPreviewModel, vv) + return c.Create(BaseImportTestsModelsPreviewModel, vv, nil) } // UpdateBaseImportTestsModelsPreview updates an existing base_import.tests.models.preview record. @@ -58,7 +54,7 @@ func (c *Client) UpdateBaseImportTestsModelsPreview(btmp *BaseImportTestsModelsP // UpdateBaseImportTestsModelsPreviews updates existing base_import.tests.models.preview records. // All records (represented by ids) will be updated by btmp values. func (c *Client) UpdateBaseImportTestsModelsPreviews(ids []int64, btmp *BaseImportTestsModelsPreview) error { - return c.Update(BaseImportTestsModelsPreviewModel, ids, btmp) + return c.Update(BaseImportTestsModelsPreviewModel, ids, btmp, nil) } // DeleteBaseImportTestsModelsPreview deletes an existing base_import.tests.models.preview record. @@ -77,10 +73,7 @@ func (c *Client) GetBaseImportTestsModelsPreview(id int64) (*BaseImportTestsMode if err != nil { return nil, err } - if btmps != nil && len(*btmps) > 0 { - return &((*btmps)[0]), nil - } - return nil, fmt.Errorf("id %v of base_import.tests.models.preview not found", id) + return &((*btmps)[0]), nil } // GetBaseImportTestsModelsPreviews gets base_import.tests.models.preview existing records. @@ -98,10 +91,7 @@ func (c *Client) FindBaseImportTestsModelsPreview(criteria *Criteria) (*BaseImpo if err := c.SearchRead(BaseImportTestsModelsPreviewModel, criteria, NewOptions().Limit(1), btmps); err != nil { return nil, err } - if btmps != nil && len(*btmps) > 0 { - return &((*btmps)[0]), nil - } - return nil, fmt.Errorf("base_import.tests.models.preview was not found with criteria %v", criteria) + return &((*btmps)[0]), nil } // FindBaseImportTestsModelsPreviews finds base_import.tests.models.preview records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindBaseImportTestsModelsPreviews(criteria *Criteria, options * // FindBaseImportTestsModelsPreviewIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseImportTestsModelsPreviewIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseImportTestsModelsPreviewModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseImportTestsModelsPreviewModel, criteria, options) } // FindBaseImportTestsModelsPreviewId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindBaseImportTestsModelsPreviewId(criteria *Criteria, options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base_import.tests.models.preview was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_language_export.go b/base_language_export.go index bbdc0563..50a8c35c 100644 --- a/base_language_export.go +++ b/base_language_export.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseLanguageExport represents base.language.export model. type BaseLanguageExport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateBaseLanguageExports(bles []*BaseLanguageExport) ([]int64, for _, v := range bles { vv = append(vv, v) } - return c.Create(BaseLanguageExportModel, vv) + return c.Create(BaseLanguageExportModel, vv, nil) } // UpdateBaseLanguageExport updates an existing base.language.export record. @@ -61,7 +57,7 @@ func (c *Client) UpdateBaseLanguageExport(ble *BaseLanguageExport) error { // UpdateBaseLanguageExports updates existing base.language.export records. // All records (represented by ids) will be updated by ble values. func (c *Client) UpdateBaseLanguageExports(ids []int64, ble *BaseLanguageExport) error { - return c.Update(BaseLanguageExportModel, ids, ble) + return c.Update(BaseLanguageExportModel, ids, ble, nil) } // DeleteBaseLanguageExport deletes an existing base.language.export record. @@ -80,10 +76,7 @@ func (c *Client) GetBaseLanguageExport(id int64) (*BaseLanguageExport, error) { if err != nil { return nil, err } - if bles != nil && len(*bles) > 0 { - return &((*bles)[0]), nil - } - return nil, fmt.Errorf("id %v of base.language.export not found", id) + return &((*bles)[0]), nil } // GetBaseLanguageExports gets base.language.export existing records. @@ -101,10 +94,7 @@ func (c *Client) FindBaseLanguageExport(criteria *Criteria) (*BaseLanguageExport if err := c.SearchRead(BaseLanguageExportModel, criteria, NewOptions().Limit(1), bles); err != nil { return nil, err } - if bles != nil && len(*bles) > 0 { - return &((*bles)[0]), nil - } - return nil, fmt.Errorf("base.language.export was not found with criteria %v", criteria) + return &((*bles)[0]), nil } // FindBaseLanguageExports finds base.language.export records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindBaseLanguageExports(criteria *Criteria, options *Options) ( // FindBaseLanguageExportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseLanguageExportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseLanguageExportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseLanguageExportModel, criteria, options) } // FindBaseLanguageExportId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindBaseLanguageExportId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base.language.export was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_language_import.go b/base_language_import.go index 103ae8ce..043642b9 100644 --- a/base_language_import.go +++ b/base_language_import.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseLanguageImport represents base.language.import model. type BaseLanguageImport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateBaseLanguageImports(blis []*BaseLanguageImport) ([]int64, for _, v := range blis { vv = append(vv, v) } - return c.Create(BaseLanguageImportModel, vv) + return c.Create(BaseLanguageImportModel, vv, nil) } // UpdateBaseLanguageImport updates an existing base.language.import record. @@ -60,7 +56,7 @@ func (c *Client) UpdateBaseLanguageImport(bli *BaseLanguageImport) error { // UpdateBaseLanguageImports updates existing base.language.import records. // All records (represented by ids) will be updated by bli values. func (c *Client) UpdateBaseLanguageImports(ids []int64, bli *BaseLanguageImport) error { - return c.Update(BaseLanguageImportModel, ids, bli) + return c.Update(BaseLanguageImportModel, ids, bli, nil) } // DeleteBaseLanguageImport deletes an existing base.language.import record. @@ -79,10 +75,7 @@ func (c *Client) GetBaseLanguageImport(id int64) (*BaseLanguageImport, error) { if err != nil { return nil, err } - if blis != nil && len(*blis) > 0 { - return &((*blis)[0]), nil - } - return nil, fmt.Errorf("id %v of base.language.import not found", id) + return &((*blis)[0]), nil } // GetBaseLanguageImports gets base.language.import existing records. @@ -100,10 +93,7 @@ func (c *Client) FindBaseLanguageImport(criteria *Criteria) (*BaseLanguageImport if err := c.SearchRead(BaseLanguageImportModel, criteria, NewOptions().Limit(1), blis); err != nil { return nil, err } - if blis != nil && len(*blis) > 0 { - return &((*blis)[0]), nil - } - return nil, fmt.Errorf("base.language.import was not found with criteria %v", criteria) + return &((*blis)[0]), nil } // FindBaseLanguageImports finds base.language.import records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindBaseLanguageImports(criteria *Criteria, options *Options) ( // FindBaseLanguageImportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseLanguageImportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseLanguageImportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseLanguageImportModel, criteria, options) } // FindBaseLanguageImportId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindBaseLanguageImportId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base.language.import was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_language_install.go b/base_language_install.go index 6499c78d..e2c23a04 100644 --- a/base_language_install.go +++ b/base_language_install.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseLanguageInstall represents base.language.install model. type BaseLanguageInstall struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateBaseLanguageInstalls(blis []*BaseLanguageInstall) ([]int6 for _, v := range blis { vv = append(vv, v) } - return c.Create(BaseLanguageInstallModel, vv) + return c.Create(BaseLanguageInstallModel, vv, nil) } // UpdateBaseLanguageInstall updates an existing base.language.install record. @@ -58,7 +54,7 @@ func (c *Client) UpdateBaseLanguageInstall(bli *BaseLanguageInstall) error { // UpdateBaseLanguageInstalls updates existing base.language.install records. // All records (represented by ids) will be updated by bli values. func (c *Client) UpdateBaseLanguageInstalls(ids []int64, bli *BaseLanguageInstall) error { - return c.Update(BaseLanguageInstallModel, ids, bli) + return c.Update(BaseLanguageInstallModel, ids, bli, nil) } // DeleteBaseLanguageInstall deletes an existing base.language.install record. @@ -77,10 +73,7 @@ func (c *Client) GetBaseLanguageInstall(id int64) (*BaseLanguageInstall, error) if err != nil { return nil, err } - if blis != nil && len(*blis) > 0 { - return &((*blis)[0]), nil - } - return nil, fmt.Errorf("id %v of base.language.install not found", id) + return &((*blis)[0]), nil } // GetBaseLanguageInstalls gets base.language.install existing records. @@ -98,10 +91,7 @@ func (c *Client) FindBaseLanguageInstall(criteria *Criteria) (*BaseLanguageInsta if err := c.SearchRead(BaseLanguageInstallModel, criteria, NewOptions().Limit(1), blis); err != nil { return nil, err } - if blis != nil && len(*blis) > 0 { - return &((*blis)[0]), nil - } - return nil, fmt.Errorf("base.language.install was not found with criteria %v", criteria) + return &((*blis)[0]), nil } // FindBaseLanguageInstalls finds base.language.install records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindBaseLanguageInstalls(criteria *Criteria, options *Options) // FindBaseLanguageInstallIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseLanguageInstallIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseLanguageInstallModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseLanguageInstallModel, criteria, options) } // FindBaseLanguageInstallId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindBaseLanguageInstallId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base.language.install was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_module_uninstall.go b/base_module_uninstall.go index 708f1268..ee7df4e7 100644 --- a/base_module_uninstall.go +++ b/base_module_uninstall.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseModuleUninstall represents base.module.uninstall model. type BaseModuleUninstall struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateBaseModuleUninstalls(bmus []*BaseModuleUninstall) ([]int6 for _, v := range bmus { vv = append(vv, v) } - return c.Create(BaseModuleUninstallModel, vv) + return c.Create(BaseModuleUninstallModel, vv, nil) } // UpdateBaseModuleUninstall updates an existing base.module.uninstall record. @@ -59,7 +55,7 @@ func (c *Client) UpdateBaseModuleUninstall(bmu *BaseModuleUninstall) error { // UpdateBaseModuleUninstalls updates existing base.module.uninstall records. // All records (represented by ids) will be updated by bmu values. func (c *Client) UpdateBaseModuleUninstalls(ids []int64, bmu *BaseModuleUninstall) error { - return c.Update(BaseModuleUninstallModel, ids, bmu) + return c.Update(BaseModuleUninstallModel, ids, bmu, nil) } // DeleteBaseModuleUninstall deletes an existing base.module.uninstall record. @@ -78,10 +74,7 @@ func (c *Client) GetBaseModuleUninstall(id int64) (*BaseModuleUninstall, error) if err != nil { return nil, err } - if bmus != nil && len(*bmus) > 0 { - return &((*bmus)[0]), nil - } - return nil, fmt.Errorf("id %v of base.module.uninstall not found", id) + return &((*bmus)[0]), nil } // GetBaseModuleUninstalls gets base.module.uninstall existing records. @@ -99,10 +92,7 @@ func (c *Client) FindBaseModuleUninstall(criteria *Criteria) (*BaseModuleUninsta if err := c.SearchRead(BaseModuleUninstallModel, criteria, NewOptions().Limit(1), bmus); err != nil { return nil, err } - if bmus != nil && len(*bmus) > 0 { - return &((*bmus)[0]), nil - } - return nil, fmt.Errorf("base.module.uninstall was not found with criteria %v", criteria) + return &((*bmus)[0]), nil } // FindBaseModuleUninstalls finds base.module.uninstall records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindBaseModuleUninstalls(criteria *Criteria, options *Options) // FindBaseModuleUninstallIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseModuleUninstallIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseModuleUninstallModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseModuleUninstallModel, criteria, options) } // FindBaseModuleUninstallId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindBaseModuleUninstallId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base.module.uninstall was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_module_update.go b/base_module_update.go index 637d9544..5526020d 100644 --- a/base_module_update.go +++ b/base_module_update.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseModuleUpdate represents base.module.update model. type BaseModuleUpdate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateBaseModuleUpdates(bmus []*BaseModuleUpdate) ([]int64, err for _, v := range bmus { vv = append(vv, v) } - return c.Create(BaseModuleUpdateModel, vv) + return c.Create(BaseModuleUpdateModel, vv, nil) } // UpdateBaseModuleUpdate updates an existing base.module.update record. @@ -58,7 +54,7 @@ func (c *Client) UpdateBaseModuleUpdate(bmu *BaseModuleUpdate) error { // UpdateBaseModuleUpdates updates existing base.module.update records. // All records (represented by ids) will be updated by bmu values. func (c *Client) UpdateBaseModuleUpdates(ids []int64, bmu *BaseModuleUpdate) error { - return c.Update(BaseModuleUpdateModel, ids, bmu) + return c.Update(BaseModuleUpdateModel, ids, bmu, nil) } // DeleteBaseModuleUpdate deletes an existing base.module.update record. @@ -77,10 +73,7 @@ func (c *Client) GetBaseModuleUpdate(id int64) (*BaseModuleUpdate, error) { if err != nil { return nil, err } - if bmus != nil && len(*bmus) > 0 { - return &((*bmus)[0]), nil - } - return nil, fmt.Errorf("id %v of base.module.update not found", id) + return &((*bmus)[0]), nil } // GetBaseModuleUpdates gets base.module.update existing records. @@ -98,10 +91,7 @@ func (c *Client) FindBaseModuleUpdate(criteria *Criteria) (*BaseModuleUpdate, er if err := c.SearchRead(BaseModuleUpdateModel, criteria, NewOptions().Limit(1), bmus); err != nil { return nil, err } - if bmus != nil && len(*bmus) > 0 { - return &((*bmus)[0]), nil - } - return nil, fmt.Errorf("base.module.update was not found with criteria %v", criteria) + return &((*bmus)[0]), nil } // FindBaseModuleUpdates finds base.module.update records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindBaseModuleUpdates(criteria *Criteria, options *Options) (*B // FindBaseModuleUpdateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseModuleUpdateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseModuleUpdateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseModuleUpdateModel, criteria, options) } // FindBaseModuleUpdateId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindBaseModuleUpdateId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base.module.update was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_module_upgrade.go b/base_module_upgrade.go index 588a6cce..2668548c 100644 --- a/base_module_upgrade.go +++ b/base_module_upgrade.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseModuleUpgrade represents base.module.upgrade model. type BaseModuleUpgrade struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseModuleUpgrades(bmus []*BaseModuleUpgrade) ([]int64, e for _, v := range bmus { vv = append(vv, v) } - return c.Create(BaseModuleUpgradeModel, vv) + return c.Create(BaseModuleUpgradeModel, vv, nil) } // UpdateBaseModuleUpgrade updates an existing base.module.upgrade record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseModuleUpgrade(bmu *BaseModuleUpgrade) error { // UpdateBaseModuleUpgrades updates existing base.module.upgrade records. // All records (represented by ids) will be updated by bmu values. func (c *Client) UpdateBaseModuleUpgrades(ids []int64, bmu *BaseModuleUpgrade) error { - return c.Update(BaseModuleUpgradeModel, ids, bmu) + return c.Update(BaseModuleUpgradeModel, ids, bmu, nil) } // DeleteBaseModuleUpgrade deletes an existing base.module.upgrade record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseModuleUpgrade(id int64) (*BaseModuleUpgrade, error) { if err != nil { return nil, err } - if bmus != nil && len(*bmus) > 0 { - return &((*bmus)[0]), nil - } - return nil, fmt.Errorf("id %v of base.module.upgrade not found", id) + return &((*bmus)[0]), nil } // GetBaseModuleUpgrades gets base.module.upgrade existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseModuleUpgrade(criteria *Criteria) (*BaseModuleUpgrade, if err := c.SearchRead(BaseModuleUpgradeModel, criteria, NewOptions().Limit(1), bmus); err != nil { return nil, err } - if bmus != nil && len(*bmus) > 0 { - return &((*bmus)[0]), nil - } - return nil, fmt.Errorf("base.module.upgrade was not found with criteria %v", criteria) + return &((*bmus)[0]), nil } // FindBaseModuleUpgrades finds base.module.upgrade records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseModuleUpgrades(criteria *Criteria, options *Options) (* // FindBaseModuleUpgradeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseModuleUpgradeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseModuleUpgradeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseModuleUpgradeModel, criteria, options) } // FindBaseModuleUpgradeId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseModuleUpgradeId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base.module.upgrade was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_partner_merge_automatic_wizard.go b/base_partner_merge_automatic_wizard.go index 867665a9..d9fd0de1 100644 --- a/base_partner_merge_automatic_wizard.go +++ b/base_partner_merge_automatic_wizard.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BasePartnerMergeAutomaticWizard represents base.partner.merge.automatic.wizard model. type BasePartnerMergeAutomaticWizard struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -58,7 +54,7 @@ func (c *Client) CreateBasePartnerMergeAutomaticWizards(bpmaws []*BasePartnerMer for _, v := range bpmaws { vv = append(vv, v) } - return c.Create(BasePartnerMergeAutomaticWizardModel, vv) + return c.Create(BasePartnerMergeAutomaticWizardModel, vv, nil) } // UpdateBasePartnerMergeAutomaticWizard updates an existing base.partner.merge.automatic.wizard record. @@ -69,7 +65,7 @@ func (c *Client) UpdateBasePartnerMergeAutomaticWizard(bpmaw *BasePartnerMergeAu // UpdateBasePartnerMergeAutomaticWizards updates existing base.partner.merge.automatic.wizard records. // All records (represented by ids) will be updated by bpmaw values. func (c *Client) UpdateBasePartnerMergeAutomaticWizards(ids []int64, bpmaw *BasePartnerMergeAutomaticWizard) error { - return c.Update(BasePartnerMergeAutomaticWizardModel, ids, bpmaw) + return c.Update(BasePartnerMergeAutomaticWizardModel, ids, bpmaw, nil) } // DeleteBasePartnerMergeAutomaticWizard deletes an existing base.partner.merge.automatic.wizard record. @@ -88,10 +84,7 @@ func (c *Client) GetBasePartnerMergeAutomaticWizard(id int64) (*BasePartnerMerge if err != nil { return nil, err } - if bpmaws != nil && len(*bpmaws) > 0 { - return &((*bpmaws)[0]), nil - } - return nil, fmt.Errorf("id %v of base.partner.merge.automatic.wizard not found", id) + return &((*bpmaws)[0]), nil } // GetBasePartnerMergeAutomaticWizards gets base.partner.merge.automatic.wizard existing records. @@ -109,10 +102,7 @@ func (c *Client) FindBasePartnerMergeAutomaticWizard(criteria *Criteria) (*BaseP if err := c.SearchRead(BasePartnerMergeAutomaticWizardModel, criteria, NewOptions().Limit(1), bpmaws); err != nil { return nil, err } - if bpmaws != nil && len(*bpmaws) > 0 { - return &((*bpmaws)[0]), nil - } - return nil, fmt.Errorf("base.partner.merge.automatic.wizard was not found with criteria %v", criteria) + return &((*bpmaws)[0]), nil } // FindBasePartnerMergeAutomaticWizards finds base.partner.merge.automatic.wizard records by querying it @@ -128,11 +118,7 @@ func (c *Client) FindBasePartnerMergeAutomaticWizards(criteria *Criteria, option // FindBasePartnerMergeAutomaticWizardIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBasePartnerMergeAutomaticWizardIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BasePartnerMergeAutomaticWizardModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BasePartnerMergeAutomaticWizardModel, criteria, options) } // FindBasePartnerMergeAutomaticWizardId finds record id by querying it with criteria. @@ -141,8 +127,5 @@ func (c *Client) FindBasePartnerMergeAutomaticWizardId(criteria *Criteria, optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base.partner.merge.automatic.wizard was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_partner_merge_line.go b/base_partner_merge_line.go index fa5cb19a..e5cf6636 100644 --- a/base_partner_merge_line.go +++ b/base_partner_merge_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BasePartnerMergeLine represents base.partner.merge.line model. type BasePartnerMergeLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateBasePartnerMergeLines(bpmls []*BasePartnerMergeLine) ([]i for _, v := range bpmls { vv = append(vv, v) } - return c.Create(BasePartnerMergeLineModel, vv) + return c.Create(BasePartnerMergeLineModel, vv, nil) } // UpdateBasePartnerMergeLine updates an existing base.partner.merge.line record. @@ -58,7 +54,7 @@ func (c *Client) UpdateBasePartnerMergeLine(bpml *BasePartnerMergeLine) error { // UpdateBasePartnerMergeLines updates existing base.partner.merge.line records. // All records (represented by ids) will be updated by bpml values. func (c *Client) UpdateBasePartnerMergeLines(ids []int64, bpml *BasePartnerMergeLine) error { - return c.Update(BasePartnerMergeLineModel, ids, bpml) + return c.Update(BasePartnerMergeLineModel, ids, bpml, nil) } // DeleteBasePartnerMergeLine deletes an existing base.partner.merge.line record. @@ -77,10 +73,7 @@ func (c *Client) GetBasePartnerMergeLine(id int64) (*BasePartnerMergeLine, error if err != nil { return nil, err } - if bpmls != nil && len(*bpmls) > 0 { - return &((*bpmls)[0]), nil - } - return nil, fmt.Errorf("id %v of base.partner.merge.line not found", id) + return &((*bpmls)[0]), nil } // GetBasePartnerMergeLines gets base.partner.merge.line existing records. @@ -98,10 +91,7 @@ func (c *Client) FindBasePartnerMergeLine(criteria *Criteria) (*BasePartnerMerge if err := c.SearchRead(BasePartnerMergeLineModel, criteria, NewOptions().Limit(1), bpmls); err != nil { return nil, err } - if bpmls != nil && len(*bpmls) > 0 { - return &((*bpmls)[0]), nil - } - return nil, fmt.Errorf("base.partner.merge.line was not found with criteria %v", criteria) + return &((*bpmls)[0]), nil } // FindBasePartnerMergeLines finds base.partner.merge.line records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindBasePartnerMergeLines(criteria *Criteria, options *Options) // FindBasePartnerMergeLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBasePartnerMergeLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BasePartnerMergeLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BasePartnerMergeLineModel, criteria, options) } // FindBasePartnerMergeLineId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindBasePartnerMergeLineId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base.partner.merge.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/base_update_translations.go b/base_update_translations.go index 717b1d53..69c6fc0d 100644 --- a/base_update_translations.go +++ b/base_update_translations.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BaseUpdateTranslations represents base.update.translations model. type BaseUpdateTranslations struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateBaseUpdateTranslationss(buts []*BaseUpdateTranslations) ( for _, v := range buts { vv = append(vv, v) } - return c.Create(BaseUpdateTranslationsModel, vv) + return c.Create(BaseUpdateTranslationsModel, vv, nil) } // UpdateBaseUpdateTranslations updates an existing base.update.translations record. @@ -56,7 +52,7 @@ func (c *Client) UpdateBaseUpdateTranslations(but *BaseUpdateTranslations) error // UpdateBaseUpdateTranslationss updates existing base.update.translations records. // All records (represented by ids) will be updated by but values. func (c *Client) UpdateBaseUpdateTranslationss(ids []int64, but *BaseUpdateTranslations) error { - return c.Update(BaseUpdateTranslationsModel, ids, but) + return c.Update(BaseUpdateTranslationsModel, ids, but, nil) } // DeleteBaseUpdateTranslations deletes an existing base.update.translations record. @@ -75,10 +71,7 @@ func (c *Client) GetBaseUpdateTranslations(id int64) (*BaseUpdateTranslations, e if err != nil { return nil, err } - if buts != nil && len(*buts) > 0 { - return &((*buts)[0]), nil - } - return nil, fmt.Errorf("id %v of base.update.translations not found", id) + return &((*buts)[0]), nil } // GetBaseUpdateTranslationss gets base.update.translations existing records. @@ -96,10 +89,7 @@ func (c *Client) FindBaseUpdateTranslations(criteria *Criteria) (*BaseUpdateTran if err := c.SearchRead(BaseUpdateTranslationsModel, criteria, NewOptions().Limit(1), buts); err != nil { return nil, err } - if buts != nil && len(*buts) > 0 { - return &((*buts)[0]), nil - } - return nil, fmt.Errorf("base.update.translations was not found with criteria %v", criteria) + return &((*buts)[0]), nil } // FindBaseUpdateTranslationss finds base.update.translations records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindBaseUpdateTranslationss(criteria *Criteria, options *Option // FindBaseUpdateTranslationsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBaseUpdateTranslationsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BaseUpdateTranslationsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BaseUpdateTranslationsModel, criteria, options) } // FindBaseUpdateTranslationsId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindBaseUpdateTranslationsId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("base.update.translations was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/board_board.go b/board_board.go index 6b94e9ba..e141691c 100644 --- a/board_board.go +++ b/board_board.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BoardBoard represents board.board model. type BoardBoard struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateBoardBoards(bbs []*BoardBoard) ([]int64, error) { for _, v := range bbs { vv = append(vv, v) } - return c.Create(BoardBoardModel, vv) + return c.Create(BoardBoardModel, vv, nil) } // UpdateBoardBoard updates an existing board.board record. @@ -51,7 +47,7 @@ func (c *Client) UpdateBoardBoard(bb *BoardBoard) error { // UpdateBoardBoards updates existing board.board records. // All records (represented by ids) will be updated by bb values. func (c *Client) UpdateBoardBoards(ids []int64, bb *BoardBoard) error { - return c.Update(BoardBoardModel, ids, bb) + return c.Update(BoardBoardModel, ids, bb, nil) } // DeleteBoardBoard deletes an existing board.board record. @@ -70,10 +66,7 @@ func (c *Client) GetBoardBoard(id int64) (*BoardBoard, error) { if err != nil { return nil, err } - if bbs != nil && len(*bbs) > 0 { - return &((*bbs)[0]), nil - } - return nil, fmt.Errorf("id %v of board.board not found", id) + return &((*bbs)[0]), nil } // GetBoardBoards gets board.board existing records. @@ -91,10 +84,7 @@ func (c *Client) FindBoardBoard(criteria *Criteria) (*BoardBoard, error) { if err := c.SearchRead(BoardBoardModel, criteria, NewOptions().Limit(1), bbs); err != nil { return nil, err } - if bbs != nil && len(*bbs) > 0 { - return &((*bbs)[0]), nil - } - return nil, fmt.Errorf("board.board was not found with criteria %v", criteria) + return &((*bbs)[0]), nil } // FindBoardBoards finds board.board records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindBoardBoards(criteria *Criteria, options *Options) (*BoardBo // FindBoardBoardIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBoardBoardIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BoardBoardModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BoardBoardModel, criteria, options) } // FindBoardBoardId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindBoardBoardId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("board.board was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/bus_bus.go b/bus_bus.go index 808a7727..49c3968c 100644 --- a/bus_bus.go +++ b/bus_bus.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BusBus represents bus.bus model. type BusBus struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateBusBuss(bbs []*BusBus) ([]int64, error) { for _, v := range bbs { vv = append(vv, v) } - return c.Create(BusBusModel, vv) + return c.Create(BusBusModel, vv, nil) } // UpdateBusBus updates an existing bus.bus record. @@ -57,7 +53,7 @@ func (c *Client) UpdateBusBus(bb *BusBus) error { // UpdateBusBuss updates existing bus.bus records. // All records (represented by ids) will be updated by bb values. func (c *Client) UpdateBusBuss(ids []int64, bb *BusBus) error { - return c.Update(BusBusModel, ids, bb) + return c.Update(BusBusModel, ids, bb, nil) } // DeleteBusBus deletes an existing bus.bus record. @@ -76,10 +72,7 @@ func (c *Client) GetBusBus(id int64) (*BusBus, error) { if err != nil { return nil, err } - if bbs != nil && len(*bbs) > 0 { - return &((*bbs)[0]), nil - } - return nil, fmt.Errorf("id %v of bus.bus not found", id) + return &((*bbs)[0]), nil } // GetBusBuss gets bus.bus existing records. @@ -97,10 +90,7 @@ func (c *Client) FindBusBus(criteria *Criteria) (*BusBus, error) { if err := c.SearchRead(BusBusModel, criteria, NewOptions().Limit(1), bbs); err != nil { return nil, err } - if bbs != nil && len(*bbs) > 0 { - return &((*bbs)[0]), nil - } - return nil, fmt.Errorf("bus.bus was not found with criteria %v", criteria) + return &((*bbs)[0]), nil } // FindBusBuss finds bus.bus records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindBusBuss(criteria *Criteria, options *Options) (*BusBuss, er // FindBusBusIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBusBusIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BusBusModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BusBusModel, criteria, options) } // FindBusBusId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindBusBusId(criteria *Criteria, options *Options) (int64, erro if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("bus.bus was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/bus_presence.go b/bus_presence.go index 6d15f244..1af79eb9 100644 --- a/bus_presence.go +++ b/bus_presence.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // BusPresence represents bus.presence model. type BusPresence struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -44,7 +40,7 @@ func (c *Client) CreateBusPresences(bps []*BusPresence) ([]int64, error) { for _, v := range bps { vv = append(vv, v) } - return c.Create(BusPresenceModel, vv) + return c.Create(BusPresenceModel, vv, nil) } // UpdateBusPresence updates an existing bus.presence record. @@ -55,7 +51,7 @@ func (c *Client) UpdateBusPresence(bp *BusPresence) error { // UpdateBusPresences updates existing bus.presence records. // All records (represented by ids) will be updated by bp values. func (c *Client) UpdateBusPresences(ids []int64, bp *BusPresence) error { - return c.Update(BusPresenceModel, ids, bp) + return c.Update(BusPresenceModel, ids, bp, nil) } // DeleteBusPresence deletes an existing bus.presence record. @@ -74,10 +70,7 @@ func (c *Client) GetBusPresence(id int64) (*BusPresence, error) { if err != nil { return nil, err } - if bps != nil && len(*bps) > 0 { - return &((*bps)[0]), nil - } - return nil, fmt.Errorf("id %v of bus.presence not found", id) + return &((*bps)[0]), nil } // GetBusPresences gets bus.presence existing records. @@ -95,10 +88,7 @@ func (c *Client) FindBusPresence(criteria *Criteria) (*BusPresence, error) { if err := c.SearchRead(BusPresenceModel, criteria, NewOptions().Limit(1), bps); err != nil { return nil, err } - if bps != nil && len(*bps) > 0 { - return &((*bps)[0]), nil - } - return nil, fmt.Errorf("bus.presence was not found with criteria %v", criteria) + return &((*bps)[0]), nil } // FindBusPresences finds bus.presence records by querying it @@ -114,11 +104,7 @@ func (c *Client) FindBusPresences(criteria *Criteria, options *Options) (*BusPre // FindBusPresenceIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindBusPresenceIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(BusPresenceModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(BusPresenceModel, criteria, options) } // FindBusPresenceId finds record id by querying it with criteria. @@ -127,8 +113,5 @@ func (c *Client) FindBusPresenceId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("bus.presence was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/calendar_alarm.go b/calendar_alarm.go index 76315798..036a774f 100644 --- a/calendar_alarm.go +++ b/calendar_alarm.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CalendarAlarm represents calendar.alarm model. type CalendarAlarm struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateCalendarAlarms(cas []*CalendarAlarm) ([]int64, error) { for _, v := range cas { vv = append(vv, v) } - return c.Create(CalendarAlarmModel, vv) + return c.Create(CalendarAlarmModel, vv, nil) } // UpdateCalendarAlarm updates an existing calendar.alarm record. @@ -60,7 +56,7 @@ func (c *Client) UpdateCalendarAlarm(ca *CalendarAlarm) error { // UpdateCalendarAlarms updates existing calendar.alarm records. // All records (represented by ids) will be updated by ca values. func (c *Client) UpdateCalendarAlarms(ids []int64, ca *CalendarAlarm) error { - return c.Update(CalendarAlarmModel, ids, ca) + return c.Update(CalendarAlarmModel, ids, ca, nil) } // DeleteCalendarAlarm deletes an existing calendar.alarm record. @@ -79,10 +75,7 @@ func (c *Client) GetCalendarAlarm(id int64) (*CalendarAlarm, error) { if err != nil { return nil, err } - if cas != nil && len(*cas) > 0 { - return &((*cas)[0]), nil - } - return nil, fmt.Errorf("id %v of calendar.alarm not found", id) + return &((*cas)[0]), nil } // GetCalendarAlarms gets calendar.alarm existing records. @@ -100,10 +93,7 @@ func (c *Client) FindCalendarAlarm(criteria *Criteria) (*CalendarAlarm, error) { if err := c.SearchRead(CalendarAlarmModel, criteria, NewOptions().Limit(1), cas); err != nil { return nil, err } - if cas != nil && len(*cas) > 0 { - return &((*cas)[0]), nil - } - return nil, fmt.Errorf("calendar.alarm was not found with criteria %v", criteria) + return &((*cas)[0]), nil } // FindCalendarAlarms finds calendar.alarm records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindCalendarAlarms(criteria *Criteria, options *Options) (*Cale // FindCalendarAlarmIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCalendarAlarmIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CalendarAlarmModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CalendarAlarmModel, criteria, options) } // FindCalendarAlarmId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindCalendarAlarmId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("calendar.alarm was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/calendar_alarm_manager.go b/calendar_alarm_manager.go index 1fd3baf2..5a59c0f7 100644 --- a/calendar_alarm_manager.go +++ b/calendar_alarm_manager.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CalendarAlarmManager represents calendar.alarm_manager model. type CalendarAlarmManager struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateCalendarAlarmManagers(cas []*CalendarAlarmManager) ([]int for _, v := range cas { vv = append(vv, v) } - return c.Create(CalendarAlarmManagerModel, vv) + return c.Create(CalendarAlarmManagerModel, vv, nil) } // UpdateCalendarAlarmManager updates an existing calendar.alarm_manager record. @@ -51,7 +47,7 @@ func (c *Client) UpdateCalendarAlarmManager(ca *CalendarAlarmManager) error { // UpdateCalendarAlarmManagers updates existing calendar.alarm_manager records. // All records (represented by ids) will be updated by ca values. func (c *Client) UpdateCalendarAlarmManagers(ids []int64, ca *CalendarAlarmManager) error { - return c.Update(CalendarAlarmManagerModel, ids, ca) + return c.Update(CalendarAlarmManagerModel, ids, ca, nil) } // DeleteCalendarAlarmManager deletes an existing calendar.alarm_manager record. @@ -70,10 +66,7 @@ func (c *Client) GetCalendarAlarmManager(id int64) (*CalendarAlarmManager, error if err != nil { return nil, err } - if cas != nil && len(*cas) > 0 { - return &((*cas)[0]), nil - } - return nil, fmt.Errorf("id %v of calendar.alarm_manager not found", id) + return &((*cas)[0]), nil } // GetCalendarAlarmManagers gets calendar.alarm_manager existing records. @@ -91,10 +84,7 @@ func (c *Client) FindCalendarAlarmManager(criteria *Criteria) (*CalendarAlarmMan if err := c.SearchRead(CalendarAlarmManagerModel, criteria, NewOptions().Limit(1), cas); err != nil { return nil, err } - if cas != nil && len(*cas) > 0 { - return &((*cas)[0]), nil - } - return nil, fmt.Errorf("calendar.alarm_manager was not found with criteria %v", criteria) + return &((*cas)[0]), nil } // FindCalendarAlarmManagers finds calendar.alarm_manager records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindCalendarAlarmManagers(criteria *Criteria, options *Options) // FindCalendarAlarmManagerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCalendarAlarmManagerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CalendarAlarmManagerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CalendarAlarmManagerModel, criteria, options) } // FindCalendarAlarmManagerId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindCalendarAlarmManagerId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("calendar.alarm_manager was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/calendar_attendee.go b/calendar_attendee.go index fbc0c56d..7125d12e 100644 --- a/calendar_attendee.go +++ b/calendar_attendee.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CalendarAttendee represents calendar.attendee model. type CalendarAttendee struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -51,7 +47,7 @@ func (c *Client) CreateCalendarAttendees(cas []*CalendarAttendee) ([]int64, erro for _, v := range cas { vv = append(vv, v) } - return c.Create(CalendarAttendeeModel, vv) + return c.Create(CalendarAttendeeModel, vv, nil) } // UpdateCalendarAttendee updates an existing calendar.attendee record. @@ -62,7 +58,7 @@ func (c *Client) UpdateCalendarAttendee(ca *CalendarAttendee) error { // UpdateCalendarAttendees updates existing calendar.attendee records. // All records (represented by ids) will be updated by ca values. func (c *Client) UpdateCalendarAttendees(ids []int64, ca *CalendarAttendee) error { - return c.Update(CalendarAttendeeModel, ids, ca) + return c.Update(CalendarAttendeeModel, ids, ca, nil) } // DeleteCalendarAttendee deletes an existing calendar.attendee record. @@ -81,10 +77,7 @@ func (c *Client) GetCalendarAttendee(id int64) (*CalendarAttendee, error) { if err != nil { return nil, err } - if cas != nil && len(*cas) > 0 { - return &((*cas)[0]), nil - } - return nil, fmt.Errorf("id %v of calendar.attendee not found", id) + return &((*cas)[0]), nil } // GetCalendarAttendees gets calendar.attendee existing records. @@ -102,10 +95,7 @@ func (c *Client) FindCalendarAttendee(criteria *Criteria) (*CalendarAttendee, er if err := c.SearchRead(CalendarAttendeeModel, criteria, NewOptions().Limit(1), cas); err != nil { return nil, err } - if cas != nil && len(*cas) > 0 { - return &((*cas)[0]), nil - } - return nil, fmt.Errorf("calendar.attendee was not found with criteria %v", criteria) + return &((*cas)[0]), nil } // FindCalendarAttendees finds calendar.attendee records by querying it @@ -121,11 +111,7 @@ func (c *Client) FindCalendarAttendees(criteria *Criteria, options *Options) (*C // FindCalendarAttendeeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCalendarAttendeeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CalendarAttendeeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CalendarAttendeeModel, criteria, options) } // FindCalendarAttendeeId finds record id by querying it with criteria. @@ -134,8 +120,5 @@ func (c *Client) FindCalendarAttendeeId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("calendar.attendee was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/calendar_contacts.go b/calendar_contacts.go index 6d8a3a8e..799b1cbb 100644 --- a/calendar_contacts.go +++ b/calendar_contacts.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CalendarContacts represents calendar.contacts model. type CalendarContacts struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateCalendarContactss(ccs []*CalendarContacts) ([]int64, erro for _, v := range ccs { vv = append(vv, v) } - return c.Create(CalendarContactsModel, vv) + return c.Create(CalendarContactsModel, vv, nil) } // UpdateCalendarContacts updates an existing calendar.contacts record. @@ -58,7 +54,7 @@ func (c *Client) UpdateCalendarContacts(cc *CalendarContacts) error { // UpdateCalendarContactss updates existing calendar.contacts records. // All records (represented by ids) will be updated by cc values. func (c *Client) UpdateCalendarContactss(ids []int64, cc *CalendarContacts) error { - return c.Update(CalendarContactsModel, ids, cc) + return c.Update(CalendarContactsModel, ids, cc, nil) } // DeleteCalendarContacts deletes an existing calendar.contacts record. @@ -77,10 +73,7 @@ func (c *Client) GetCalendarContacts(id int64) (*CalendarContacts, error) { if err != nil { return nil, err } - if ccs != nil && len(*ccs) > 0 { - return &((*ccs)[0]), nil - } - return nil, fmt.Errorf("id %v of calendar.contacts not found", id) + return &((*ccs)[0]), nil } // GetCalendarContactss gets calendar.contacts existing records. @@ -98,10 +91,7 @@ func (c *Client) FindCalendarContacts(criteria *Criteria) (*CalendarContacts, er if err := c.SearchRead(CalendarContactsModel, criteria, NewOptions().Limit(1), ccs); err != nil { return nil, err } - if ccs != nil && len(*ccs) > 0 { - return &((*ccs)[0]), nil - } - return nil, fmt.Errorf("calendar.contacts was not found with criteria %v", criteria) + return &((*ccs)[0]), nil } // FindCalendarContactss finds calendar.contacts records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindCalendarContactss(criteria *Criteria, options *Options) (*C // FindCalendarContactsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCalendarContactsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CalendarContactsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CalendarContactsModel, criteria, options) } // FindCalendarContactsId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindCalendarContactsId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("calendar.contacts was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/calendar_event.go b/calendar_event.go index 31591396..dd696dac 100644 --- a/calendar_event.go +++ b/calendar_event.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CalendarEvent represents calendar.event model. type CalendarEvent struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -106,7 +102,7 @@ func (c *Client) CreateCalendarEvents(ces []*CalendarEvent) ([]int64, error) { for _, v := range ces { vv = append(vv, v) } - return c.Create(CalendarEventModel, vv) + return c.Create(CalendarEventModel, vv, nil) } // UpdateCalendarEvent updates an existing calendar.event record. @@ -117,7 +113,7 @@ func (c *Client) UpdateCalendarEvent(ce *CalendarEvent) error { // UpdateCalendarEvents updates existing calendar.event records. // All records (represented by ids) will be updated by ce values. func (c *Client) UpdateCalendarEvents(ids []int64, ce *CalendarEvent) error { - return c.Update(CalendarEventModel, ids, ce) + return c.Update(CalendarEventModel, ids, ce, nil) } // DeleteCalendarEvent deletes an existing calendar.event record. @@ -136,10 +132,7 @@ func (c *Client) GetCalendarEvent(id int64) (*CalendarEvent, error) { if err != nil { return nil, err } - if ces != nil && len(*ces) > 0 { - return &((*ces)[0]), nil - } - return nil, fmt.Errorf("id %v of calendar.event not found", id) + return &((*ces)[0]), nil } // GetCalendarEvents gets calendar.event existing records. @@ -157,10 +150,7 @@ func (c *Client) FindCalendarEvent(criteria *Criteria) (*CalendarEvent, error) { if err := c.SearchRead(CalendarEventModel, criteria, NewOptions().Limit(1), ces); err != nil { return nil, err } - if ces != nil && len(*ces) > 0 { - return &((*ces)[0]), nil - } - return nil, fmt.Errorf("calendar.event was not found with criteria %v", criteria) + return &((*ces)[0]), nil } // FindCalendarEvents finds calendar.event records by querying it @@ -176,11 +166,7 @@ func (c *Client) FindCalendarEvents(criteria *Criteria, options *Options) (*Cale // FindCalendarEventIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCalendarEventIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CalendarEventModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CalendarEventModel, criteria, options) } // FindCalendarEventId finds record id by querying it with criteria. @@ -189,8 +175,5 @@ func (c *Client) FindCalendarEventId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("calendar.event was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/calendar_event_type.go b/calendar_event_type.go index 83154d05..416b654b 100644 --- a/calendar_event_type.go +++ b/calendar_event_type.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CalendarEventType represents calendar.event.type model. type CalendarEventType struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateCalendarEventTypes(cets []*CalendarEventType) ([]int64, e for _, v := range cets { vv = append(vv, v) } - return c.Create(CalendarEventTypeModel, vv) + return c.Create(CalendarEventTypeModel, vv, nil) } // UpdateCalendarEventType updates an existing calendar.event.type record. @@ -56,7 +52,7 @@ func (c *Client) UpdateCalendarEventType(cet *CalendarEventType) error { // UpdateCalendarEventTypes updates existing calendar.event.type records. // All records (represented by ids) will be updated by cet values. func (c *Client) UpdateCalendarEventTypes(ids []int64, cet *CalendarEventType) error { - return c.Update(CalendarEventTypeModel, ids, cet) + return c.Update(CalendarEventTypeModel, ids, cet, nil) } // DeleteCalendarEventType deletes an existing calendar.event.type record. @@ -75,10 +71,7 @@ func (c *Client) GetCalendarEventType(id int64) (*CalendarEventType, error) { if err != nil { return nil, err } - if cets != nil && len(*cets) > 0 { - return &((*cets)[0]), nil - } - return nil, fmt.Errorf("id %v of calendar.event.type not found", id) + return &((*cets)[0]), nil } // GetCalendarEventTypes gets calendar.event.type existing records. @@ -96,10 +89,7 @@ func (c *Client) FindCalendarEventType(criteria *Criteria) (*CalendarEventType, if err := c.SearchRead(CalendarEventTypeModel, criteria, NewOptions().Limit(1), cets); err != nil { return nil, err } - if cets != nil && len(*cets) > 0 { - return &((*cets)[0]), nil - } - return nil, fmt.Errorf("calendar.event.type was not found with criteria %v", criteria) + return &((*cets)[0]), nil } // FindCalendarEventTypes finds calendar.event.type records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindCalendarEventTypes(criteria *Criteria, options *Options) (* // FindCalendarEventTypeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCalendarEventTypeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CalendarEventTypeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CalendarEventTypeModel, criteria, options) } // FindCalendarEventTypeId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindCalendarEventTypeId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("calendar.event.type was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/cash_box_in.go b/cash_box_in.go index d94b4aac..27eeab70 100644 --- a/cash_box_in.go +++ b/cash_box_in.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CashBoxIn represents cash.box.in model. type CashBoxIn struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateCashBoxIns(cbis []*CashBoxIn) ([]int64, error) { for _, v := range cbis { vv = append(vv, v) } - return c.Create(CashBoxInModel, vv) + return c.Create(CashBoxInModel, vv, nil) } // UpdateCashBoxIn updates an existing cash.box.in record. @@ -58,7 +54,7 @@ func (c *Client) UpdateCashBoxIn(cbi *CashBoxIn) error { // UpdateCashBoxIns updates existing cash.box.in records. // All records (represented by ids) will be updated by cbi values. func (c *Client) UpdateCashBoxIns(ids []int64, cbi *CashBoxIn) error { - return c.Update(CashBoxInModel, ids, cbi) + return c.Update(CashBoxInModel, ids, cbi, nil) } // DeleteCashBoxIn deletes an existing cash.box.in record. @@ -77,10 +73,7 @@ func (c *Client) GetCashBoxIn(id int64) (*CashBoxIn, error) { if err != nil { return nil, err } - if cbis != nil && len(*cbis) > 0 { - return &((*cbis)[0]), nil - } - return nil, fmt.Errorf("id %v of cash.box.in not found", id) + return &((*cbis)[0]), nil } // GetCashBoxIns gets cash.box.in existing records. @@ -98,10 +91,7 @@ func (c *Client) FindCashBoxIn(criteria *Criteria) (*CashBoxIn, error) { if err := c.SearchRead(CashBoxInModel, criteria, NewOptions().Limit(1), cbis); err != nil { return nil, err } - if cbis != nil && len(*cbis) > 0 { - return &((*cbis)[0]), nil - } - return nil, fmt.Errorf("cash.box.in was not found with criteria %v", criteria) + return &((*cbis)[0]), nil } // FindCashBoxIns finds cash.box.in records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindCashBoxIns(criteria *Criteria, options *Options) (*CashBoxI // FindCashBoxInIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCashBoxInIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CashBoxInModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CashBoxInModel, criteria, options) } // FindCashBoxInId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindCashBoxInId(criteria *Criteria, options *Options) (int64, e if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("cash.box.in was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/cash_box_out.go b/cash_box_out.go index 49e1888b..39fa1234 100644 --- a/cash_box_out.go +++ b/cash_box_out.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CashBoxOut represents cash.box.out model. type CashBoxOut struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateCashBoxOuts(cbos []*CashBoxOut) ([]int64, error) { for _, v := range cbos { vv = append(vv, v) } - return c.Create(CashBoxOutModel, vv) + return c.Create(CashBoxOutModel, vv, nil) } // UpdateCashBoxOut updates an existing cash.box.out record. @@ -57,7 +53,7 @@ func (c *Client) UpdateCashBoxOut(cbo *CashBoxOut) error { // UpdateCashBoxOuts updates existing cash.box.out records. // All records (represented by ids) will be updated by cbo values. func (c *Client) UpdateCashBoxOuts(ids []int64, cbo *CashBoxOut) error { - return c.Update(CashBoxOutModel, ids, cbo) + return c.Update(CashBoxOutModel, ids, cbo, nil) } // DeleteCashBoxOut deletes an existing cash.box.out record. @@ -76,10 +72,7 @@ func (c *Client) GetCashBoxOut(id int64) (*CashBoxOut, error) { if err != nil { return nil, err } - if cbos != nil && len(*cbos) > 0 { - return &((*cbos)[0]), nil - } - return nil, fmt.Errorf("id %v of cash.box.out not found", id) + return &((*cbos)[0]), nil } // GetCashBoxOuts gets cash.box.out existing records. @@ -97,10 +90,7 @@ func (c *Client) FindCashBoxOut(criteria *Criteria) (*CashBoxOut, error) { if err := c.SearchRead(CashBoxOutModel, criteria, NewOptions().Limit(1), cbos); err != nil { return nil, err } - if cbos != nil && len(*cbos) > 0 { - return &((*cbos)[0]), nil - } - return nil, fmt.Errorf("cash.box.out was not found with criteria %v", criteria) + return &((*cbos)[0]), nil } // FindCashBoxOuts finds cash.box.out records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindCashBoxOuts(criteria *Criteria, options *Options) (*CashBox // FindCashBoxOutIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCashBoxOutIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CashBoxOutModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CashBoxOutModel, criteria, options) } // FindCashBoxOutId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindCashBoxOutId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("cash.box.out was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/change_password_user.go b/change_password_user.go index 837fc251..873a86a5 100644 --- a/change_password_user.go +++ b/change_password_user.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ChangePasswordUser represents change.password.user model. type ChangePasswordUser struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateChangePasswordUsers(cpus []*ChangePasswordUser) ([]int64, for _, v := range cpus { vv = append(vv, v) } - return c.Create(ChangePasswordUserModel, vv) + return c.Create(ChangePasswordUserModel, vv, nil) } // UpdateChangePasswordUser updates an existing change.password.user record. @@ -59,7 +55,7 @@ func (c *Client) UpdateChangePasswordUser(cpu *ChangePasswordUser) error { // UpdateChangePasswordUsers updates existing change.password.user records. // All records (represented by ids) will be updated by cpu values. func (c *Client) UpdateChangePasswordUsers(ids []int64, cpu *ChangePasswordUser) error { - return c.Update(ChangePasswordUserModel, ids, cpu) + return c.Update(ChangePasswordUserModel, ids, cpu, nil) } // DeleteChangePasswordUser deletes an existing change.password.user record. @@ -78,10 +74,7 @@ func (c *Client) GetChangePasswordUser(id int64) (*ChangePasswordUser, error) { if err != nil { return nil, err } - if cpus != nil && len(*cpus) > 0 { - return &((*cpus)[0]), nil - } - return nil, fmt.Errorf("id %v of change.password.user not found", id) + return &((*cpus)[0]), nil } // GetChangePasswordUsers gets change.password.user existing records. @@ -99,10 +92,7 @@ func (c *Client) FindChangePasswordUser(criteria *Criteria) (*ChangePasswordUser if err := c.SearchRead(ChangePasswordUserModel, criteria, NewOptions().Limit(1), cpus); err != nil { return nil, err } - if cpus != nil && len(*cpus) > 0 { - return &((*cpus)[0]), nil - } - return nil, fmt.Errorf("change.password.user was not found with criteria %v", criteria) + return &((*cpus)[0]), nil } // FindChangePasswordUsers finds change.password.user records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindChangePasswordUsers(criteria *Criteria, options *Options) ( // FindChangePasswordUserIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindChangePasswordUserIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ChangePasswordUserModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ChangePasswordUserModel, criteria, options) } // FindChangePasswordUserId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindChangePasswordUserId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("change.password.user was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/change_password_wizard.go b/change_password_wizard.go index 621437f4..c45c62e6 100644 --- a/change_password_wizard.go +++ b/change_password_wizard.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ChangePasswordWizard represents change.password.wizard model. type ChangePasswordWizard struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateChangePasswordWizards(cpws []*ChangePasswordWizard) ([]in for _, v := range cpws { vv = append(vv, v) } - return c.Create(ChangePasswordWizardModel, vv) + return c.Create(ChangePasswordWizardModel, vv, nil) } // UpdateChangePasswordWizard updates an existing change.password.wizard record. @@ -56,7 +52,7 @@ func (c *Client) UpdateChangePasswordWizard(cpw *ChangePasswordWizard) error { // UpdateChangePasswordWizards updates existing change.password.wizard records. // All records (represented by ids) will be updated by cpw values. func (c *Client) UpdateChangePasswordWizards(ids []int64, cpw *ChangePasswordWizard) error { - return c.Update(ChangePasswordWizardModel, ids, cpw) + return c.Update(ChangePasswordWizardModel, ids, cpw, nil) } // DeleteChangePasswordWizard deletes an existing change.password.wizard record. @@ -75,10 +71,7 @@ func (c *Client) GetChangePasswordWizard(id int64) (*ChangePasswordWizard, error if err != nil { return nil, err } - if cpws != nil && len(*cpws) > 0 { - return &((*cpws)[0]), nil - } - return nil, fmt.Errorf("id %v of change.password.wizard not found", id) + return &((*cpws)[0]), nil } // GetChangePasswordWizards gets change.password.wizard existing records. @@ -96,10 +89,7 @@ func (c *Client) FindChangePasswordWizard(criteria *Criteria) (*ChangePasswordWi if err := c.SearchRead(ChangePasswordWizardModel, criteria, NewOptions().Limit(1), cpws); err != nil { return nil, err } - if cpws != nil && len(*cpws) > 0 { - return &((*cpws)[0]), nil - } - return nil, fmt.Errorf("change.password.wizard was not found with criteria %v", criteria) + return &((*cpws)[0]), nil } // FindChangePasswordWizards finds change.password.wizard records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindChangePasswordWizards(criteria *Criteria, options *Options) // FindChangePasswordWizardIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindChangePasswordWizardIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ChangePasswordWizardModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ChangePasswordWizardModel, criteria, options) } // FindChangePasswordWizardId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindChangePasswordWizardId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("change.password.wizard was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/crm_activity_report.go b/crm_activity_report.go index c4328227..5f9edf1e 100644 --- a/crm_activity_report.go +++ b/crm_activity_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CrmActivityReport represents crm.activity.report model. type CrmActivityReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -55,7 +51,7 @@ func (c *Client) CreateCrmActivityReports(cars []*CrmActivityReport) ([]int64, e for _, v := range cars { vv = append(vv, v) } - return c.Create(CrmActivityReportModel, vv) + return c.Create(CrmActivityReportModel, vv, nil) } // UpdateCrmActivityReport updates an existing crm.activity.report record. @@ -66,7 +62,7 @@ func (c *Client) UpdateCrmActivityReport(car *CrmActivityReport) error { // UpdateCrmActivityReports updates existing crm.activity.report records. // All records (represented by ids) will be updated by car values. func (c *Client) UpdateCrmActivityReports(ids []int64, car *CrmActivityReport) error { - return c.Update(CrmActivityReportModel, ids, car) + return c.Update(CrmActivityReportModel, ids, car, nil) } // DeleteCrmActivityReport deletes an existing crm.activity.report record. @@ -85,10 +81,7 @@ func (c *Client) GetCrmActivityReport(id int64) (*CrmActivityReport, error) { if err != nil { return nil, err } - if cars != nil && len(*cars) > 0 { - return &((*cars)[0]), nil - } - return nil, fmt.Errorf("id %v of crm.activity.report not found", id) + return &((*cars)[0]), nil } // GetCrmActivityReports gets crm.activity.report existing records. @@ -106,10 +99,7 @@ func (c *Client) FindCrmActivityReport(criteria *Criteria) (*CrmActivityReport, if err := c.SearchRead(CrmActivityReportModel, criteria, NewOptions().Limit(1), cars); err != nil { return nil, err } - if cars != nil && len(*cars) > 0 { - return &((*cars)[0]), nil - } - return nil, fmt.Errorf("crm.activity.report was not found with criteria %v", criteria) + return &((*cars)[0]), nil } // FindCrmActivityReports finds crm.activity.report records by querying it @@ -125,11 +115,7 @@ func (c *Client) FindCrmActivityReports(criteria *Criteria, options *Options) (* // FindCrmActivityReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCrmActivityReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CrmActivityReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CrmActivityReportModel, criteria, options) } // FindCrmActivityReportId finds record id by querying it with criteria. @@ -138,8 +124,5 @@ func (c *Client) FindCrmActivityReportId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("crm.activity.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/crm_lead.go b/crm_lead.go index f4564d37..1b52ff5c 100644 --- a/crm_lead.go +++ b/crm_lead.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CrmLead represents crm.lead model. type CrmLead struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -116,7 +112,7 @@ func (c *Client) CreateCrmLeads(cls []*CrmLead) ([]int64, error) { for _, v := range cls { vv = append(vv, v) } - return c.Create(CrmLeadModel, vv) + return c.Create(CrmLeadModel, vv, nil) } // UpdateCrmLead updates an existing crm.lead record. @@ -127,7 +123,7 @@ func (c *Client) UpdateCrmLead(cl *CrmLead) error { // UpdateCrmLeads updates existing crm.lead records. // All records (represented by ids) will be updated by cl values. func (c *Client) UpdateCrmLeads(ids []int64, cl *CrmLead) error { - return c.Update(CrmLeadModel, ids, cl) + return c.Update(CrmLeadModel, ids, cl, nil) } // DeleteCrmLead deletes an existing crm.lead record. @@ -146,10 +142,7 @@ func (c *Client) GetCrmLead(id int64) (*CrmLead, error) { if err != nil { return nil, err } - if cls != nil && len(*cls) > 0 { - return &((*cls)[0]), nil - } - return nil, fmt.Errorf("id %v of crm.lead not found", id) + return &((*cls)[0]), nil } // GetCrmLeads gets crm.lead existing records. @@ -167,10 +160,7 @@ func (c *Client) FindCrmLead(criteria *Criteria) (*CrmLead, error) { if err := c.SearchRead(CrmLeadModel, criteria, NewOptions().Limit(1), cls); err != nil { return nil, err } - if cls != nil && len(*cls) > 0 { - return &((*cls)[0]), nil - } - return nil, fmt.Errorf("crm.lead was not found with criteria %v", criteria) + return &((*cls)[0]), nil } // FindCrmLeads finds crm.lead records by querying it @@ -186,11 +176,7 @@ func (c *Client) FindCrmLeads(criteria *Criteria, options *Options) (*CrmLeads, // FindCrmLeadIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCrmLeadIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CrmLeadModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CrmLeadModel, criteria, options) } // FindCrmLeadId finds record id by querying it with criteria. @@ -199,8 +185,5 @@ func (c *Client) FindCrmLeadId(criteria *Criteria, options *Options) (int64, err if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("crm.lead was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/crm_lead2opportunity_partner.go b/crm_lead2opportunity_partner.go index be70f124..69aff551 100644 --- a/crm_lead2opportunity_partner.go +++ b/crm_lead2opportunity_partner.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CrmLead2OpportunityPartner represents crm.lead2opportunity.partner model. type CrmLead2OpportunityPartner struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateCrmLead2OpportunityPartners(clps []*CrmLead2OpportunityPa for _, v := range clps { vv = append(vv, v) } - return c.Create(CrmLead2OpportunityPartnerModel, vv) + return c.Create(CrmLead2OpportunityPartnerModel, vv, nil) } // UpdateCrmLead2OpportunityPartner updates an existing crm.lead2opportunity.partner record. @@ -61,7 +57,7 @@ func (c *Client) UpdateCrmLead2OpportunityPartner(clp *CrmLead2OpportunityPartne // UpdateCrmLead2OpportunityPartners updates existing crm.lead2opportunity.partner records. // All records (represented by ids) will be updated by clp values. func (c *Client) UpdateCrmLead2OpportunityPartners(ids []int64, clp *CrmLead2OpportunityPartner) error { - return c.Update(CrmLead2OpportunityPartnerModel, ids, clp) + return c.Update(CrmLead2OpportunityPartnerModel, ids, clp, nil) } // DeleteCrmLead2OpportunityPartner deletes an existing crm.lead2opportunity.partner record. @@ -80,10 +76,7 @@ func (c *Client) GetCrmLead2OpportunityPartner(id int64) (*CrmLead2OpportunityPa if err != nil { return nil, err } - if clps != nil && len(*clps) > 0 { - return &((*clps)[0]), nil - } - return nil, fmt.Errorf("id %v of crm.lead2opportunity.partner not found", id) + return &((*clps)[0]), nil } // GetCrmLead2OpportunityPartners gets crm.lead2opportunity.partner existing records. @@ -101,10 +94,7 @@ func (c *Client) FindCrmLead2OpportunityPartner(criteria *Criteria) (*CrmLead2Op if err := c.SearchRead(CrmLead2OpportunityPartnerModel, criteria, NewOptions().Limit(1), clps); err != nil { return nil, err } - if clps != nil && len(*clps) > 0 { - return &((*clps)[0]), nil - } - return nil, fmt.Errorf("crm.lead2opportunity.partner was not found with criteria %v", criteria) + return &((*clps)[0]), nil } // FindCrmLead2OpportunityPartners finds crm.lead2opportunity.partner records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindCrmLead2OpportunityPartners(criteria *Criteria, options *Op // FindCrmLead2OpportunityPartnerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCrmLead2OpportunityPartnerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CrmLead2OpportunityPartnerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CrmLead2OpportunityPartnerModel, criteria, options) } // FindCrmLead2OpportunityPartnerId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindCrmLead2OpportunityPartnerId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("crm.lead2opportunity.partner was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/crm_lead2opportunity_partner_mass.go b/crm_lead2opportunity_partner_mass.go index 80788cd9..f2a4b194 100644 --- a/crm_lead2opportunity_partner_mass.go +++ b/crm_lead2opportunity_partner_mass.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CrmLead2OpportunityPartnerMass represents crm.lead2opportunity.partner.mass model. type CrmLead2OpportunityPartnerMass struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -53,7 +49,7 @@ func (c *Client) CreateCrmLead2OpportunityPartnerMasss(clpms []*CrmLead2Opportun for _, v := range clpms { vv = append(vv, v) } - return c.Create(CrmLead2OpportunityPartnerMassModel, vv) + return c.Create(CrmLead2OpportunityPartnerMassModel, vv, nil) } // UpdateCrmLead2OpportunityPartnerMass updates an existing crm.lead2opportunity.partner.mass record. @@ -64,7 +60,7 @@ func (c *Client) UpdateCrmLead2OpportunityPartnerMass(clpm *CrmLead2OpportunityP // UpdateCrmLead2OpportunityPartnerMasss updates existing crm.lead2opportunity.partner.mass records. // All records (represented by ids) will be updated by clpm values. func (c *Client) UpdateCrmLead2OpportunityPartnerMasss(ids []int64, clpm *CrmLead2OpportunityPartnerMass) error { - return c.Update(CrmLead2OpportunityPartnerMassModel, ids, clpm) + return c.Update(CrmLead2OpportunityPartnerMassModel, ids, clpm, nil) } // DeleteCrmLead2OpportunityPartnerMass deletes an existing crm.lead2opportunity.partner.mass record. @@ -83,10 +79,7 @@ func (c *Client) GetCrmLead2OpportunityPartnerMass(id int64) (*CrmLead2Opportuni if err != nil { return nil, err } - if clpms != nil && len(*clpms) > 0 { - return &((*clpms)[0]), nil - } - return nil, fmt.Errorf("id %v of crm.lead2opportunity.partner.mass not found", id) + return &((*clpms)[0]), nil } // GetCrmLead2OpportunityPartnerMasss gets crm.lead2opportunity.partner.mass existing records. @@ -104,10 +97,7 @@ func (c *Client) FindCrmLead2OpportunityPartnerMass(criteria *Criteria) (*CrmLea if err := c.SearchRead(CrmLead2OpportunityPartnerMassModel, criteria, NewOptions().Limit(1), clpms); err != nil { return nil, err } - if clpms != nil && len(*clpms) > 0 { - return &((*clpms)[0]), nil - } - return nil, fmt.Errorf("crm.lead2opportunity.partner.mass was not found with criteria %v", criteria) + return &((*clpms)[0]), nil } // FindCrmLead2OpportunityPartnerMasss finds crm.lead2opportunity.partner.mass records by querying it @@ -123,11 +113,7 @@ func (c *Client) FindCrmLead2OpportunityPartnerMasss(criteria *Criteria, options // FindCrmLead2OpportunityPartnerMassIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCrmLead2OpportunityPartnerMassIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CrmLead2OpportunityPartnerMassModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CrmLead2OpportunityPartnerMassModel, criteria, options) } // FindCrmLead2OpportunityPartnerMassId finds record id by querying it with criteria. @@ -136,8 +122,5 @@ func (c *Client) FindCrmLead2OpportunityPartnerMassId(criteria *Criteria, option if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("crm.lead2opportunity.partner.mass was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/crm_lead_lost.go b/crm_lead_lost.go index 69d0393c..731e4066 100644 --- a/crm_lead_lost.go +++ b/crm_lead_lost.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CrmLeadLost represents crm.lead.lost model. type CrmLeadLost struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateCrmLeadLosts(clls []*CrmLeadLost) ([]int64, error) { for _, v := range clls { vv = append(vv, v) } - return c.Create(CrmLeadLostModel, vv) + return c.Create(CrmLeadLostModel, vv, nil) } // UpdateCrmLeadLost updates an existing crm.lead.lost record. @@ -56,7 +52,7 @@ func (c *Client) UpdateCrmLeadLost(cll *CrmLeadLost) error { // UpdateCrmLeadLosts updates existing crm.lead.lost records. // All records (represented by ids) will be updated by cll values. func (c *Client) UpdateCrmLeadLosts(ids []int64, cll *CrmLeadLost) error { - return c.Update(CrmLeadLostModel, ids, cll) + return c.Update(CrmLeadLostModel, ids, cll, nil) } // DeleteCrmLeadLost deletes an existing crm.lead.lost record. @@ -75,10 +71,7 @@ func (c *Client) GetCrmLeadLost(id int64) (*CrmLeadLost, error) { if err != nil { return nil, err } - if clls != nil && len(*clls) > 0 { - return &((*clls)[0]), nil - } - return nil, fmt.Errorf("id %v of crm.lead.lost not found", id) + return &((*clls)[0]), nil } // GetCrmLeadLosts gets crm.lead.lost existing records. @@ -96,10 +89,7 @@ func (c *Client) FindCrmLeadLost(criteria *Criteria) (*CrmLeadLost, error) { if err := c.SearchRead(CrmLeadLostModel, criteria, NewOptions().Limit(1), clls); err != nil { return nil, err } - if clls != nil && len(*clls) > 0 { - return &((*clls)[0]), nil - } - return nil, fmt.Errorf("crm.lead.lost was not found with criteria %v", criteria) + return &((*clls)[0]), nil } // FindCrmLeadLosts finds crm.lead.lost records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindCrmLeadLosts(criteria *Criteria, options *Options) (*CrmLea // FindCrmLeadLostIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCrmLeadLostIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CrmLeadLostModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CrmLeadLostModel, criteria, options) } // FindCrmLeadLostId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindCrmLeadLostId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("crm.lead.lost was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/crm_lead_tag.go b/crm_lead_tag.go index 957d6b4e..c1d10344 100644 --- a/crm_lead_tag.go +++ b/crm_lead_tag.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CrmLeadTag represents crm.lead.tag model. type CrmLeadTag struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateCrmLeadTags(clts []*CrmLeadTag) ([]int64, error) { for _, v := range clts { vv = append(vv, v) } - return c.Create(CrmLeadTagModel, vv) + return c.Create(CrmLeadTagModel, vv, nil) } // UpdateCrmLeadTag updates an existing crm.lead.tag record. @@ -57,7 +53,7 @@ func (c *Client) UpdateCrmLeadTag(clt *CrmLeadTag) error { // UpdateCrmLeadTags updates existing crm.lead.tag records. // All records (represented by ids) will be updated by clt values. func (c *Client) UpdateCrmLeadTags(ids []int64, clt *CrmLeadTag) error { - return c.Update(CrmLeadTagModel, ids, clt) + return c.Update(CrmLeadTagModel, ids, clt, nil) } // DeleteCrmLeadTag deletes an existing crm.lead.tag record. @@ -76,10 +72,7 @@ func (c *Client) GetCrmLeadTag(id int64) (*CrmLeadTag, error) { if err != nil { return nil, err } - if clts != nil && len(*clts) > 0 { - return &((*clts)[0]), nil - } - return nil, fmt.Errorf("id %v of crm.lead.tag not found", id) + return &((*clts)[0]), nil } // GetCrmLeadTags gets crm.lead.tag existing records. @@ -97,10 +90,7 @@ func (c *Client) FindCrmLeadTag(criteria *Criteria) (*CrmLeadTag, error) { if err := c.SearchRead(CrmLeadTagModel, criteria, NewOptions().Limit(1), clts); err != nil { return nil, err } - if clts != nil && len(*clts) > 0 { - return &((*clts)[0]), nil - } - return nil, fmt.Errorf("crm.lead.tag was not found with criteria %v", criteria) + return &((*clts)[0]), nil } // FindCrmLeadTags finds crm.lead.tag records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindCrmLeadTags(criteria *Criteria, options *Options) (*CrmLead // FindCrmLeadTagIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCrmLeadTagIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CrmLeadTagModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CrmLeadTagModel, criteria, options) } // FindCrmLeadTagId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindCrmLeadTagId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("crm.lead.tag was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/crm_lost_reason.go b/crm_lost_reason.go index d5df99f2..743a5e8a 100644 --- a/crm_lost_reason.go +++ b/crm_lost_reason.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CrmLostReason represents crm.lost.reason model. type CrmLostReason struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateCrmLostReasons(clrs []*CrmLostReason) ([]int64, error) { for _, v := range clrs { vv = append(vv, v) } - return c.Create(CrmLostReasonModel, vv) + return c.Create(CrmLostReasonModel, vv, nil) } // UpdateCrmLostReason updates an existing crm.lost.reason record. @@ -57,7 +53,7 @@ func (c *Client) UpdateCrmLostReason(clr *CrmLostReason) error { // UpdateCrmLostReasons updates existing crm.lost.reason records. // All records (represented by ids) will be updated by clr values. func (c *Client) UpdateCrmLostReasons(ids []int64, clr *CrmLostReason) error { - return c.Update(CrmLostReasonModel, ids, clr) + return c.Update(CrmLostReasonModel, ids, clr, nil) } // DeleteCrmLostReason deletes an existing crm.lost.reason record. @@ -76,10 +72,7 @@ func (c *Client) GetCrmLostReason(id int64) (*CrmLostReason, error) { if err != nil { return nil, err } - if clrs != nil && len(*clrs) > 0 { - return &((*clrs)[0]), nil - } - return nil, fmt.Errorf("id %v of crm.lost.reason not found", id) + return &((*clrs)[0]), nil } // GetCrmLostReasons gets crm.lost.reason existing records. @@ -97,10 +90,7 @@ func (c *Client) FindCrmLostReason(criteria *Criteria) (*CrmLostReason, error) { if err := c.SearchRead(CrmLostReasonModel, criteria, NewOptions().Limit(1), clrs); err != nil { return nil, err } - if clrs != nil && len(*clrs) > 0 { - return &((*clrs)[0]), nil - } - return nil, fmt.Errorf("crm.lost.reason was not found with criteria %v", criteria) + return &((*clrs)[0]), nil } // FindCrmLostReasons finds crm.lost.reason records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindCrmLostReasons(criteria *Criteria, options *Options) (*CrmL // FindCrmLostReasonIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCrmLostReasonIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CrmLostReasonModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CrmLostReasonModel, criteria, options) } // FindCrmLostReasonId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindCrmLostReasonId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("crm.lost.reason was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/crm_merge_opportunity.go b/crm_merge_opportunity.go index e7f617aa..4241e42a 100644 --- a/crm_merge_opportunity.go +++ b/crm_merge_opportunity.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CrmMergeOpportunity represents crm.merge.opportunity model. type CrmMergeOpportunity struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateCrmMergeOpportunitys(cmos []*CrmMergeOpportunity) ([]int6 for _, v := range cmos { vv = append(vv, v) } - return c.Create(CrmMergeOpportunityModel, vv) + return c.Create(CrmMergeOpportunityModel, vv, nil) } // UpdateCrmMergeOpportunity updates an existing crm.merge.opportunity record. @@ -58,7 +54,7 @@ func (c *Client) UpdateCrmMergeOpportunity(cmo *CrmMergeOpportunity) error { // UpdateCrmMergeOpportunitys updates existing crm.merge.opportunity records. // All records (represented by ids) will be updated by cmo values. func (c *Client) UpdateCrmMergeOpportunitys(ids []int64, cmo *CrmMergeOpportunity) error { - return c.Update(CrmMergeOpportunityModel, ids, cmo) + return c.Update(CrmMergeOpportunityModel, ids, cmo, nil) } // DeleteCrmMergeOpportunity deletes an existing crm.merge.opportunity record. @@ -77,10 +73,7 @@ func (c *Client) GetCrmMergeOpportunity(id int64) (*CrmMergeOpportunity, error) if err != nil { return nil, err } - if cmos != nil && len(*cmos) > 0 { - return &((*cmos)[0]), nil - } - return nil, fmt.Errorf("id %v of crm.merge.opportunity not found", id) + return &((*cmos)[0]), nil } // GetCrmMergeOpportunitys gets crm.merge.opportunity existing records. @@ -98,10 +91,7 @@ func (c *Client) FindCrmMergeOpportunity(criteria *Criteria) (*CrmMergeOpportuni if err := c.SearchRead(CrmMergeOpportunityModel, criteria, NewOptions().Limit(1), cmos); err != nil { return nil, err } - if cmos != nil && len(*cmos) > 0 { - return &((*cmos)[0]), nil - } - return nil, fmt.Errorf("crm.merge.opportunity was not found with criteria %v", criteria) + return &((*cmos)[0]), nil } // FindCrmMergeOpportunitys finds crm.merge.opportunity records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindCrmMergeOpportunitys(criteria *Criteria, options *Options) // FindCrmMergeOpportunityIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCrmMergeOpportunityIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CrmMergeOpportunityModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CrmMergeOpportunityModel, criteria, options) } // FindCrmMergeOpportunityId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindCrmMergeOpportunityId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("crm.merge.opportunity was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/crm_opportunity_report.go b/crm_opportunity_report.go index 22fb32b4..f6bbf831 100644 --- a/crm_opportunity_report.go +++ b/crm_opportunity_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CrmOpportunityReport represents crm.opportunity.report model. type CrmOpportunityReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -68,7 +64,7 @@ func (c *Client) CreateCrmOpportunityReports(cors []*CrmOpportunityReport) ([]in for _, v := range cors { vv = append(vv, v) } - return c.Create(CrmOpportunityReportModel, vv) + return c.Create(CrmOpportunityReportModel, vv, nil) } // UpdateCrmOpportunityReport updates an existing crm.opportunity.report record. @@ -79,7 +75,7 @@ func (c *Client) UpdateCrmOpportunityReport(cor *CrmOpportunityReport) error { // UpdateCrmOpportunityReports updates existing crm.opportunity.report records. // All records (represented by ids) will be updated by cor values. func (c *Client) UpdateCrmOpportunityReports(ids []int64, cor *CrmOpportunityReport) error { - return c.Update(CrmOpportunityReportModel, ids, cor) + return c.Update(CrmOpportunityReportModel, ids, cor, nil) } // DeleteCrmOpportunityReport deletes an existing crm.opportunity.report record. @@ -98,10 +94,7 @@ func (c *Client) GetCrmOpportunityReport(id int64) (*CrmOpportunityReport, error if err != nil { return nil, err } - if cors != nil && len(*cors) > 0 { - return &((*cors)[0]), nil - } - return nil, fmt.Errorf("id %v of crm.opportunity.report not found", id) + return &((*cors)[0]), nil } // GetCrmOpportunityReports gets crm.opportunity.report existing records. @@ -119,10 +112,7 @@ func (c *Client) FindCrmOpportunityReport(criteria *Criteria) (*CrmOpportunityRe if err := c.SearchRead(CrmOpportunityReportModel, criteria, NewOptions().Limit(1), cors); err != nil { return nil, err } - if cors != nil && len(*cors) > 0 { - return &((*cors)[0]), nil - } - return nil, fmt.Errorf("crm.opportunity.report was not found with criteria %v", criteria) + return &((*cors)[0]), nil } // FindCrmOpportunityReports finds crm.opportunity.report records by querying it @@ -138,11 +128,7 @@ func (c *Client) FindCrmOpportunityReports(criteria *Criteria, options *Options) // FindCrmOpportunityReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCrmOpportunityReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CrmOpportunityReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CrmOpportunityReportModel, criteria, options) } // FindCrmOpportunityReportId finds record id by querying it with criteria. @@ -151,8 +137,5 @@ func (c *Client) FindCrmOpportunityReportId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("crm.opportunity.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/crm_partner_binding.go b/crm_partner_binding.go index b6ac1805..7becabd7 100644 --- a/crm_partner_binding.go +++ b/crm_partner_binding.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CrmPartnerBinding represents crm.partner.binding model. type CrmPartnerBinding struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateCrmPartnerBindings(cpbs []*CrmPartnerBinding) ([]int64, e for _, v := range cpbs { vv = append(vv, v) } - return c.Create(CrmPartnerBindingModel, vv) + return c.Create(CrmPartnerBindingModel, vv, nil) } // UpdateCrmPartnerBinding updates an existing crm.partner.binding record. @@ -57,7 +53,7 @@ func (c *Client) UpdateCrmPartnerBinding(cpb *CrmPartnerBinding) error { // UpdateCrmPartnerBindings updates existing crm.partner.binding records. // All records (represented by ids) will be updated by cpb values. func (c *Client) UpdateCrmPartnerBindings(ids []int64, cpb *CrmPartnerBinding) error { - return c.Update(CrmPartnerBindingModel, ids, cpb) + return c.Update(CrmPartnerBindingModel, ids, cpb, nil) } // DeleteCrmPartnerBinding deletes an existing crm.partner.binding record. @@ -76,10 +72,7 @@ func (c *Client) GetCrmPartnerBinding(id int64) (*CrmPartnerBinding, error) { if err != nil { return nil, err } - if cpbs != nil && len(*cpbs) > 0 { - return &((*cpbs)[0]), nil - } - return nil, fmt.Errorf("id %v of crm.partner.binding not found", id) + return &((*cpbs)[0]), nil } // GetCrmPartnerBindings gets crm.partner.binding existing records. @@ -97,10 +90,7 @@ func (c *Client) FindCrmPartnerBinding(criteria *Criteria) (*CrmPartnerBinding, if err := c.SearchRead(CrmPartnerBindingModel, criteria, NewOptions().Limit(1), cpbs); err != nil { return nil, err } - if cpbs != nil && len(*cpbs) > 0 { - return &((*cpbs)[0]), nil - } - return nil, fmt.Errorf("crm.partner.binding was not found with criteria %v", criteria) + return &((*cpbs)[0]), nil } // FindCrmPartnerBindings finds crm.partner.binding records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindCrmPartnerBindings(criteria *Criteria, options *Options) (* // FindCrmPartnerBindingIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCrmPartnerBindingIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CrmPartnerBindingModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CrmPartnerBindingModel, criteria, options) } // FindCrmPartnerBindingId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindCrmPartnerBindingId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("crm.partner.binding was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/crm_stage.go b/crm_stage.go index 189eb446..88640f4b 100644 --- a/crm_stage.go +++ b/crm_stage.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CrmStage represents crm.stage model. type CrmStage struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -52,7 +48,7 @@ func (c *Client) CreateCrmStages(css []*CrmStage) ([]int64, error) { for _, v := range css { vv = append(vv, v) } - return c.Create(CrmStageModel, vv) + return c.Create(CrmStageModel, vv, nil) } // UpdateCrmStage updates an existing crm.stage record. @@ -63,7 +59,7 @@ func (c *Client) UpdateCrmStage(cs *CrmStage) error { // UpdateCrmStages updates existing crm.stage records. // All records (represented by ids) will be updated by cs values. func (c *Client) UpdateCrmStages(ids []int64, cs *CrmStage) error { - return c.Update(CrmStageModel, ids, cs) + return c.Update(CrmStageModel, ids, cs, nil) } // DeleteCrmStage deletes an existing crm.stage record. @@ -82,10 +78,7 @@ func (c *Client) GetCrmStage(id int64) (*CrmStage, error) { if err != nil { return nil, err } - if css != nil && len(*css) > 0 { - return &((*css)[0]), nil - } - return nil, fmt.Errorf("id %v of crm.stage not found", id) + return &((*css)[0]), nil } // GetCrmStages gets crm.stage existing records. @@ -103,10 +96,7 @@ func (c *Client) FindCrmStage(criteria *Criteria) (*CrmStage, error) { if err := c.SearchRead(CrmStageModel, criteria, NewOptions().Limit(1), css); err != nil { return nil, err } - if css != nil && len(*css) > 0 { - return &((*css)[0]), nil - } - return nil, fmt.Errorf("crm.stage was not found with criteria %v", criteria) + return &((*css)[0]), nil } // FindCrmStages finds crm.stage records by querying it @@ -122,11 +112,7 @@ func (c *Client) FindCrmStages(criteria *Criteria, options *Options) (*CrmStages // FindCrmStageIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCrmStageIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CrmStageModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CrmStageModel, criteria, options) } // FindCrmStageId finds record id by querying it with criteria. @@ -135,8 +121,5 @@ func (c *Client) FindCrmStageId(criteria *Criteria, options *Options) (int64, er if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("crm.stage was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/crm_team.go b/crm_team.go index 51168afd..4b955e10 100644 --- a/crm_team.go +++ b/crm_team.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // CrmTeam represents crm.team model. type CrmTeam struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -96,7 +92,7 @@ func (c *Client) CreateCrmTeams(cts []*CrmTeam) ([]int64, error) { for _, v := range cts { vv = append(vv, v) } - return c.Create(CrmTeamModel, vv) + return c.Create(CrmTeamModel, vv, nil) } // UpdateCrmTeam updates an existing crm.team record. @@ -107,7 +103,7 @@ func (c *Client) UpdateCrmTeam(ct *CrmTeam) error { // UpdateCrmTeams updates existing crm.team records. // All records (represented by ids) will be updated by ct values. func (c *Client) UpdateCrmTeams(ids []int64, ct *CrmTeam) error { - return c.Update(CrmTeamModel, ids, ct) + return c.Update(CrmTeamModel, ids, ct, nil) } // DeleteCrmTeam deletes an existing crm.team record. @@ -126,10 +122,7 @@ func (c *Client) GetCrmTeam(id int64) (*CrmTeam, error) { if err != nil { return nil, err } - if cts != nil && len(*cts) > 0 { - return &((*cts)[0]), nil - } - return nil, fmt.Errorf("id %v of crm.team not found", id) + return &((*cts)[0]), nil } // GetCrmTeams gets crm.team existing records. @@ -147,10 +140,7 @@ func (c *Client) FindCrmTeam(criteria *Criteria) (*CrmTeam, error) { if err := c.SearchRead(CrmTeamModel, criteria, NewOptions().Limit(1), cts); err != nil { return nil, err } - if cts != nil && len(*cts) > 0 { - return &((*cts)[0]), nil - } - return nil, fmt.Errorf("crm.team was not found with criteria %v", criteria) + return &((*cts)[0]), nil } // FindCrmTeams finds crm.team records by querying it @@ -166,11 +156,7 @@ func (c *Client) FindCrmTeams(criteria *Criteria, options *Options) (*CrmTeams, // FindCrmTeamIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindCrmTeamIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(CrmTeamModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(CrmTeamModel, criteria, options) } // FindCrmTeamId finds record id by querying it with criteria. @@ -179,8 +165,5 @@ func (c *Client) FindCrmTeamId(criteria *Criteria, options *Options) (int64, err if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("crm.team was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/decimal_precision.go b/decimal_precision.go index 6eee3b6d..7721b7fa 100644 --- a/decimal_precision.go +++ b/decimal_precision.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // DecimalPrecision represents decimal.precision model. type DecimalPrecision struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateDecimalPrecisions(dps []*DecimalPrecision) ([]int64, erro for _, v := range dps { vv = append(vv, v) } - return c.Create(DecimalPrecisionModel, vv) + return c.Create(DecimalPrecisionModel, vv, nil) } // UpdateDecimalPrecision updates an existing decimal.precision record. @@ -57,7 +53,7 @@ func (c *Client) UpdateDecimalPrecision(dp *DecimalPrecision) error { // UpdateDecimalPrecisions updates existing decimal.precision records. // All records (represented by ids) will be updated by dp values. func (c *Client) UpdateDecimalPrecisions(ids []int64, dp *DecimalPrecision) error { - return c.Update(DecimalPrecisionModel, ids, dp) + return c.Update(DecimalPrecisionModel, ids, dp, nil) } // DeleteDecimalPrecision deletes an existing decimal.precision record. @@ -76,10 +72,7 @@ func (c *Client) GetDecimalPrecision(id int64) (*DecimalPrecision, error) { if err != nil { return nil, err } - if dps != nil && len(*dps) > 0 { - return &((*dps)[0]), nil - } - return nil, fmt.Errorf("id %v of decimal.precision not found", id) + return &((*dps)[0]), nil } // GetDecimalPrecisions gets decimal.precision existing records. @@ -97,10 +90,7 @@ func (c *Client) FindDecimalPrecision(criteria *Criteria) (*DecimalPrecision, er if err := c.SearchRead(DecimalPrecisionModel, criteria, NewOptions().Limit(1), dps); err != nil { return nil, err } - if dps != nil && len(*dps) > 0 { - return &((*dps)[0]), nil - } - return nil, fmt.Errorf("decimal.precision was not found with criteria %v", criteria) + return &((*dps)[0]), nil } // FindDecimalPrecisions finds decimal.precision records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindDecimalPrecisions(criteria *Criteria, options *Options) (*D // FindDecimalPrecisionIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindDecimalPrecisionIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(DecimalPrecisionModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(DecimalPrecisionModel, criteria, options) } // FindDecimalPrecisionId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindDecimalPrecisionId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("decimal.precision was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/decimal_precision_test.go b/decimal_precision_test.go index 59a9fb57..55a42132 100644 --- a/decimal_precision_test.go +++ b/decimal_precision_test.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // DecimalPrecisionTest represents decimal.precision.test model. type DecimalPrecisionTest struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateDecimalPrecisionTests(dpts []*DecimalPrecisionTest) ([]in for _, v := range dpts { vv = append(vv, v) } - return c.Create(DecimalPrecisionTestModel, vv) + return c.Create(DecimalPrecisionTestModel, vv, nil) } // UpdateDecimalPrecisionTest updates an existing decimal.precision.test record. @@ -58,7 +54,7 @@ func (c *Client) UpdateDecimalPrecisionTest(dpt *DecimalPrecisionTest) error { // UpdateDecimalPrecisionTests updates existing decimal.precision.test records. // All records (represented by ids) will be updated by dpt values. func (c *Client) UpdateDecimalPrecisionTests(ids []int64, dpt *DecimalPrecisionTest) error { - return c.Update(DecimalPrecisionTestModel, ids, dpt) + return c.Update(DecimalPrecisionTestModel, ids, dpt, nil) } // DeleteDecimalPrecisionTest deletes an existing decimal.precision.test record. @@ -77,10 +73,7 @@ func (c *Client) GetDecimalPrecisionTest(id int64) (*DecimalPrecisionTest, error if err != nil { return nil, err } - if dpts != nil && len(*dpts) > 0 { - return &((*dpts)[0]), nil - } - return nil, fmt.Errorf("id %v of decimal.precision.test not found", id) + return &((*dpts)[0]), nil } // GetDecimalPrecisionTests gets decimal.precision.test existing records. @@ -98,10 +91,7 @@ func (c *Client) FindDecimalPrecisionTest(criteria *Criteria) (*DecimalPrecision if err := c.SearchRead(DecimalPrecisionTestModel, criteria, NewOptions().Limit(1), dpts); err != nil { return nil, err } - if dpts != nil && len(*dpts) > 0 { - return &((*dpts)[0]), nil - } - return nil, fmt.Errorf("decimal.precision.test was not found with criteria %v", criteria) + return &((*dpts)[0]), nil } // FindDecimalPrecisionTests finds decimal.precision.test records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindDecimalPrecisionTests(criteria *Criteria, options *Options) // FindDecimalPrecisionTestIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindDecimalPrecisionTestIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(DecimalPrecisionTestModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(DecimalPrecisionTestModel, criteria, options) } // FindDecimalPrecisionTestId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindDecimalPrecisionTestId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("decimal.precision.test was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/email_template_preview.go b/email_template_preview.go index 39cd3797..c92d08fd 100644 --- a/email_template_preview.go +++ b/email_template_preview.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // EmailTemplatePreview represents email_template.preview model. type EmailTemplatePreview struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -71,7 +67,7 @@ func (c *Client) CreateEmailTemplatePreviews(eps []*EmailTemplatePreview) ([]int for _, v := range eps { vv = append(vv, v) } - return c.Create(EmailTemplatePreviewModel, vv) + return c.Create(EmailTemplatePreviewModel, vv, nil) } // UpdateEmailTemplatePreview updates an existing email_template.preview record. @@ -82,7 +78,7 @@ func (c *Client) UpdateEmailTemplatePreview(ep *EmailTemplatePreview) error { // UpdateEmailTemplatePreviews updates existing email_template.preview records. // All records (represented by ids) will be updated by ep values. func (c *Client) UpdateEmailTemplatePreviews(ids []int64, ep *EmailTemplatePreview) error { - return c.Update(EmailTemplatePreviewModel, ids, ep) + return c.Update(EmailTemplatePreviewModel, ids, ep, nil) } // DeleteEmailTemplatePreview deletes an existing email_template.preview record. @@ -101,10 +97,7 @@ func (c *Client) GetEmailTemplatePreview(id int64) (*EmailTemplatePreview, error if err != nil { return nil, err } - if eps != nil && len(*eps) > 0 { - return &((*eps)[0]), nil - } - return nil, fmt.Errorf("id %v of email_template.preview not found", id) + return &((*eps)[0]), nil } // GetEmailTemplatePreviews gets email_template.preview existing records. @@ -122,10 +115,7 @@ func (c *Client) FindEmailTemplatePreview(criteria *Criteria) (*EmailTemplatePre if err := c.SearchRead(EmailTemplatePreviewModel, criteria, NewOptions().Limit(1), eps); err != nil { return nil, err } - if eps != nil && len(*eps) > 0 { - return &((*eps)[0]), nil - } - return nil, fmt.Errorf("email_template.preview was not found with criteria %v", criteria) + return &((*eps)[0]), nil } // FindEmailTemplatePreviews finds email_template.preview records by querying it @@ -141,11 +131,7 @@ func (c *Client) FindEmailTemplatePreviews(criteria *Criteria, options *Options) // FindEmailTemplatePreviewIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindEmailTemplatePreviewIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(EmailTemplatePreviewModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(EmailTemplatePreviewModel, criteria, options) } // FindEmailTemplatePreviewId finds record id by querying it with criteria. @@ -154,8 +140,5 @@ func (c *Client) FindEmailTemplatePreviewId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("email_template.preview was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/fetchmail_server.go b/fetchmail_server.go index 83283236..fcdeb19f 100644 --- a/fetchmail_server.go +++ b/fetchmail_server.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // FetchmailServer represents fetchmail.server model. type FetchmailServer struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -62,7 +58,7 @@ func (c *Client) CreateFetchmailServers(fss []*FetchmailServer) ([]int64, error) for _, v := range fss { vv = append(vv, v) } - return c.Create(FetchmailServerModel, vv) + return c.Create(FetchmailServerModel, vv, nil) } // UpdateFetchmailServer updates an existing fetchmail.server record. @@ -73,7 +69,7 @@ func (c *Client) UpdateFetchmailServer(fs *FetchmailServer) error { // UpdateFetchmailServers updates existing fetchmail.server records. // All records (represented by ids) will be updated by fs values. func (c *Client) UpdateFetchmailServers(ids []int64, fs *FetchmailServer) error { - return c.Update(FetchmailServerModel, ids, fs) + return c.Update(FetchmailServerModel, ids, fs, nil) } // DeleteFetchmailServer deletes an existing fetchmail.server record. @@ -92,10 +88,7 @@ func (c *Client) GetFetchmailServer(id int64) (*FetchmailServer, error) { if err != nil { return nil, err } - if fss != nil && len(*fss) > 0 { - return &((*fss)[0]), nil - } - return nil, fmt.Errorf("id %v of fetchmail.server not found", id) + return &((*fss)[0]), nil } // GetFetchmailServers gets fetchmail.server existing records. @@ -113,10 +106,7 @@ func (c *Client) FindFetchmailServer(criteria *Criteria) (*FetchmailServer, erro if err := c.SearchRead(FetchmailServerModel, criteria, NewOptions().Limit(1), fss); err != nil { return nil, err } - if fss != nil && len(*fss) > 0 { - return &((*fss)[0]), nil - } - return nil, fmt.Errorf("fetchmail.server was not found with criteria %v", criteria) + return &((*fss)[0]), nil } // FindFetchmailServers finds fetchmail.server records by querying it @@ -132,11 +122,7 @@ func (c *Client) FindFetchmailServers(criteria *Criteria, options *Options) (*Fe // FindFetchmailServerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindFetchmailServerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(FetchmailServerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(FetchmailServerModel, criteria, options) } // FindFetchmailServerId finds record id by querying it with criteria. @@ -145,8 +131,5 @@ func (c *Client) FindFetchmailServerId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("fetchmail.server was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/format_address_mixin.go b/format_address_mixin.go index d39d4e4b..42e6cae5 100644 --- a/format_address_mixin.go +++ b/format_address_mixin.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // FormatAddressMixin represents format.address.mixin model. type FormatAddressMixin struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateFormatAddressMixins(fams []*FormatAddressMixin) ([]int64, for _, v := range fams { vv = append(vv, v) } - return c.Create(FormatAddressMixinModel, vv) + return c.Create(FormatAddressMixinModel, vv, nil) } // UpdateFormatAddressMixin updates an existing format.address.mixin record. @@ -51,7 +47,7 @@ func (c *Client) UpdateFormatAddressMixin(fam *FormatAddressMixin) error { // UpdateFormatAddressMixins updates existing format.address.mixin records. // All records (represented by ids) will be updated by fam values. func (c *Client) UpdateFormatAddressMixins(ids []int64, fam *FormatAddressMixin) error { - return c.Update(FormatAddressMixinModel, ids, fam) + return c.Update(FormatAddressMixinModel, ids, fam, nil) } // DeleteFormatAddressMixin deletes an existing format.address.mixin record. @@ -70,10 +66,7 @@ func (c *Client) GetFormatAddressMixin(id int64) (*FormatAddressMixin, error) { if err != nil { return nil, err } - if fams != nil && len(*fams) > 0 { - return &((*fams)[0]), nil - } - return nil, fmt.Errorf("id %v of format.address.mixin not found", id) + return &((*fams)[0]), nil } // GetFormatAddressMixins gets format.address.mixin existing records. @@ -91,10 +84,7 @@ func (c *Client) FindFormatAddressMixin(criteria *Criteria) (*FormatAddressMixin if err := c.SearchRead(FormatAddressMixinModel, criteria, NewOptions().Limit(1), fams); err != nil { return nil, err } - if fams != nil && len(*fams) > 0 { - return &((*fams)[0]), nil - } - return nil, fmt.Errorf("format.address.mixin was not found with criteria %v", criteria) + return &((*fams)[0]), nil } // FindFormatAddressMixins finds format.address.mixin records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindFormatAddressMixins(criteria *Criteria, options *Options) ( // FindFormatAddressMixinIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindFormatAddressMixinIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(FormatAddressMixinModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(FormatAddressMixinModel, criteria, options) } // FindFormatAddressMixinId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindFormatAddressMixinId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("format.address.mixin was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/generator/cmd/generator.go b/generator/cmd/generator.go index 87dd430b..a621a079 100644 --- a/generator/cmd/generator.go +++ b/generator/cmd/generator.go @@ -61,17 +61,28 @@ func (g *generator) getModels(models []string) ([]*model, error) { fmt.Printf("error: cannot find fields for model %s, cannot generate it.\n", model) continue } + idExists := false + for _, mf := range mfs { + if mf.Name == "id" { + idExists = true + break + } + } + if idExists == false { + fmt.Printf("error: cannot find ID field for model %s, cannot generate it.\n", model) + continue + } mm = append(mm, newModel(model, mfs)) } return mm, nil } func (g *generator) getAllModelsName() ([]string, error) { + var models []string ims, err := g.odoo.FindIrModels(nil, nil) - if err != nil || ims == nil { - return []string{}, nil + if err != nil { + return models, err } - var models []string for _, im := range *ims { models = append(models, im.Model.Get()) } diff --git a/generator/cmd/model.go b/generator/cmd/model.go index 47189087..65a770c8 100644 --- a/generator/cmd/model.go +++ b/generator/cmd/model.go @@ -47,7 +47,7 @@ func newModel(name string, mfs []*modelField) *model { for _, p := range pp { m.VarName += string(p[0]) } - if m.VarName == "ids" || m.VarName == "id" || m.VarName == "c" || m.VarName == "if" { + if m.VarName == "ids" || m.VarName == "id" || m.VarName == "c" || m.VarName == "if" || m.VarName == "map" { m.VarName = strings.ToUpper(m.VarName) } m.VarsName = m.VarName + "s" diff --git a/generator/cmd/tmpl/model.tmpl b/generator/cmd/tmpl/model.tmpl index b1a2a249..c7bccf66 100644 --- a/generator/cmd/tmpl/model.tmpl +++ b/generator/cmd/tmpl/model.tmpl @@ -34,7 +34,7 @@ func (c *Client) Create{{.StructName}}s({{.VarName}}s []*{{.StructName}}) ([]int for _, v := range {{.VarName}}s { vv = append(vv, v) } - return c.Create({{.StructName}}Model, vv) + return c.Create({{.StructName}}Model, vv, nil) } // Update{{.StructName}} updates an existing {{ .Name }} record. @@ -45,7 +45,7 @@ func (c *Client) Update{{.StructName}}({{.VarName}} *{{.StructName}}) error { // Update{{.StructName}}s updates existing {{ .Name }} records. // All records (represented by ids) will be updated by {{.VarName}} values. func (c *Client) Update{{.StructName}}s(ids []int64, {{.VarName}} *{{.StructName}}) error { - return c.Update({{.StructName}}Model, ids, {{.VarName}}) + return c.Update({{.StructName}}Model, ids, {{.VarName}}, nil) } // Delete{{.StructName}} deletes an existing {{ .Name }} record. diff --git a/generator/generator b/generator/generator index 89c10568..4389d318 100755 Binary files a/generator/generator and b/generator/generator differ diff --git a/hr_department.go b/hr_department.go index 2bb421f2..3f658f8e 100644 --- a/hr_department.go +++ b/hr_department.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // HrDepartment represents hr.department model. type HrDepartment struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -70,7 +66,7 @@ func (c *Client) CreateHrDepartments(hds []*HrDepartment) ([]int64, error) { for _, v := range hds { vv = append(vv, v) } - return c.Create(HrDepartmentModel, vv) + return c.Create(HrDepartmentModel, vv, nil) } // UpdateHrDepartment updates an existing hr.department record. @@ -81,7 +77,7 @@ func (c *Client) UpdateHrDepartment(hd *HrDepartment) error { // UpdateHrDepartments updates existing hr.department records. // All records (represented by ids) will be updated by hd values. func (c *Client) UpdateHrDepartments(ids []int64, hd *HrDepartment) error { - return c.Update(HrDepartmentModel, ids, hd) + return c.Update(HrDepartmentModel, ids, hd, nil) } // DeleteHrDepartment deletes an existing hr.department record. @@ -100,10 +96,7 @@ func (c *Client) GetHrDepartment(id int64) (*HrDepartment, error) { if err != nil { return nil, err } - if hds != nil && len(*hds) > 0 { - return &((*hds)[0]), nil - } - return nil, fmt.Errorf("id %v of hr.department not found", id) + return &((*hds)[0]), nil } // GetHrDepartments gets hr.department existing records. @@ -121,10 +114,7 @@ func (c *Client) FindHrDepartment(criteria *Criteria) (*HrDepartment, error) { if err := c.SearchRead(HrDepartmentModel, criteria, NewOptions().Limit(1), hds); err != nil { return nil, err } - if hds != nil && len(*hds) > 0 { - return &((*hds)[0]), nil - } - return nil, fmt.Errorf("hr.department was not found with criteria %v", criteria) + return &((*hds)[0]), nil } // FindHrDepartments finds hr.department records by querying it @@ -140,11 +130,7 @@ func (c *Client) FindHrDepartments(criteria *Criteria, options *Options) (*HrDep // FindHrDepartmentIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindHrDepartmentIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(HrDepartmentModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(HrDepartmentModel, criteria, options) } // FindHrDepartmentId finds record id by querying it with criteria. @@ -153,8 +139,5 @@ func (c *Client) FindHrDepartmentId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("hr.department was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/hr_employee.go b/hr_employee.go index 25a72de5..595de330 100644 --- a/hr_employee.go +++ b/hr_employee.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // HrEmployee represents hr.employee model. type HrEmployee struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -102,7 +98,7 @@ func (c *Client) CreateHrEmployees(hes []*HrEmployee) ([]int64, error) { for _, v := range hes { vv = append(vv, v) } - return c.Create(HrEmployeeModel, vv) + return c.Create(HrEmployeeModel, vv, nil) } // UpdateHrEmployee updates an existing hr.employee record. @@ -113,7 +109,7 @@ func (c *Client) UpdateHrEmployee(he *HrEmployee) error { // UpdateHrEmployees updates existing hr.employee records. // All records (represented by ids) will be updated by he values. func (c *Client) UpdateHrEmployees(ids []int64, he *HrEmployee) error { - return c.Update(HrEmployeeModel, ids, he) + return c.Update(HrEmployeeModel, ids, he, nil) } // DeleteHrEmployee deletes an existing hr.employee record. @@ -132,10 +128,7 @@ func (c *Client) GetHrEmployee(id int64) (*HrEmployee, error) { if err != nil { return nil, err } - if hes != nil && len(*hes) > 0 { - return &((*hes)[0]), nil - } - return nil, fmt.Errorf("id %v of hr.employee not found", id) + return &((*hes)[0]), nil } // GetHrEmployees gets hr.employee existing records. @@ -153,10 +146,7 @@ func (c *Client) FindHrEmployee(criteria *Criteria) (*HrEmployee, error) { if err := c.SearchRead(HrEmployeeModel, criteria, NewOptions().Limit(1), hes); err != nil { return nil, err } - if hes != nil && len(*hes) > 0 { - return &((*hes)[0]), nil - } - return nil, fmt.Errorf("hr.employee was not found with criteria %v", criteria) + return &((*hes)[0]), nil } // FindHrEmployees finds hr.employee records by querying it @@ -172,11 +162,7 @@ func (c *Client) FindHrEmployees(criteria *Criteria, options *Options) (*HrEmplo // FindHrEmployeeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindHrEmployeeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(HrEmployeeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(HrEmployeeModel, criteria, options) } // FindHrEmployeeId finds record id by querying it with criteria. @@ -185,8 +171,5 @@ func (c *Client) FindHrEmployeeId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("hr.employee was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/hr_employee_category.go b/hr_employee_category.go index facf7e59..e1fa1c24 100644 --- a/hr_employee_category.go +++ b/hr_employee_category.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // HrEmployeeCategory represents hr.employee.category model. type HrEmployeeCategory struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateHrEmployeeCategorys(hecs []*HrEmployeeCategory) ([]int64, for _, v := range hecs { vv = append(vv, v) } - return c.Create(HrEmployeeCategoryModel, vv) + return c.Create(HrEmployeeCategoryModel, vv, nil) } // UpdateHrEmployeeCategory updates an existing hr.employee.category record. @@ -58,7 +54,7 @@ func (c *Client) UpdateHrEmployeeCategory(hec *HrEmployeeCategory) error { // UpdateHrEmployeeCategorys updates existing hr.employee.category records. // All records (represented by ids) will be updated by hec values. func (c *Client) UpdateHrEmployeeCategorys(ids []int64, hec *HrEmployeeCategory) error { - return c.Update(HrEmployeeCategoryModel, ids, hec) + return c.Update(HrEmployeeCategoryModel, ids, hec, nil) } // DeleteHrEmployeeCategory deletes an existing hr.employee.category record. @@ -77,10 +73,7 @@ func (c *Client) GetHrEmployeeCategory(id int64) (*HrEmployeeCategory, error) { if err != nil { return nil, err } - if hecs != nil && len(*hecs) > 0 { - return &((*hecs)[0]), nil - } - return nil, fmt.Errorf("id %v of hr.employee.category not found", id) + return &((*hecs)[0]), nil } // GetHrEmployeeCategorys gets hr.employee.category existing records. @@ -98,10 +91,7 @@ func (c *Client) FindHrEmployeeCategory(criteria *Criteria) (*HrEmployeeCategory if err := c.SearchRead(HrEmployeeCategoryModel, criteria, NewOptions().Limit(1), hecs); err != nil { return nil, err } - if hecs != nil && len(*hecs) > 0 { - return &((*hecs)[0]), nil - } - return nil, fmt.Errorf("hr.employee.category was not found with criteria %v", criteria) + return &((*hecs)[0]), nil } // FindHrEmployeeCategorys finds hr.employee.category records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindHrEmployeeCategorys(criteria *Criteria, options *Options) ( // FindHrEmployeeCategoryIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindHrEmployeeCategoryIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(HrEmployeeCategoryModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(HrEmployeeCategoryModel, criteria, options) } // FindHrEmployeeCategoryId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindHrEmployeeCategoryId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("hr.employee.category was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/hr_holidays.go b/hr_holidays.go index 85502e30..4b3bf50a 100644 --- a/hr_holidays.go +++ b/hr_holidays.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // HrHolidays represents hr.holidays model. type HrHolidays struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -80,7 +76,7 @@ func (c *Client) CreateHrHolidayss(hhs []*HrHolidays) ([]int64, error) { for _, v := range hhs { vv = append(vv, v) } - return c.Create(HrHolidaysModel, vv) + return c.Create(HrHolidaysModel, vv, nil) } // UpdateHrHolidays updates an existing hr.holidays record. @@ -91,7 +87,7 @@ func (c *Client) UpdateHrHolidays(hh *HrHolidays) error { // UpdateHrHolidayss updates existing hr.holidays records. // All records (represented by ids) will be updated by hh values. func (c *Client) UpdateHrHolidayss(ids []int64, hh *HrHolidays) error { - return c.Update(HrHolidaysModel, ids, hh) + return c.Update(HrHolidaysModel, ids, hh, nil) } // DeleteHrHolidays deletes an existing hr.holidays record. @@ -110,10 +106,7 @@ func (c *Client) GetHrHolidays(id int64) (*HrHolidays, error) { if err != nil { return nil, err } - if hhs != nil && len(*hhs) > 0 { - return &((*hhs)[0]), nil - } - return nil, fmt.Errorf("id %v of hr.holidays not found", id) + return &((*hhs)[0]), nil } // GetHrHolidayss gets hr.holidays existing records. @@ -131,10 +124,7 @@ func (c *Client) FindHrHolidays(criteria *Criteria) (*HrHolidays, error) { if err := c.SearchRead(HrHolidaysModel, criteria, NewOptions().Limit(1), hhs); err != nil { return nil, err } - if hhs != nil && len(*hhs) > 0 { - return &((*hhs)[0]), nil - } - return nil, fmt.Errorf("hr.holidays was not found with criteria %v", criteria) + return &((*hhs)[0]), nil } // FindHrHolidayss finds hr.holidays records by querying it @@ -150,11 +140,7 @@ func (c *Client) FindHrHolidayss(criteria *Criteria, options *Options) (*HrHolid // FindHrHolidaysIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindHrHolidaysIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(HrHolidaysModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(HrHolidaysModel, criteria, options) } // FindHrHolidaysId finds record id by querying it with criteria. @@ -163,8 +149,5 @@ func (c *Client) FindHrHolidaysId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("hr.holidays was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/hr_holidays_remaining_leaves_user.go b/hr_holidays_remaining_leaves_user.go index e9871a1d..503a24f1 100644 --- a/hr_holidays_remaining_leaves_user.go +++ b/hr_holidays_remaining_leaves_user.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // HrHolidaysRemainingLeavesUser represents hr.holidays.remaining.leaves.user model. type HrHolidaysRemainingLeavesUser struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -44,7 +40,7 @@ func (c *Client) CreateHrHolidaysRemainingLeavesUsers(hhrlus []*HrHolidaysRemain for _, v := range hhrlus { vv = append(vv, v) } - return c.Create(HrHolidaysRemainingLeavesUserModel, vv) + return c.Create(HrHolidaysRemainingLeavesUserModel, vv, nil) } // UpdateHrHolidaysRemainingLeavesUser updates an existing hr.holidays.remaining.leaves.user record. @@ -55,7 +51,7 @@ func (c *Client) UpdateHrHolidaysRemainingLeavesUser(hhrlu *HrHolidaysRemainingL // UpdateHrHolidaysRemainingLeavesUsers updates existing hr.holidays.remaining.leaves.user records. // All records (represented by ids) will be updated by hhrlu values. func (c *Client) UpdateHrHolidaysRemainingLeavesUsers(ids []int64, hhrlu *HrHolidaysRemainingLeavesUser) error { - return c.Update(HrHolidaysRemainingLeavesUserModel, ids, hhrlu) + return c.Update(HrHolidaysRemainingLeavesUserModel, ids, hhrlu, nil) } // DeleteHrHolidaysRemainingLeavesUser deletes an existing hr.holidays.remaining.leaves.user record. @@ -74,10 +70,7 @@ func (c *Client) GetHrHolidaysRemainingLeavesUser(id int64) (*HrHolidaysRemainin if err != nil { return nil, err } - if hhrlus != nil && len(*hhrlus) > 0 { - return &((*hhrlus)[0]), nil - } - return nil, fmt.Errorf("id %v of hr.holidays.remaining.leaves.user not found", id) + return &((*hhrlus)[0]), nil } // GetHrHolidaysRemainingLeavesUsers gets hr.holidays.remaining.leaves.user existing records. @@ -95,10 +88,7 @@ func (c *Client) FindHrHolidaysRemainingLeavesUser(criteria *Criteria) (*HrHolid if err := c.SearchRead(HrHolidaysRemainingLeavesUserModel, criteria, NewOptions().Limit(1), hhrlus); err != nil { return nil, err } - if hhrlus != nil && len(*hhrlus) > 0 { - return &((*hhrlus)[0]), nil - } - return nil, fmt.Errorf("hr.holidays.remaining.leaves.user was not found with criteria %v", criteria) + return &((*hhrlus)[0]), nil } // FindHrHolidaysRemainingLeavesUsers finds hr.holidays.remaining.leaves.user records by querying it @@ -114,11 +104,7 @@ func (c *Client) FindHrHolidaysRemainingLeavesUsers(criteria *Criteria, options // FindHrHolidaysRemainingLeavesUserIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindHrHolidaysRemainingLeavesUserIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(HrHolidaysRemainingLeavesUserModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(HrHolidaysRemainingLeavesUserModel, criteria, options) } // FindHrHolidaysRemainingLeavesUserId finds record id by querying it with criteria. @@ -127,8 +113,5 @@ func (c *Client) FindHrHolidaysRemainingLeavesUserId(criteria *Criteria, options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("hr.holidays.remaining.leaves.user was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/hr_holidays_status.go b/hr_holidays_status.go index 630ddfe1..322aed58 100644 --- a/hr_holidays_status.go +++ b/hr_holidays_status.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // HrHolidaysStatus represents hr.holidays.status model. type HrHolidaysStatus struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -58,7 +54,7 @@ func (c *Client) CreateHrHolidaysStatuss(hhss []*HrHolidaysStatus) ([]int64, err for _, v := range hhss { vv = append(vv, v) } - return c.Create(HrHolidaysStatusModel, vv) + return c.Create(HrHolidaysStatusModel, vv, nil) } // UpdateHrHolidaysStatus updates an existing hr.holidays.status record. @@ -69,7 +65,7 @@ func (c *Client) UpdateHrHolidaysStatus(hhs *HrHolidaysStatus) error { // UpdateHrHolidaysStatuss updates existing hr.holidays.status records. // All records (represented by ids) will be updated by hhs values. func (c *Client) UpdateHrHolidaysStatuss(ids []int64, hhs *HrHolidaysStatus) error { - return c.Update(HrHolidaysStatusModel, ids, hhs) + return c.Update(HrHolidaysStatusModel, ids, hhs, nil) } // DeleteHrHolidaysStatus deletes an existing hr.holidays.status record. @@ -88,10 +84,7 @@ func (c *Client) GetHrHolidaysStatus(id int64) (*HrHolidaysStatus, error) { if err != nil { return nil, err } - if hhss != nil && len(*hhss) > 0 { - return &((*hhss)[0]), nil - } - return nil, fmt.Errorf("id %v of hr.holidays.status not found", id) + return &((*hhss)[0]), nil } // GetHrHolidaysStatuss gets hr.holidays.status existing records. @@ -109,10 +102,7 @@ func (c *Client) FindHrHolidaysStatus(criteria *Criteria) (*HrHolidaysStatus, er if err := c.SearchRead(HrHolidaysStatusModel, criteria, NewOptions().Limit(1), hhss); err != nil { return nil, err } - if hhss != nil && len(*hhss) > 0 { - return &((*hhss)[0]), nil - } - return nil, fmt.Errorf("hr.holidays.status was not found with criteria %v", criteria) + return &((*hhss)[0]), nil } // FindHrHolidaysStatuss finds hr.holidays.status records by querying it @@ -128,11 +118,7 @@ func (c *Client) FindHrHolidaysStatuss(criteria *Criteria, options *Options) (*H // FindHrHolidaysStatusIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindHrHolidaysStatusIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(HrHolidaysStatusModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(HrHolidaysStatusModel, criteria, options) } // FindHrHolidaysStatusId finds record id by querying it with criteria. @@ -141,8 +127,5 @@ func (c *Client) FindHrHolidaysStatusId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("hr.holidays.status was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/hr_holidays_summary_dept.go b/hr_holidays_summary_dept.go index 35661b28..7ac62c7a 100644 --- a/hr_holidays_summary_dept.go +++ b/hr_holidays_summary_dept.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // HrHolidaysSummaryDept represents hr.holidays.summary.dept model. type HrHolidaysSummaryDept struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateHrHolidaysSummaryDepts(hhsds []*HrHolidaysSummaryDept) ([ for _, v := range hhsds { vv = append(vv, v) } - return c.Create(HrHolidaysSummaryDeptModel, vv) + return c.Create(HrHolidaysSummaryDeptModel, vv, nil) } // UpdateHrHolidaysSummaryDept updates an existing hr.holidays.summary.dept record. @@ -58,7 +54,7 @@ func (c *Client) UpdateHrHolidaysSummaryDept(hhsd *HrHolidaysSummaryDept) error // UpdateHrHolidaysSummaryDepts updates existing hr.holidays.summary.dept records. // All records (represented by ids) will be updated by hhsd values. func (c *Client) UpdateHrHolidaysSummaryDepts(ids []int64, hhsd *HrHolidaysSummaryDept) error { - return c.Update(HrHolidaysSummaryDeptModel, ids, hhsd) + return c.Update(HrHolidaysSummaryDeptModel, ids, hhsd, nil) } // DeleteHrHolidaysSummaryDept deletes an existing hr.holidays.summary.dept record. @@ -77,10 +73,7 @@ func (c *Client) GetHrHolidaysSummaryDept(id int64) (*HrHolidaysSummaryDept, err if err != nil { return nil, err } - if hhsds != nil && len(*hhsds) > 0 { - return &((*hhsds)[0]), nil - } - return nil, fmt.Errorf("id %v of hr.holidays.summary.dept not found", id) + return &((*hhsds)[0]), nil } // GetHrHolidaysSummaryDepts gets hr.holidays.summary.dept existing records. @@ -98,10 +91,7 @@ func (c *Client) FindHrHolidaysSummaryDept(criteria *Criteria) (*HrHolidaysSumma if err := c.SearchRead(HrHolidaysSummaryDeptModel, criteria, NewOptions().Limit(1), hhsds); err != nil { return nil, err } - if hhsds != nil && len(*hhsds) > 0 { - return &((*hhsds)[0]), nil - } - return nil, fmt.Errorf("hr.holidays.summary.dept was not found with criteria %v", criteria) + return &((*hhsds)[0]), nil } // FindHrHolidaysSummaryDepts finds hr.holidays.summary.dept records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindHrHolidaysSummaryDepts(criteria *Criteria, options *Options // FindHrHolidaysSummaryDeptIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindHrHolidaysSummaryDeptIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(HrHolidaysSummaryDeptModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(HrHolidaysSummaryDeptModel, criteria, options) } // FindHrHolidaysSummaryDeptId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindHrHolidaysSummaryDeptId(criteria *Criteria, options *Option if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("hr.holidays.summary.dept was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/hr_holidays_summary_employee.go b/hr_holidays_summary_employee.go index 55d60a01..f4636ee7 100644 --- a/hr_holidays_summary_employee.go +++ b/hr_holidays_summary_employee.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // HrHolidaysSummaryEmployee represents hr.holidays.summary.employee model. type HrHolidaysSummaryEmployee struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateHrHolidaysSummaryEmployees(hhses []*HrHolidaysSummaryEmpl for _, v := range hhses { vv = append(vv, v) } - return c.Create(HrHolidaysSummaryEmployeeModel, vv) + return c.Create(HrHolidaysSummaryEmployeeModel, vv, nil) } // UpdateHrHolidaysSummaryEmployee updates an existing hr.holidays.summary.employee record. @@ -58,7 +54,7 @@ func (c *Client) UpdateHrHolidaysSummaryEmployee(hhse *HrHolidaysSummaryEmployee // UpdateHrHolidaysSummaryEmployees updates existing hr.holidays.summary.employee records. // All records (represented by ids) will be updated by hhse values. func (c *Client) UpdateHrHolidaysSummaryEmployees(ids []int64, hhse *HrHolidaysSummaryEmployee) error { - return c.Update(HrHolidaysSummaryEmployeeModel, ids, hhse) + return c.Update(HrHolidaysSummaryEmployeeModel, ids, hhse, nil) } // DeleteHrHolidaysSummaryEmployee deletes an existing hr.holidays.summary.employee record. @@ -77,10 +73,7 @@ func (c *Client) GetHrHolidaysSummaryEmployee(id int64) (*HrHolidaysSummaryEmplo if err != nil { return nil, err } - if hhses != nil && len(*hhses) > 0 { - return &((*hhses)[0]), nil - } - return nil, fmt.Errorf("id %v of hr.holidays.summary.employee not found", id) + return &((*hhses)[0]), nil } // GetHrHolidaysSummaryEmployees gets hr.holidays.summary.employee existing records. @@ -98,10 +91,7 @@ func (c *Client) FindHrHolidaysSummaryEmployee(criteria *Criteria) (*HrHolidaysS if err := c.SearchRead(HrHolidaysSummaryEmployeeModel, criteria, NewOptions().Limit(1), hhses); err != nil { return nil, err } - if hhses != nil && len(*hhses) > 0 { - return &((*hhses)[0]), nil - } - return nil, fmt.Errorf("hr.holidays.summary.employee was not found with criteria %v", criteria) + return &((*hhses)[0]), nil } // FindHrHolidaysSummaryEmployees finds hr.holidays.summary.employee records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindHrHolidaysSummaryEmployees(criteria *Criteria, options *Opt // FindHrHolidaysSummaryEmployeeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindHrHolidaysSummaryEmployeeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(HrHolidaysSummaryEmployeeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(HrHolidaysSummaryEmployeeModel, criteria, options) } // FindHrHolidaysSummaryEmployeeId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindHrHolidaysSummaryEmployeeId(criteria *Criteria, options *Op if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("hr.holidays.summary.employee was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/hr_job.go b/hr_job.go index 9d6dfcb8..10d088bf 100644 --- a/hr_job.go +++ b/hr_job.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // HrJob represents hr.job model. type HrJob struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -66,7 +62,7 @@ func (c *Client) CreateHrJobs(hjs []*HrJob) ([]int64, error) { for _, v := range hjs { vv = append(vv, v) } - return c.Create(HrJobModel, vv) + return c.Create(HrJobModel, vv, nil) } // UpdateHrJob updates an existing hr.job record. @@ -77,7 +73,7 @@ func (c *Client) UpdateHrJob(hj *HrJob) error { // UpdateHrJobs updates existing hr.job records. // All records (represented by ids) will be updated by hj values. func (c *Client) UpdateHrJobs(ids []int64, hj *HrJob) error { - return c.Update(HrJobModel, ids, hj) + return c.Update(HrJobModel, ids, hj, nil) } // DeleteHrJob deletes an existing hr.job record. @@ -96,10 +92,7 @@ func (c *Client) GetHrJob(id int64) (*HrJob, error) { if err != nil { return nil, err } - if hjs != nil && len(*hjs) > 0 { - return &((*hjs)[0]), nil - } - return nil, fmt.Errorf("id %v of hr.job not found", id) + return &((*hjs)[0]), nil } // GetHrJobs gets hr.job existing records. @@ -117,10 +110,7 @@ func (c *Client) FindHrJob(criteria *Criteria) (*HrJob, error) { if err := c.SearchRead(HrJobModel, criteria, NewOptions().Limit(1), hjs); err != nil { return nil, err } - if hjs != nil && len(*hjs) > 0 { - return &((*hjs)[0]), nil - } - return nil, fmt.Errorf("hr.job was not found with criteria %v", criteria) + return &((*hjs)[0]), nil } // FindHrJobs finds hr.job records by querying it @@ -136,11 +126,7 @@ func (c *Client) FindHrJobs(criteria *Criteria, options *Options) (*HrJobs, erro // FindHrJobIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindHrJobIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(HrJobModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(HrJobModel, criteria, options) } // FindHrJobId finds record id by querying it with criteria. @@ -149,8 +135,5 @@ func (c *Client) FindHrJobId(criteria *Criteria, options *Options) (int64, error if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("hr.job was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/iap_account.go b/iap_account.go index e0205b9a..2449a29a 100644 --- a/iap_account.go +++ b/iap_account.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IapAccount represents iap.account model. type IapAccount struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateIapAccounts(ias []*IapAccount) ([]int64, error) { for _, v := range ias { vv = append(vv, v) } - return c.Create(IapAccountModel, vv) + return c.Create(IapAccountModel, vv, nil) } // UpdateIapAccount updates an existing iap.account record. @@ -58,7 +54,7 @@ func (c *Client) UpdateIapAccount(ia *IapAccount) error { // UpdateIapAccounts updates existing iap.account records. // All records (represented by ids) will be updated by ia values. func (c *Client) UpdateIapAccounts(ids []int64, ia *IapAccount) error { - return c.Update(IapAccountModel, ids, ia) + return c.Update(IapAccountModel, ids, ia, nil) } // DeleteIapAccount deletes an existing iap.account record. @@ -77,10 +73,7 @@ func (c *Client) GetIapAccount(id int64) (*IapAccount, error) { if err != nil { return nil, err } - if ias != nil && len(*ias) > 0 { - return &((*ias)[0]), nil - } - return nil, fmt.Errorf("id %v of iap.account not found", id) + return &((*ias)[0]), nil } // GetIapAccounts gets iap.account existing records. @@ -98,10 +91,7 @@ func (c *Client) FindIapAccount(criteria *Criteria) (*IapAccount, error) { if err := c.SearchRead(IapAccountModel, criteria, NewOptions().Limit(1), ias); err != nil { return nil, err } - if ias != nil && len(*ias) > 0 { - return &((*ias)[0]), nil - } - return nil, fmt.Errorf("iap.account was not found with criteria %v", criteria) + return &((*ias)[0]), nil } // FindIapAccounts finds iap.account records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindIapAccounts(criteria *Criteria, options *Options) (*IapAcco // FindIapAccountIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIapAccountIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IapAccountModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IapAccountModel, criteria, options) } // FindIapAccountId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindIapAccountId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("iap.account was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/im_livechat_channel.go b/im_livechat_channel.go index a85c669c..2469d256 100644 --- a/im_livechat_channel.go +++ b/im_livechat_channel.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ImLivechatChannel represents im_livechat.channel model. type ImLivechatChannel struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -59,7 +55,7 @@ func (c *Client) CreateImLivechatChannels(ics []*ImLivechatChannel) ([]int64, er for _, v := range ics { vv = append(vv, v) } - return c.Create(ImLivechatChannelModel, vv) + return c.Create(ImLivechatChannelModel, vv, nil) } // UpdateImLivechatChannel updates an existing im_livechat.channel record. @@ -70,7 +66,7 @@ func (c *Client) UpdateImLivechatChannel(ic *ImLivechatChannel) error { // UpdateImLivechatChannels updates existing im_livechat.channel records. // All records (represented by ids) will be updated by ic values. func (c *Client) UpdateImLivechatChannels(ids []int64, ic *ImLivechatChannel) error { - return c.Update(ImLivechatChannelModel, ids, ic) + return c.Update(ImLivechatChannelModel, ids, ic, nil) } // DeleteImLivechatChannel deletes an existing im_livechat.channel record. @@ -89,10 +85,7 @@ func (c *Client) GetImLivechatChannel(id int64) (*ImLivechatChannel, error) { if err != nil { return nil, err } - if ics != nil && len(*ics) > 0 { - return &((*ics)[0]), nil - } - return nil, fmt.Errorf("id %v of im_livechat.channel not found", id) + return &((*ics)[0]), nil } // GetImLivechatChannels gets im_livechat.channel existing records. @@ -110,10 +103,7 @@ func (c *Client) FindImLivechatChannel(criteria *Criteria) (*ImLivechatChannel, if err := c.SearchRead(ImLivechatChannelModel, criteria, NewOptions().Limit(1), ics); err != nil { return nil, err } - if ics != nil && len(*ics) > 0 { - return &((*ics)[0]), nil - } - return nil, fmt.Errorf("im_livechat.channel was not found with criteria %v", criteria) + return &((*ics)[0]), nil } // FindImLivechatChannels finds im_livechat.channel records by querying it @@ -129,11 +119,7 @@ func (c *Client) FindImLivechatChannels(criteria *Criteria, options *Options) (* // FindImLivechatChannelIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindImLivechatChannelIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ImLivechatChannelModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ImLivechatChannelModel, criteria, options) } // FindImLivechatChannelId finds record id by querying it with criteria. @@ -142,8 +128,5 @@ func (c *Client) FindImLivechatChannelId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("im_livechat.channel was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/im_livechat_channel_rule.go b/im_livechat_channel_rule.go index 0afed85f..9100321d 100644 --- a/im_livechat_channel_rule.go +++ b/im_livechat_channel_rule.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ImLivechatChannelRule represents im_livechat.channel.rule model. type ImLivechatChannelRule struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateImLivechatChannelRules(icrs []*ImLivechatChannelRule) ([] for _, v := range icrs { vv = append(vv, v) } - return c.Create(ImLivechatChannelRuleModel, vv) + return c.Create(ImLivechatChannelRuleModel, vv, nil) } // UpdateImLivechatChannelRule updates an existing im_livechat.channel.rule record. @@ -61,7 +57,7 @@ func (c *Client) UpdateImLivechatChannelRule(icr *ImLivechatChannelRule) error { // UpdateImLivechatChannelRules updates existing im_livechat.channel.rule records. // All records (represented by ids) will be updated by icr values. func (c *Client) UpdateImLivechatChannelRules(ids []int64, icr *ImLivechatChannelRule) error { - return c.Update(ImLivechatChannelRuleModel, ids, icr) + return c.Update(ImLivechatChannelRuleModel, ids, icr, nil) } // DeleteImLivechatChannelRule deletes an existing im_livechat.channel.rule record. @@ -80,10 +76,7 @@ func (c *Client) GetImLivechatChannelRule(id int64) (*ImLivechatChannelRule, err if err != nil { return nil, err } - if icrs != nil && len(*icrs) > 0 { - return &((*icrs)[0]), nil - } - return nil, fmt.Errorf("id %v of im_livechat.channel.rule not found", id) + return &((*icrs)[0]), nil } // GetImLivechatChannelRules gets im_livechat.channel.rule existing records. @@ -101,10 +94,7 @@ func (c *Client) FindImLivechatChannelRule(criteria *Criteria) (*ImLivechatChann if err := c.SearchRead(ImLivechatChannelRuleModel, criteria, NewOptions().Limit(1), icrs); err != nil { return nil, err } - if icrs != nil && len(*icrs) > 0 { - return &((*icrs)[0]), nil - } - return nil, fmt.Errorf("im_livechat.channel.rule was not found with criteria %v", criteria) + return &((*icrs)[0]), nil } // FindImLivechatChannelRules finds im_livechat.channel.rule records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindImLivechatChannelRules(criteria *Criteria, options *Options // FindImLivechatChannelRuleIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindImLivechatChannelRuleIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ImLivechatChannelRuleModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ImLivechatChannelRuleModel, criteria, options) } // FindImLivechatChannelRuleId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindImLivechatChannelRuleId(criteria *Criteria, options *Option if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("im_livechat.channel.rule was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/im_livechat_report_channel.go b/im_livechat_report_channel.go index e17c50f9..2caa08c8 100644 --- a/im_livechat_report_channel.go +++ b/im_livechat_report_channel.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ImLivechatReportChannel represents im_livechat.report.channel model. type ImLivechatReportChannel struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -51,7 +47,7 @@ func (c *Client) CreateImLivechatReportChannels(ircs []*ImLivechatReportChannel) for _, v := range ircs { vv = append(vv, v) } - return c.Create(ImLivechatReportChannelModel, vv) + return c.Create(ImLivechatReportChannelModel, vv, nil) } // UpdateImLivechatReportChannel updates an existing im_livechat.report.channel record. @@ -62,7 +58,7 @@ func (c *Client) UpdateImLivechatReportChannel(irc *ImLivechatReportChannel) err // UpdateImLivechatReportChannels updates existing im_livechat.report.channel records. // All records (represented by ids) will be updated by irc values. func (c *Client) UpdateImLivechatReportChannels(ids []int64, irc *ImLivechatReportChannel) error { - return c.Update(ImLivechatReportChannelModel, ids, irc) + return c.Update(ImLivechatReportChannelModel, ids, irc, nil) } // DeleteImLivechatReportChannel deletes an existing im_livechat.report.channel record. @@ -81,10 +77,7 @@ func (c *Client) GetImLivechatReportChannel(id int64) (*ImLivechatReportChannel, if err != nil { return nil, err } - if ircs != nil && len(*ircs) > 0 { - return &((*ircs)[0]), nil - } - return nil, fmt.Errorf("id %v of im_livechat.report.channel not found", id) + return &((*ircs)[0]), nil } // GetImLivechatReportChannels gets im_livechat.report.channel existing records. @@ -102,10 +95,7 @@ func (c *Client) FindImLivechatReportChannel(criteria *Criteria) (*ImLivechatRep if err := c.SearchRead(ImLivechatReportChannelModel, criteria, NewOptions().Limit(1), ircs); err != nil { return nil, err } - if ircs != nil && len(*ircs) > 0 { - return &((*ircs)[0]), nil - } - return nil, fmt.Errorf("im_livechat.report.channel was not found with criteria %v", criteria) + return &((*ircs)[0]), nil } // FindImLivechatReportChannels finds im_livechat.report.channel records by querying it @@ -121,11 +111,7 @@ func (c *Client) FindImLivechatReportChannels(criteria *Criteria, options *Optio // FindImLivechatReportChannelIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindImLivechatReportChannelIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ImLivechatReportChannelModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ImLivechatReportChannelModel, criteria, options) } // FindImLivechatReportChannelId finds record id by querying it with criteria. @@ -134,8 +120,5 @@ func (c *Client) FindImLivechatReportChannelId(criteria *Criteria, options *Opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("im_livechat.report.channel was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/im_livechat_report_operator.go b/im_livechat_report_operator.go index d79f0182..645eccbc 100644 --- a/im_livechat_report_operator.go +++ b/im_livechat_report_operator.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ImLivechatReportOperator represents im_livechat.report.operator model. type ImLivechatReportOperator struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateImLivechatReportOperators(iros []*ImLivechatReportOperato for _, v := range iros { vv = append(vv, v) } - return c.Create(ImLivechatReportOperatorModel, vv) + return c.Create(ImLivechatReportOperatorModel, vv, nil) } // UpdateImLivechatReportOperator updates an existing im_livechat.report.operator record. @@ -58,7 +54,7 @@ func (c *Client) UpdateImLivechatReportOperator(iro *ImLivechatReportOperator) e // UpdateImLivechatReportOperators updates existing im_livechat.report.operator records. // All records (represented by ids) will be updated by iro values. func (c *Client) UpdateImLivechatReportOperators(ids []int64, iro *ImLivechatReportOperator) error { - return c.Update(ImLivechatReportOperatorModel, ids, iro) + return c.Update(ImLivechatReportOperatorModel, ids, iro, nil) } // DeleteImLivechatReportOperator deletes an existing im_livechat.report.operator record. @@ -77,10 +73,7 @@ func (c *Client) GetImLivechatReportOperator(id int64) (*ImLivechatReportOperato if err != nil { return nil, err } - if iros != nil && len(*iros) > 0 { - return &((*iros)[0]), nil - } - return nil, fmt.Errorf("id %v of im_livechat.report.operator not found", id) + return &((*iros)[0]), nil } // GetImLivechatReportOperators gets im_livechat.report.operator existing records. @@ -98,10 +91,7 @@ func (c *Client) FindImLivechatReportOperator(criteria *Criteria) (*ImLivechatRe if err := c.SearchRead(ImLivechatReportOperatorModel, criteria, NewOptions().Limit(1), iros); err != nil { return nil, err } - if iros != nil && len(*iros) > 0 { - return &((*iros)[0]), nil - } - return nil, fmt.Errorf("im_livechat.report.operator was not found with criteria %v", criteria) + return &((*iros)[0]), nil } // FindImLivechatReportOperators finds im_livechat.report.operator records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindImLivechatReportOperators(criteria *Criteria, options *Opti // FindImLivechatReportOperatorIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindImLivechatReportOperatorIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ImLivechatReportOperatorModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ImLivechatReportOperatorModel, criteria, options) } // FindImLivechatReportOperatorId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindImLivechatReportOperatorId(criteria *Criteria, options *Opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("im_livechat.report.operator was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_actions_act_url.go b/ir_actions_act_url.go index 3d550bf3..fa114db3 100644 --- a/ir_actions_act_url.go +++ b/ir_actions_act_url.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrActionsActUrl represents ir.actions.act_url model. type IrActionsActUrl struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -52,7 +48,7 @@ func (c *Client) CreateIrActionsActUrls(iaas []*IrActionsActUrl) ([]int64, error for _, v := range iaas { vv = append(vv, v) } - return c.Create(IrActionsActUrlModel, vv) + return c.Create(IrActionsActUrlModel, vv, nil) } // UpdateIrActionsActUrl updates an existing ir.actions.act_url record. @@ -63,7 +59,7 @@ func (c *Client) UpdateIrActionsActUrl(iaa *IrActionsActUrl) error { // UpdateIrActionsActUrls updates existing ir.actions.act_url records. // All records (represented by ids) will be updated by iaa values. func (c *Client) UpdateIrActionsActUrls(ids []int64, iaa *IrActionsActUrl) error { - return c.Update(IrActionsActUrlModel, ids, iaa) + return c.Update(IrActionsActUrlModel, ids, iaa, nil) } // DeleteIrActionsActUrl deletes an existing ir.actions.act_url record. @@ -82,10 +78,7 @@ func (c *Client) GetIrActionsActUrl(id int64) (*IrActionsActUrl, error) { if err != nil { return nil, err } - if iaas != nil && len(*iaas) > 0 { - return &((*iaas)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.actions.act_url not found", id) + return &((*iaas)[0]), nil } // GetIrActionsActUrls gets ir.actions.act_url existing records. @@ -103,10 +96,7 @@ func (c *Client) FindIrActionsActUrl(criteria *Criteria) (*IrActionsActUrl, erro if err := c.SearchRead(IrActionsActUrlModel, criteria, NewOptions().Limit(1), iaas); err != nil { return nil, err } - if iaas != nil && len(*iaas) > 0 { - return &((*iaas)[0]), nil - } - return nil, fmt.Errorf("ir.actions.act_url was not found with criteria %v", criteria) + return &((*iaas)[0]), nil } // FindIrActionsActUrls finds ir.actions.act_url records by querying it @@ -122,11 +112,7 @@ func (c *Client) FindIrActionsActUrls(criteria *Criteria, options *Options) (*Ir // FindIrActionsActUrlIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrActionsActUrlIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrActionsActUrlModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrActionsActUrlModel, criteria, options) } // FindIrActionsActUrlId finds record id by querying it with criteria. @@ -135,8 +121,5 @@ func (c *Client) FindIrActionsActUrlId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.actions.act_url was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_actions_act_window.go b/ir_actions_act_window.go index c789e313..3d42ad7c 100644 --- a/ir_actions_act_window.go +++ b/ir_actions_act_window.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrActionsActWindow represents ir.actions.act_window model. type IrActionsActWindow struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -69,7 +65,7 @@ func (c *Client) CreateIrActionsActWindows(iaas []*IrActionsActWindow) ([]int64, for _, v := range iaas { vv = append(vv, v) } - return c.Create(IrActionsActWindowModel, vv) + return c.Create(IrActionsActWindowModel, vv, nil) } // UpdateIrActionsActWindow updates an existing ir.actions.act_window record. @@ -80,7 +76,7 @@ func (c *Client) UpdateIrActionsActWindow(iaa *IrActionsActWindow) error { // UpdateIrActionsActWindows updates existing ir.actions.act_window records. // All records (represented by ids) will be updated by iaa values. func (c *Client) UpdateIrActionsActWindows(ids []int64, iaa *IrActionsActWindow) error { - return c.Update(IrActionsActWindowModel, ids, iaa) + return c.Update(IrActionsActWindowModel, ids, iaa, nil) } // DeleteIrActionsActWindow deletes an existing ir.actions.act_window record. @@ -99,10 +95,7 @@ func (c *Client) GetIrActionsActWindow(id int64) (*IrActionsActWindow, error) { if err != nil { return nil, err } - if iaas != nil && len(*iaas) > 0 { - return &((*iaas)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.actions.act_window not found", id) + return &((*iaas)[0]), nil } // GetIrActionsActWindows gets ir.actions.act_window existing records. @@ -120,10 +113,7 @@ func (c *Client) FindIrActionsActWindow(criteria *Criteria) (*IrActionsActWindow if err := c.SearchRead(IrActionsActWindowModel, criteria, NewOptions().Limit(1), iaas); err != nil { return nil, err } - if iaas != nil && len(*iaas) > 0 { - return &((*iaas)[0]), nil - } - return nil, fmt.Errorf("ir.actions.act_window was not found with criteria %v", criteria) + return &((*iaas)[0]), nil } // FindIrActionsActWindows finds ir.actions.act_window records by querying it @@ -139,11 +129,7 @@ func (c *Client) FindIrActionsActWindows(criteria *Criteria, options *Options) ( // FindIrActionsActWindowIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrActionsActWindowIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrActionsActWindowModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrActionsActWindowModel, criteria, options) } // FindIrActionsActWindowId finds record id by querying it with criteria. @@ -152,8 +138,5 @@ func (c *Client) FindIrActionsActWindowId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.actions.act_window was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_actions_act_window_close.go b/ir_actions_act_window_close.go index 6bdd63b8..b784d670 100644 --- a/ir_actions_act_window_close.go +++ b/ir_actions_act_window_close.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrActionsActWindowClose represents ir.actions.act_window_close model. type IrActionsActWindowClose struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateIrActionsActWindowCloses(iaas []*IrActionsActWindowClose) for _, v := range iaas { vv = append(vv, v) } - return c.Create(IrActionsActWindowCloseModel, vv) + return c.Create(IrActionsActWindowCloseModel, vv, nil) } // UpdateIrActionsActWindowClose updates an existing ir.actions.act_window_close record. @@ -61,7 +57,7 @@ func (c *Client) UpdateIrActionsActWindowClose(iaa *IrActionsActWindowClose) err // UpdateIrActionsActWindowCloses updates existing ir.actions.act_window_close records. // All records (represented by ids) will be updated by iaa values. func (c *Client) UpdateIrActionsActWindowCloses(ids []int64, iaa *IrActionsActWindowClose) error { - return c.Update(IrActionsActWindowCloseModel, ids, iaa) + return c.Update(IrActionsActWindowCloseModel, ids, iaa, nil) } // DeleteIrActionsActWindowClose deletes an existing ir.actions.act_window_close record. @@ -80,10 +76,7 @@ func (c *Client) GetIrActionsActWindowClose(id int64) (*IrActionsActWindowClose, if err != nil { return nil, err } - if iaas != nil && len(*iaas) > 0 { - return &((*iaas)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.actions.act_window_close not found", id) + return &((*iaas)[0]), nil } // GetIrActionsActWindowCloses gets ir.actions.act_window_close existing records. @@ -101,10 +94,7 @@ func (c *Client) FindIrActionsActWindowClose(criteria *Criteria) (*IrActionsActW if err := c.SearchRead(IrActionsActWindowCloseModel, criteria, NewOptions().Limit(1), iaas); err != nil { return nil, err } - if iaas != nil && len(*iaas) > 0 { - return &((*iaas)[0]), nil - } - return nil, fmt.Errorf("ir.actions.act_window_close was not found with criteria %v", criteria) + return &((*iaas)[0]), nil } // FindIrActionsActWindowCloses finds ir.actions.act_window_close records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindIrActionsActWindowCloses(criteria *Criteria, options *Optio // FindIrActionsActWindowCloseIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrActionsActWindowCloseIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrActionsActWindowCloseModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrActionsActWindowCloseModel, criteria, options) } // FindIrActionsActWindowCloseId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindIrActionsActWindowCloseId(criteria *Criteria, options *Opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.actions.act_window_close was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_actions_act_window_view.go b/ir_actions_act_window_view.go index e40be269..9d9da8af 100644 --- a/ir_actions_act_window_view.go +++ b/ir_actions_act_window_view.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrActionsActWindowView represents ir.actions.act_window.view model. type IrActionsActWindowView struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateIrActionsActWindowViews(iaavs []*IrActionsActWindowView) for _, v := range iaavs { vv = append(vv, v) } - return c.Create(IrActionsActWindowViewModel, vv) + return c.Create(IrActionsActWindowViewModel, vv, nil) } // UpdateIrActionsActWindowView updates an existing ir.actions.act_window.view record. @@ -60,7 +56,7 @@ func (c *Client) UpdateIrActionsActWindowView(iaav *IrActionsActWindowView) erro // UpdateIrActionsActWindowViews updates existing ir.actions.act_window.view records. // All records (represented by ids) will be updated by iaav values. func (c *Client) UpdateIrActionsActWindowViews(ids []int64, iaav *IrActionsActWindowView) error { - return c.Update(IrActionsActWindowViewModel, ids, iaav) + return c.Update(IrActionsActWindowViewModel, ids, iaav, nil) } // DeleteIrActionsActWindowView deletes an existing ir.actions.act_window.view record. @@ -79,10 +75,7 @@ func (c *Client) GetIrActionsActWindowView(id int64) (*IrActionsActWindowView, e if err != nil { return nil, err } - if iaavs != nil && len(*iaavs) > 0 { - return &((*iaavs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.actions.act_window.view not found", id) + return &((*iaavs)[0]), nil } // GetIrActionsActWindowViews gets ir.actions.act_window.view existing records. @@ -100,10 +93,7 @@ func (c *Client) FindIrActionsActWindowView(criteria *Criteria) (*IrActionsActWi if err := c.SearchRead(IrActionsActWindowViewModel, criteria, NewOptions().Limit(1), iaavs); err != nil { return nil, err } - if iaavs != nil && len(*iaavs) > 0 { - return &((*iaavs)[0]), nil - } - return nil, fmt.Errorf("ir.actions.act_window.view was not found with criteria %v", criteria) + return &((*iaavs)[0]), nil } // FindIrActionsActWindowViews finds ir.actions.act_window.view records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindIrActionsActWindowViews(criteria *Criteria, options *Option // FindIrActionsActWindowViewIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrActionsActWindowViewIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrActionsActWindowViewModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrActionsActWindowViewModel, criteria, options) } // FindIrActionsActWindowViewId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindIrActionsActWindowViewId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.actions.act_window.view was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_actions_actions.go b/ir_actions_actions.go index 67a48fcf..f030da19 100644 --- a/ir_actions_actions.go +++ b/ir_actions_actions.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrActionsActions represents ir.actions.actions model. type IrActionsActions struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateIrActionsActionss(iaas []*IrActionsActions) ([]int64, err for _, v := range iaas { vv = append(vv, v) } - return c.Create(IrActionsActionsModel, vv) + return c.Create(IrActionsActionsModel, vv, nil) } // UpdateIrActionsActions updates an existing ir.actions.actions record. @@ -61,7 +57,7 @@ func (c *Client) UpdateIrActionsActions(iaa *IrActionsActions) error { // UpdateIrActionsActionss updates existing ir.actions.actions records. // All records (represented by ids) will be updated by iaa values. func (c *Client) UpdateIrActionsActionss(ids []int64, iaa *IrActionsActions) error { - return c.Update(IrActionsActionsModel, ids, iaa) + return c.Update(IrActionsActionsModel, ids, iaa, nil) } // DeleteIrActionsActions deletes an existing ir.actions.actions record. @@ -80,10 +76,7 @@ func (c *Client) GetIrActionsActions(id int64) (*IrActionsActions, error) { if err != nil { return nil, err } - if iaas != nil && len(*iaas) > 0 { - return &((*iaas)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.actions.actions not found", id) + return &((*iaas)[0]), nil } // GetIrActionsActionss gets ir.actions.actions existing records. @@ -101,10 +94,7 @@ func (c *Client) FindIrActionsActions(criteria *Criteria) (*IrActionsActions, er if err := c.SearchRead(IrActionsActionsModel, criteria, NewOptions().Limit(1), iaas); err != nil { return nil, err } - if iaas != nil && len(*iaas) > 0 { - return &((*iaas)[0]), nil - } - return nil, fmt.Errorf("ir.actions.actions was not found with criteria %v", criteria) + return &((*iaas)[0]), nil } // FindIrActionsActionss finds ir.actions.actions records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindIrActionsActionss(criteria *Criteria, options *Options) (*I // FindIrActionsActionsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrActionsActionsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrActionsActionsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrActionsActionsModel, criteria, options) } // FindIrActionsActionsId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindIrActionsActionsId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.actions.actions was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_actions_client.go b/ir_actions_client.go index a69448e5..00b1eb1b 100644 --- a/ir_actions_client.go +++ b/ir_actions_client.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrActionsClient represents ir.actions.client model. type IrActionsClient struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -56,7 +52,7 @@ func (c *Client) CreateIrActionsClients(iacs []*IrActionsClient) ([]int64, error for _, v := range iacs { vv = append(vv, v) } - return c.Create(IrActionsClientModel, vv) + return c.Create(IrActionsClientModel, vv, nil) } // UpdateIrActionsClient updates an existing ir.actions.client record. @@ -67,7 +63,7 @@ func (c *Client) UpdateIrActionsClient(iac *IrActionsClient) error { // UpdateIrActionsClients updates existing ir.actions.client records. // All records (represented by ids) will be updated by iac values. func (c *Client) UpdateIrActionsClients(ids []int64, iac *IrActionsClient) error { - return c.Update(IrActionsClientModel, ids, iac) + return c.Update(IrActionsClientModel, ids, iac, nil) } // DeleteIrActionsClient deletes an existing ir.actions.client record. @@ -86,10 +82,7 @@ func (c *Client) GetIrActionsClient(id int64) (*IrActionsClient, error) { if err != nil { return nil, err } - if iacs != nil && len(*iacs) > 0 { - return &((*iacs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.actions.client not found", id) + return &((*iacs)[0]), nil } // GetIrActionsClients gets ir.actions.client existing records. @@ -107,10 +100,7 @@ func (c *Client) FindIrActionsClient(criteria *Criteria) (*IrActionsClient, erro if err := c.SearchRead(IrActionsClientModel, criteria, NewOptions().Limit(1), iacs); err != nil { return nil, err } - if iacs != nil && len(*iacs) > 0 { - return &((*iacs)[0]), nil - } - return nil, fmt.Errorf("ir.actions.client was not found with criteria %v", criteria) + return &((*iacs)[0]), nil } // FindIrActionsClients finds ir.actions.client records by querying it @@ -126,11 +116,7 @@ func (c *Client) FindIrActionsClients(criteria *Criteria, options *Options) (*Ir // FindIrActionsClientIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrActionsClientIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrActionsClientModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrActionsClientModel, criteria, options) } // FindIrActionsClientId finds record id by querying it with criteria. @@ -139,8 +125,5 @@ func (c *Client) FindIrActionsClientId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.actions.client was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_actions_report.go b/ir_actions_report.go index cddf8736..da150470 100644 --- a/ir_actions_report.go +++ b/ir_actions_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrActionsReport represents ir.actions.report model. type IrActionsReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -60,7 +56,7 @@ func (c *Client) CreateIrActionsReports(iars []*IrActionsReport) ([]int64, error for _, v := range iars { vv = append(vv, v) } - return c.Create(IrActionsReportModel, vv) + return c.Create(IrActionsReportModel, vv, nil) } // UpdateIrActionsReport updates an existing ir.actions.report record. @@ -71,7 +67,7 @@ func (c *Client) UpdateIrActionsReport(iar *IrActionsReport) error { // UpdateIrActionsReports updates existing ir.actions.report records. // All records (represented by ids) will be updated by iar values. func (c *Client) UpdateIrActionsReports(ids []int64, iar *IrActionsReport) error { - return c.Update(IrActionsReportModel, ids, iar) + return c.Update(IrActionsReportModel, ids, iar, nil) } // DeleteIrActionsReport deletes an existing ir.actions.report record. @@ -90,10 +86,7 @@ func (c *Client) GetIrActionsReport(id int64) (*IrActionsReport, error) { if err != nil { return nil, err } - if iars != nil && len(*iars) > 0 { - return &((*iars)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.actions.report not found", id) + return &((*iars)[0]), nil } // GetIrActionsReports gets ir.actions.report existing records. @@ -111,10 +104,7 @@ func (c *Client) FindIrActionsReport(criteria *Criteria) (*IrActionsReport, erro if err := c.SearchRead(IrActionsReportModel, criteria, NewOptions().Limit(1), iars); err != nil { return nil, err } - if iars != nil && len(*iars) > 0 { - return &((*iars)[0]), nil - } - return nil, fmt.Errorf("ir.actions.report was not found with criteria %v", criteria) + return &((*iars)[0]), nil } // FindIrActionsReports finds ir.actions.report records by querying it @@ -130,11 +120,7 @@ func (c *Client) FindIrActionsReports(criteria *Criteria, options *Options) (*Ir // FindIrActionsReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrActionsReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrActionsReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrActionsReportModel, criteria, options) } // FindIrActionsReportId finds record id by querying it with criteria. @@ -143,8 +129,5 @@ func (c *Client) FindIrActionsReportId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.actions.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_actions_server.go b/ir_actions_server.go index 4103a19f..513b83ac 100644 --- a/ir_actions_server.go +++ b/ir_actions_server.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrActionsServer represents ir.actions.server model. type IrActionsServer struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -64,7 +60,7 @@ func (c *Client) CreateIrActionsServers(iass []*IrActionsServer) ([]int64, error for _, v := range iass { vv = append(vv, v) } - return c.Create(IrActionsServerModel, vv) + return c.Create(IrActionsServerModel, vv, nil) } // UpdateIrActionsServer updates an existing ir.actions.server record. @@ -75,7 +71,7 @@ func (c *Client) UpdateIrActionsServer(ias *IrActionsServer) error { // UpdateIrActionsServers updates existing ir.actions.server records. // All records (represented by ids) will be updated by ias values. func (c *Client) UpdateIrActionsServers(ids []int64, ias *IrActionsServer) error { - return c.Update(IrActionsServerModel, ids, ias) + return c.Update(IrActionsServerModel, ids, ias, nil) } // DeleteIrActionsServer deletes an existing ir.actions.server record. @@ -94,10 +90,7 @@ func (c *Client) GetIrActionsServer(id int64) (*IrActionsServer, error) { if err != nil { return nil, err } - if iass != nil && len(*iass) > 0 { - return &((*iass)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.actions.server not found", id) + return &((*iass)[0]), nil } // GetIrActionsServers gets ir.actions.server existing records. @@ -115,10 +108,7 @@ func (c *Client) FindIrActionsServer(criteria *Criteria) (*IrActionsServer, erro if err := c.SearchRead(IrActionsServerModel, criteria, NewOptions().Limit(1), iass); err != nil { return nil, err } - if iass != nil && len(*iass) > 0 { - return &((*iass)[0]), nil - } - return nil, fmt.Errorf("ir.actions.server was not found with criteria %v", criteria) + return &((*iass)[0]), nil } // FindIrActionsServers finds ir.actions.server records by querying it @@ -134,11 +124,7 @@ func (c *Client) FindIrActionsServers(criteria *Criteria, options *Options) (*Ir // FindIrActionsServerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrActionsServerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrActionsServerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrActionsServerModel, criteria, options) } // FindIrActionsServerId finds record id by querying it with criteria. @@ -147,8 +133,5 @@ func (c *Client) FindIrActionsServerId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.actions.server was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_actions_todo.go b/ir_actions_todo.go index 5cffb47a..aa9af818 100644 --- a/ir_actions_todo.go +++ b/ir_actions_todo.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrActionsTodo represents ir.actions.todo model. type IrActionsTodo struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateIrActionsTodos(iats []*IrActionsTodo) ([]int64, error) { for _, v := range iats { vv = append(vv, v) } - return c.Create(IrActionsTodoModel, vv) + return c.Create(IrActionsTodoModel, vv, nil) } // UpdateIrActionsTodo updates an existing ir.actions.todo record. @@ -59,7 +55,7 @@ func (c *Client) UpdateIrActionsTodo(iat *IrActionsTodo) error { // UpdateIrActionsTodos updates existing ir.actions.todo records. // All records (represented by ids) will be updated by iat values. func (c *Client) UpdateIrActionsTodos(ids []int64, iat *IrActionsTodo) error { - return c.Update(IrActionsTodoModel, ids, iat) + return c.Update(IrActionsTodoModel, ids, iat, nil) } // DeleteIrActionsTodo deletes an existing ir.actions.todo record. @@ -78,10 +74,7 @@ func (c *Client) GetIrActionsTodo(id int64) (*IrActionsTodo, error) { if err != nil { return nil, err } - if iats != nil && len(*iats) > 0 { - return &((*iats)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.actions.todo not found", id) + return &((*iats)[0]), nil } // GetIrActionsTodos gets ir.actions.todo existing records. @@ -99,10 +92,7 @@ func (c *Client) FindIrActionsTodo(criteria *Criteria) (*IrActionsTodo, error) { if err := c.SearchRead(IrActionsTodoModel, criteria, NewOptions().Limit(1), iats); err != nil { return nil, err } - if iats != nil && len(*iats) > 0 { - return &((*iats)[0]), nil - } - return nil, fmt.Errorf("ir.actions.todo was not found with criteria %v", criteria) + return &((*iats)[0]), nil } // FindIrActionsTodos finds ir.actions.todo records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindIrActionsTodos(criteria *Criteria, options *Options) (*IrAc // FindIrActionsTodoIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrActionsTodoIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrActionsTodoModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrActionsTodoModel, criteria, options) } // FindIrActionsTodoId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindIrActionsTodoId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.actions.todo was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_attachment.go b/ir_attachment.go index d86eacd6..2255d5a1 100644 --- a/ir_attachment.go +++ b/ir_attachment.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrAttachment represents ir.attachment model. type IrAttachment struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -64,7 +60,7 @@ func (c *Client) CreateIrAttachments(ias []*IrAttachment) ([]int64, error) { for _, v := range ias { vv = append(vv, v) } - return c.Create(IrAttachmentModel, vv) + return c.Create(IrAttachmentModel, vv, nil) } // UpdateIrAttachment updates an existing ir.attachment record. @@ -75,7 +71,7 @@ func (c *Client) UpdateIrAttachment(ia *IrAttachment) error { // UpdateIrAttachments updates existing ir.attachment records. // All records (represented by ids) will be updated by ia values. func (c *Client) UpdateIrAttachments(ids []int64, ia *IrAttachment) error { - return c.Update(IrAttachmentModel, ids, ia) + return c.Update(IrAttachmentModel, ids, ia, nil) } // DeleteIrAttachment deletes an existing ir.attachment record. @@ -94,10 +90,7 @@ func (c *Client) GetIrAttachment(id int64) (*IrAttachment, error) { if err != nil { return nil, err } - if ias != nil && len(*ias) > 0 { - return &((*ias)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.attachment not found", id) + return &((*ias)[0]), nil } // GetIrAttachments gets ir.attachment existing records. @@ -115,10 +108,7 @@ func (c *Client) FindIrAttachment(criteria *Criteria) (*IrAttachment, error) { if err := c.SearchRead(IrAttachmentModel, criteria, NewOptions().Limit(1), ias); err != nil { return nil, err } - if ias != nil && len(*ias) > 0 { - return &((*ias)[0]), nil - } - return nil, fmt.Errorf("ir.attachment was not found with criteria %v", criteria) + return &((*ias)[0]), nil } // FindIrAttachments finds ir.attachment records by querying it @@ -134,11 +124,7 @@ func (c *Client) FindIrAttachments(criteria *Criteria, options *Options) (*IrAtt // FindIrAttachmentIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrAttachmentIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrAttachmentModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrAttachmentModel, criteria, options) } // FindIrAttachmentId finds record id by querying it with criteria. @@ -147,8 +133,5 @@ func (c *Client) FindIrAttachmentId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.attachment was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_autovacuum.go b/ir_autovacuum.go index 2561c90a..b60f842c 100644 --- a/ir_autovacuum.go +++ b/ir_autovacuum.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrAutovacuum represents ir.autovacuum model. type IrAutovacuum struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrAutovacuums(ias []*IrAutovacuum) ([]int64, error) { for _, v := range ias { vv = append(vv, v) } - return c.Create(IrAutovacuumModel, vv) + return c.Create(IrAutovacuumModel, vv, nil) } // UpdateIrAutovacuum updates an existing ir.autovacuum record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrAutovacuum(ia *IrAutovacuum) error { // UpdateIrAutovacuums updates existing ir.autovacuum records. // All records (represented by ids) will be updated by ia values. func (c *Client) UpdateIrAutovacuums(ids []int64, ia *IrAutovacuum) error { - return c.Update(IrAutovacuumModel, ids, ia) + return c.Update(IrAutovacuumModel, ids, ia, nil) } // DeleteIrAutovacuum deletes an existing ir.autovacuum record. @@ -70,10 +66,7 @@ func (c *Client) GetIrAutovacuum(id int64) (*IrAutovacuum, error) { if err != nil { return nil, err } - if ias != nil && len(*ias) > 0 { - return &((*ias)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.autovacuum not found", id) + return &((*ias)[0]), nil } // GetIrAutovacuums gets ir.autovacuum existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrAutovacuum(criteria *Criteria) (*IrAutovacuum, error) { if err := c.SearchRead(IrAutovacuumModel, criteria, NewOptions().Limit(1), ias); err != nil { return nil, err } - if ias != nil && len(*ias) > 0 { - return &((*ias)[0]), nil - } - return nil, fmt.Errorf("ir.autovacuum was not found with criteria %v", criteria) + return &((*ias)[0]), nil } // FindIrAutovacuums finds ir.autovacuum records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrAutovacuums(criteria *Criteria, options *Options) (*IrAut // FindIrAutovacuumIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrAutovacuumIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrAutovacuumModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrAutovacuumModel, criteria, options) } // FindIrAutovacuumId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrAutovacuumId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.autovacuum was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_config_parameter.go b/ir_config_parameter.go index 7076b3fb..418f7cf2 100644 --- a/ir_config_parameter.go +++ b/ir_config_parameter.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrConfigParameter represents ir.config_parameter model. type IrConfigParameter struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateIrConfigParameters(ics []*IrConfigParameter) ([]int64, er for _, v := range ics { vv = append(vv, v) } - return c.Create(IrConfigParameterModel, vv) + return c.Create(IrConfigParameterModel, vv, nil) } // UpdateIrConfigParameter updates an existing ir.config_parameter record. @@ -57,7 +53,7 @@ func (c *Client) UpdateIrConfigParameter(ic *IrConfigParameter) error { // UpdateIrConfigParameters updates existing ir.config_parameter records. // All records (represented by ids) will be updated by ic values. func (c *Client) UpdateIrConfigParameters(ids []int64, ic *IrConfigParameter) error { - return c.Update(IrConfigParameterModel, ids, ic) + return c.Update(IrConfigParameterModel, ids, ic, nil) } // DeleteIrConfigParameter deletes an existing ir.config_parameter record. @@ -76,10 +72,7 @@ func (c *Client) GetIrConfigParameter(id int64) (*IrConfigParameter, error) { if err != nil { return nil, err } - if ics != nil && len(*ics) > 0 { - return &((*ics)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.config_parameter not found", id) + return &((*ics)[0]), nil } // GetIrConfigParameters gets ir.config_parameter existing records. @@ -97,10 +90,7 @@ func (c *Client) FindIrConfigParameter(criteria *Criteria) (*IrConfigParameter, if err := c.SearchRead(IrConfigParameterModel, criteria, NewOptions().Limit(1), ics); err != nil { return nil, err } - if ics != nil && len(*ics) > 0 { - return &((*ics)[0]), nil - } - return nil, fmt.Errorf("ir.config_parameter was not found with criteria %v", criteria) + return &((*ics)[0]), nil } // FindIrConfigParameters finds ir.config_parameter records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindIrConfigParameters(criteria *Criteria, options *Options) (* // FindIrConfigParameterIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrConfigParameterIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrConfigParameterModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrConfigParameterModel, criteria, options) } // FindIrConfigParameterId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindIrConfigParameterId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.config_parameter was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_cron.go b/ir_cron.go index b71468e1..133702b0 100644 --- a/ir_cron.go +++ b/ir_cron.go @@ -1,15 +1,12 @@ package odoo -import ( - "fmt" -) - // IrCron represents ir.cron model. type IrCron struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` Active *Bool `xmlrpc:"active,omptempty"` BindingModelId *Many2One `xmlrpc:"binding_model_id,omptempty"` BindingType *Selection `xmlrpc:"binding_type,omptempty"` + ChannelIds *Relation `xmlrpc:"channel_ids,omptempty"` ChildIds *Relation `xmlrpc:"child_ids,omptempty"` Code *String `xmlrpc:"code,omptempty"` CreateDate *Time `xmlrpc:"create_date,omptempty"` @@ -31,9 +28,11 @@ type IrCron struct { Name *String `xmlrpc:"name,omptempty"` Nextcall *Time `xmlrpc:"nextcall,omptempty"` Numbercall *Int `xmlrpc:"numbercall,omptempty"` + PartnerIds *Relation `xmlrpc:"partner_ids,omptempty"` Priority *Int `xmlrpc:"priority,omptempty"` Sequence *Int `xmlrpc:"sequence,omptempty"` State *Selection `xmlrpc:"state,omptempty"` + TemplateId *Many2One `xmlrpc:"template_id,omptempty"` Type *String `xmlrpc:"type,omptempty"` Usage *Selection `xmlrpc:"usage,omptempty"` UserId *Many2One `xmlrpc:"user_id,omptempty"` @@ -71,7 +70,7 @@ func (c *Client) CreateIrCrons(ics []*IrCron) ([]int64, error) { for _, v := range ics { vv = append(vv, v) } - return c.Create(IrCronModel, vv) + return c.Create(IrCronModel, vv, nil) } // UpdateIrCron updates an existing ir.cron record. @@ -82,7 +81,7 @@ func (c *Client) UpdateIrCron(ic *IrCron) error { // UpdateIrCrons updates existing ir.cron records. // All records (represented by ids) will be updated by ic values. func (c *Client) UpdateIrCrons(ids []int64, ic *IrCron) error { - return c.Update(IrCronModel, ids, ic) + return c.Update(IrCronModel, ids, ic, nil) } // DeleteIrCron deletes an existing ir.cron record. @@ -101,10 +100,7 @@ func (c *Client) GetIrCron(id int64) (*IrCron, error) { if err != nil { return nil, err } - if ics != nil && len(*ics) > 0 { - return &((*ics)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.cron not found", id) + return &((*ics)[0]), nil } // GetIrCrons gets ir.cron existing records. @@ -122,10 +118,7 @@ func (c *Client) FindIrCron(criteria *Criteria) (*IrCron, error) { if err := c.SearchRead(IrCronModel, criteria, NewOptions().Limit(1), ics); err != nil { return nil, err } - if ics != nil && len(*ics) > 0 { - return &((*ics)[0]), nil - } - return nil, fmt.Errorf("ir.cron was not found with criteria %v", criteria) + return &((*ics)[0]), nil } // FindIrCrons finds ir.cron records by querying it @@ -141,11 +134,7 @@ func (c *Client) FindIrCrons(criteria *Criteria, options *Options) (*IrCrons, er // FindIrCronIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrCronIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrCronModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrCronModel, criteria, options) } // FindIrCronId finds record id by querying it with criteria. @@ -154,8 +143,5 @@ func (c *Client) FindIrCronId(criteria *Criteria, options *Options) (int64, erro if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.cron was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_default.go b/ir_default.go index 0486616a..4c6d49ed 100644 --- a/ir_default.go +++ b/ir_default.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrDefault represents ir.default model. type IrDefault struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateIrDefaults(IDs []*IrDefault) ([]int64, error) { for _, v := range IDs { vv = append(vv, v) } - return c.Create(IrDefaultModel, vv) + return c.Create(IrDefaultModel, vv, nil) } // UpdateIrDefault updates an existing ir.default record. @@ -60,7 +56,7 @@ func (c *Client) UpdateIrDefault(ID *IrDefault) error { // UpdateIrDefaults updates existing ir.default records. // All records (represented by ids) will be updated by ID values. func (c *Client) UpdateIrDefaults(ids []int64, ID *IrDefault) error { - return c.Update(IrDefaultModel, ids, ID) + return c.Update(IrDefaultModel, ids, ID, nil) } // DeleteIrDefault deletes an existing ir.default record. @@ -79,10 +75,7 @@ func (c *Client) GetIrDefault(id int64) (*IrDefault, error) { if err != nil { return nil, err } - if IDs != nil && len(*IDs) > 0 { - return &((*IDs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.default not found", id) + return &((*IDs)[0]), nil } // GetIrDefaults gets ir.default existing records. @@ -100,10 +93,7 @@ func (c *Client) FindIrDefault(criteria *Criteria) (*IrDefault, error) { if err := c.SearchRead(IrDefaultModel, criteria, NewOptions().Limit(1), IDs); err != nil { return nil, err } - if IDs != nil && len(*IDs) > 0 { - return &((*IDs)[0]), nil - } - return nil, fmt.Errorf("ir.default was not found with criteria %v", criteria) + return &((*IDs)[0]), nil } // FindIrDefaults finds ir.default records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindIrDefaults(criteria *Criteria, options *Options) (*IrDefaul // FindIrDefaultIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrDefaultIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrDefaultModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrDefaultModel, criteria, options) } // FindIrDefaultId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindIrDefaultId(criteria *Criteria, options *Options) (int64, e if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.default was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_exports.go b/ir_exports.go index abd7b649..b8becf83 100644 --- a/ir_exports.go +++ b/ir_exports.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrExports represents ir.exports model. type IrExports struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateIrExportss(ies []*IrExports) ([]int64, error) { for _, v := range ies { vv = append(vv, v) } - return c.Create(IrExportsModel, vv) + return c.Create(IrExportsModel, vv, nil) } // UpdateIrExports updates an existing ir.exports record. @@ -58,7 +54,7 @@ func (c *Client) UpdateIrExports(ie *IrExports) error { // UpdateIrExportss updates existing ir.exports records. // All records (represented by ids) will be updated by ie values. func (c *Client) UpdateIrExportss(ids []int64, ie *IrExports) error { - return c.Update(IrExportsModel, ids, ie) + return c.Update(IrExportsModel, ids, ie, nil) } // DeleteIrExports deletes an existing ir.exports record. @@ -77,10 +73,7 @@ func (c *Client) GetIrExports(id int64) (*IrExports, error) { if err != nil { return nil, err } - if ies != nil && len(*ies) > 0 { - return &((*ies)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.exports not found", id) + return &((*ies)[0]), nil } // GetIrExportss gets ir.exports existing records. @@ -98,10 +91,7 @@ func (c *Client) FindIrExports(criteria *Criteria) (*IrExports, error) { if err := c.SearchRead(IrExportsModel, criteria, NewOptions().Limit(1), ies); err != nil { return nil, err } - if ies != nil && len(*ies) > 0 { - return &((*ies)[0]), nil - } - return nil, fmt.Errorf("ir.exports was not found with criteria %v", criteria) + return &((*ies)[0]), nil } // FindIrExportss finds ir.exports records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindIrExportss(criteria *Criteria, options *Options) (*IrExport // FindIrExportsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrExportsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrExportsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrExportsModel, criteria, options) } // FindIrExportsId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindIrExportsId(criteria *Criteria, options *Options) (int64, e if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.exports was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_exports_line.go b/ir_exports_line.go index c47a52d8..2ba1d499 100644 --- a/ir_exports_line.go +++ b/ir_exports_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrExportsLine represents ir.exports.line model. type IrExportsLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateIrExportsLines(iels []*IrExportsLine) ([]int64, error) { for _, v := range iels { vv = append(vv, v) } - return c.Create(IrExportsLineModel, vv) + return c.Create(IrExportsLineModel, vv, nil) } // UpdateIrExportsLine updates an existing ir.exports.line record. @@ -57,7 +53,7 @@ func (c *Client) UpdateIrExportsLine(iel *IrExportsLine) error { // UpdateIrExportsLines updates existing ir.exports.line records. // All records (represented by ids) will be updated by iel values. func (c *Client) UpdateIrExportsLines(ids []int64, iel *IrExportsLine) error { - return c.Update(IrExportsLineModel, ids, iel) + return c.Update(IrExportsLineModel, ids, iel, nil) } // DeleteIrExportsLine deletes an existing ir.exports.line record. @@ -76,10 +72,7 @@ func (c *Client) GetIrExportsLine(id int64) (*IrExportsLine, error) { if err != nil { return nil, err } - if iels != nil && len(*iels) > 0 { - return &((*iels)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.exports.line not found", id) + return &((*iels)[0]), nil } // GetIrExportsLines gets ir.exports.line existing records. @@ -97,10 +90,7 @@ func (c *Client) FindIrExportsLine(criteria *Criteria) (*IrExportsLine, error) { if err := c.SearchRead(IrExportsLineModel, criteria, NewOptions().Limit(1), iels); err != nil { return nil, err } - if iels != nil && len(*iels) > 0 { - return &((*iels)[0]), nil - } - return nil, fmt.Errorf("ir.exports.line was not found with criteria %v", criteria) + return &((*iels)[0]), nil } // FindIrExportsLines finds ir.exports.line records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindIrExportsLines(criteria *Criteria, options *Options) (*IrEx // FindIrExportsLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrExportsLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrExportsLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrExportsLineModel, criteria, options) } // FindIrExportsLineId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindIrExportsLineId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.exports.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_fields_converter.go b/ir_fields_converter.go index 5ea8f0c4..c7aff1d6 100644 --- a/ir_fields_converter.go +++ b/ir_fields_converter.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrFieldsConverter represents ir.fields.converter model. type IrFieldsConverter struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrFieldsConverters(ifcs []*IrFieldsConverter) ([]int64, e for _, v := range ifcs { vv = append(vv, v) } - return c.Create(IrFieldsConverterModel, vv) + return c.Create(IrFieldsConverterModel, vv, nil) } // UpdateIrFieldsConverter updates an existing ir.fields.converter record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrFieldsConverter(ifc *IrFieldsConverter) error { // UpdateIrFieldsConverters updates existing ir.fields.converter records. // All records (represented by ids) will be updated by ifc values. func (c *Client) UpdateIrFieldsConverters(ids []int64, ifc *IrFieldsConverter) error { - return c.Update(IrFieldsConverterModel, ids, ifc) + return c.Update(IrFieldsConverterModel, ids, ifc, nil) } // DeleteIrFieldsConverter deletes an existing ir.fields.converter record. @@ -70,10 +66,7 @@ func (c *Client) GetIrFieldsConverter(id int64) (*IrFieldsConverter, error) { if err != nil { return nil, err } - if ifcs != nil && len(*ifcs) > 0 { - return &((*ifcs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.fields.converter not found", id) + return &((*ifcs)[0]), nil } // GetIrFieldsConverters gets ir.fields.converter existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrFieldsConverter(criteria *Criteria) (*IrFieldsConverter, if err := c.SearchRead(IrFieldsConverterModel, criteria, NewOptions().Limit(1), ifcs); err != nil { return nil, err } - if ifcs != nil && len(*ifcs) > 0 { - return &((*ifcs)[0]), nil - } - return nil, fmt.Errorf("ir.fields.converter was not found with criteria %v", criteria) + return &((*ifcs)[0]), nil } // FindIrFieldsConverters finds ir.fields.converter records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrFieldsConverters(criteria *Criteria, options *Options) (* // FindIrFieldsConverterIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrFieldsConverterIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrFieldsConverterModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrFieldsConverterModel, criteria, options) } // FindIrFieldsConverterId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrFieldsConverterId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.fields.converter was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_filters.go b/ir_filters.go index 852d19af..9e181629 100644 --- a/ir_filters.go +++ b/ir_filters.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrFilters represents ir.filters model. type IrFilters struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -53,7 +49,7 @@ func (c *Client) CreateIrFilterss(IFs []*IrFilters) ([]int64, error) { for _, v := range IFs { vv = append(vv, v) } - return c.Create(IrFiltersModel, vv) + return c.Create(IrFiltersModel, vv, nil) } // UpdateIrFilters updates an existing ir.filters record. @@ -64,7 +60,7 @@ func (c *Client) UpdateIrFilters(IF *IrFilters) error { // UpdateIrFilterss updates existing ir.filters records. // All records (represented by ids) will be updated by IF values. func (c *Client) UpdateIrFilterss(ids []int64, IF *IrFilters) error { - return c.Update(IrFiltersModel, ids, IF) + return c.Update(IrFiltersModel, ids, IF, nil) } // DeleteIrFilters deletes an existing ir.filters record. @@ -83,10 +79,7 @@ func (c *Client) GetIrFilters(id int64) (*IrFilters, error) { if err != nil { return nil, err } - if IFs != nil && len(*IFs) > 0 { - return &((*IFs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.filters not found", id) + return &((*IFs)[0]), nil } // GetIrFilterss gets ir.filters existing records. @@ -104,10 +97,7 @@ func (c *Client) FindIrFilters(criteria *Criteria) (*IrFilters, error) { if err := c.SearchRead(IrFiltersModel, criteria, NewOptions().Limit(1), IFs); err != nil { return nil, err } - if IFs != nil && len(*IFs) > 0 { - return &((*IFs)[0]), nil - } - return nil, fmt.Errorf("ir.filters was not found with criteria %v", criteria) + return &((*IFs)[0]), nil } // FindIrFilterss finds ir.filters records by querying it @@ -123,11 +113,7 @@ func (c *Client) FindIrFilterss(criteria *Criteria, options *Options) (*IrFilter // FindIrFiltersIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrFiltersIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrFiltersModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrFiltersModel, criteria, options) } // FindIrFiltersId finds record id by querying it with criteria. @@ -136,8 +122,5 @@ func (c *Client) FindIrFiltersId(criteria *Criteria, options *Options) (int64, e if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.filters was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_http.go b/ir_http.go index ebc6ac2c..70658bef 100644 --- a/ir_http.go +++ b/ir_http.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrHttp represents ir.http model. type IrHttp struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrHttps(ihs []*IrHttp) ([]int64, error) { for _, v := range ihs { vv = append(vv, v) } - return c.Create(IrHttpModel, vv) + return c.Create(IrHttpModel, vv, nil) } // UpdateIrHttp updates an existing ir.http record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrHttp(ih *IrHttp) error { // UpdateIrHttps updates existing ir.http records. // All records (represented by ids) will be updated by ih values. func (c *Client) UpdateIrHttps(ids []int64, ih *IrHttp) error { - return c.Update(IrHttpModel, ids, ih) + return c.Update(IrHttpModel, ids, ih, nil) } // DeleteIrHttp deletes an existing ir.http record. @@ -70,10 +66,7 @@ func (c *Client) GetIrHttp(id int64) (*IrHttp, error) { if err != nil { return nil, err } - if ihs != nil && len(*ihs) > 0 { - return &((*ihs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.http not found", id) + return &((*ihs)[0]), nil } // GetIrHttps gets ir.http existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrHttp(criteria *Criteria) (*IrHttp, error) { if err := c.SearchRead(IrHttpModel, criteria, NewOptions().Limit(1), ihs); err != nil { return nil, err } - if ihs != nil && len(*ihs) > 0 { - return &((*ihs)[0]), nil - } - return nil, fmt.Errorf("ir.http was not found with criteria %v", criteria) + return &((*ihs)[0]), nil } // FindIrHttps finds ir.http records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrHttps(criteria *Criteria, options *Options) (*IrHttps, er // FindIrHttpIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrHttpIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrHttpModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrHttpModel, criteria, options) } // FindIrHttpId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrHttpId(criteria *Criteria, options *Options) (int64, erro if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.http was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_logging.go b/ir_logging.go index d847075c..a47b28bc 100644 --- a/ir_logging.go +++ b/ir_logging.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrLogging represents ir.logging model. type IrLogging struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -20,7 +16,7 @@ type IrLogging struct { Path *String `xmlrpc:"path,omptempty"` Type *Selection `xmlrpc:"type,omptempty"` WriteDate *Time `xmlrpc:"write_date,omptempty"` - WriteUid *Int `xmlrpc:"write_uid,omptempty"` + WriteUid *Many2One `xmlrpc:"write_uid,omptempty"` } // IrLoggings represents array of ir.logging model. @@ -52,7 +48,7 @@ func (c *Client) CreateIrLoggings(ils []*IrLogging) ([]int64, error) { for _, v := range ils { vv = append(vv, v) } - return c.Create(IrLoggingModel, vv) + return c.Create(IrLoggingModel, vv, nil) } // UpdateIrLogging updates an existing ir.logging record. @@ -63,7 +59,7 @@ func (c *Client) UpdateIrLogging(il *IrLogging) error { // UpdateIrLoggings updates existing ir.logging records. // All records (represented by ids) will be updated by il values. func (c *Client) UpdateIrLoggings(ids []int64, il *IrLogging) error { - return c.Update(IrLoggingModel, ids, il) + return c.Update(IrLoggingModel, ids, il, nil) } // DeleteIrLogging deletes an existing ir.logging record. @@ -82,10 +78,7 @@ func (c *Client) GetIrLogging(id int64) (*IrLogging, error) { if err != nil { return nil, err } - if ils != nil && len(*ils) > 0 { - return &((*ils)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.logging not found", id) + return &((*ils)[0]), nil } // GetIrLoggings gets ir.logging existing records. @@ -103,10 +96,7 @@ func (c *Client) FindIrLogging(criteria *Criteria) (*IrLogging, error) { if err := c.SearchRead(IrLoggingModel, criteria, NewOptions().Limit(1), ils); err != nil { return nil, err } - if ils != nil && len(*ils) > 0 { - return &((*ils)[0]), nil - } - return nil, fmt.Errorf("ir.logging was not found with criteria %v", criteria) + return &((*ils)[0]), nil } // FindIrLoggings finds ir.logging records by querying it @@ -122,11 +112,7 @@ func (c *Client) FindIrLoggings(criteria *Criteria, options *Options) (*IrLoggin // FindIrLoggingIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrLoggingIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrLoggingModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrLoggingModel, criteria, options) } // FindIrLoggingId finds record id by querying it with criteria. @@ -135,8 +121,5 @@ func (c *Client) FindIrLoggingId(criteria *Criteria, options *Options) (int64, e if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.logging was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_mail_server.go b/ir_mail_server.go index 5c8066f6..2f7b2ca2 100644 --- a/ir_mail_server.go +++ b/ir_mail_server.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrMailServer represents ir.mail_server model. type IrMailServer struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -53,7 +49,7 @@ func (c *Client) CreateIrMailServers(ims []*IrMailServer) ([]int64, error) { for _, v := range ims { vv = append(vv, v) } - return c.Create(IrMailServerModel, vv) + return c.Create(IrMailServerModel, vv, nil) } // UpdateIrMailServer updates an existing ir.mail_server record. @@ -64,7 +60,7 @@ func (c *Client) UpdateIrMailServer(im *IrMailServer) error { // UpdateIrMailServers updates existing ir.mail_server records. // All records (represented by ids) will be updated by im values. func (c *Client) UpdateIrMailServers(ids []int64, im *IrMailServer) error { - return c.Update(IrMailServerModel, ids, im) + return c.Update(IrMailServerModel, ids, im, nil) } // DeleteIrMailServer deletes an existing ir.mail_server record. @@ -83,10 +79,7 @@ func (c *Client) GetIrMailServer(id int64) (*IrMailServer, error) { if err != nil { return nil, err } - if ims != nil && len(*ims) > 0 { - return &((*ims)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.mail_server not found", id) + return &((*ims)[0]), nil } // GetIrMailServers gets ir.mail_server existing records. @@ -104,10 +97,7 @@ func (c *Client) FindIrMailServer(criteria *Criteria) (*IrMailServer, error) { if err := c.SearchRead(IrMailServerModel, criteria, NewOptions().Limit(1), ims); err != nil { return nil, err } - if ims != nil && len(*ims) > 0 { - return &((*ims)[0]), nil - } - return nil, fmt.Errorf("ir.mail_server was not found with criteria %v", criteria) + return &((*ims)[0]), nil } // FindIrMailServers finds ir.mail_server records by querying it @@ -123,11 +113,7 @@ func (c *Client) FindIrMailServers(criteria *Criteria, options *Options) (*IrMai // FindIrMailServerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrMailServerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrMailServerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrMailServerModel, criteria, options) } // FindIrMailServerId finds record id by querying it with criteria. @@ -136,8 +122,5 @@ func (c *Client) FindIrMailServerId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.mail_server was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_model.go b/ir_model.go index 5f0ac1e8..ab71679c 100644 --- a/ir_model.go +++ b/ir_model.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrModel represents ir.model model. type IrModel struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -56,7 +52,7 @@ func (c *Client) CreateIrModels(ims []*IrModel) ([]int64, error) { for _, v := range ims { vv = append(vv, v) } - return c.Create(IrModelModel, vv) + return c.Create(IrModelModel, vv, nil) } // UpdateIrModel updates an existing ir.model record. @@ -67,7 +63,7 @@ func (c *Client) UpdateIrModel(im *IrModel) error { // UpdateIrModels updates existing ir.model records. // All records (represented by ids) will be updated by im values. func (c *Client) UpdateIrModels(ids []int64, im *IrModel) error { - return c.Update(IrModelModel, ids, im) + return c.Update(IrModelModel, ids, im, nil) } // DeleteIrModel deletes an existing ir.model record. @@ -86,10 +82,7 @@ func (c *Client) GetIrModel(id int64) (*IrModel, error) { if err != nil { return nil, err } - if ims != nil && len(*ims) > 0 { - return &((*ims)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.model not found", id) + return &((*ims)[0]), nil } // GetIrModels gets ir.model existing records. @@ -107,10 +100,7 @@ func (c *Client) FindIrModel(criteria *Criteria) (*IrModel, error) { if err := c.SearchRead(IrModelModel, criteria, NewOptions().Limit(1), ims); err != nil { return nil, err } - if ims != nil && len(*ims) > 0 { - return &((*ims)[0]), nil - } - return nil, fmt.Errorf("ir.model was not found with criteria %v", criteria) + return &((*ims)[0]), nil } // FindIrModels finds ir.model records by querying it @@ -126,11 +116,7 @@ func (c *Client) FindIrModels(criteria *Criteria, options *Options) (*IrModels, // FindIrModelIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrModelIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrModelModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrModelModel, criteria, options) } // FindIrModelId finds record id by querying it with criteria. @@ -139,8 +125,5 @@ func (c *Client) FindIrModelId(criteria *Criteria, options *Options) (int64, err if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.model was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_model_access.go b/ir_model_access.go index 3b1f3a95..74ba1219 100644 --- a/ir_model_access.go +++ b/ir_model_access.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrModelAccess represents ir.model.access model. type IrModelAccess struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -52,7 +48,7 @@ func (c *Client) CreateIrModelAccesss(imas []*IrModelAccess) ([]int64, error) { for _, v := range imas { vv = append(vv, v) } - return c.Create(IrModelAccessModel, vv) + return c.Create(IrModelAccessModel, vv, nil) } // UpdateIrModelAccess updates an existing ir.model.access record. @@ -63,7 +59,7 @@ func (c *Client) UpdateIrModelAccess(ima *IrModelAccess) error { // UpdateIrModelAccesss updates existing ir.model.access records. // All records (represented by ids) will be updated by ima values. func (c *Client) UpdateIrModelAccesss(ids []int64, ima *IrModelAccess) error { - return c.Update(IrModelAccessModel, ids, ima) + return c.Update(IrModelAccessModel, ids, ima, nil) } // DeleteIrModelAccess deletes an existing ir.model.access record. @@ -82,10 +78,7 @@ func (c *Client) GetIrModelAccess(id int64) (*IrModelAccess, error) { if err != nil { return nil, err } - if imas != nil && len(*imas) > 0 { - return &((*imas)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.model.access not found", id) + return &((*imas)[0]), nil } // GetIrModelAccesss gets ir.model.access existing records. @@ -103,10 +96,7 @@ func (c *Client) FindIrModelAccess(criteria *Criteria) (*IrModelAccess, error) { if err := c.SearchRead(IrModelAccessModel, criteria, NewOptions().Limit(1), imas); err != nil { return nil, err } - if imas != nil && len(*imas) > 0 { - return &((*imas)[0]), nil - } - return nil, fmt.Errorf("ir.model.access was not found with criteria %v", criteria) + return &((*imas)[0]), nil } // FindIrModelAccesss finds ir.model.access records by querying it @@ -122,11 +112,7 @@ func (c *Client) FindIrModelAccesss(criteria *Criteria, options *Options) (*IrMo // FindIrModelAccessIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrModelAccessIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrModelAccessModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrModelAccessModel, criteria, options) } // FindIrModelAccessId finds record id by querying it with criteria. @@ -135,8 +121,5 @@ func (c *Client) FindIrModelAccessId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.model.access was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_model_constraint.go b/ir_model_constraint.go index f249761b..97d3885b 100644 --- a/ir_model_constraint.go +++ b/ir_model_constraint.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrModelConstraint represents ir.model.constraint model. type IrModelConstraint struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -51,7 +47,7 @@ func (c *Client) CreateIrModelConstraints(imcs []*IrModelConstraint) ([]int64, e for _, v := range imcs { vv = append(vv, v) } - return c.Create(IrModelConstraintModel, vv) + return c.Create(IrModelConstraintModel, vv, nil) } // UpdateIrModelConstraint updates an existing ir.model.constraint record. @@ -62,7 +58,7 @@ func (c *Client) UpdateIrModelConstraint(imc *IrModelConstraint) error { // UpdateIrModelConstraints updates existing ir.model.constraint records. // All records (represented by ids) will be updated by imc values. func (c *Client) UpdateIrModelConstraints(ids []int64, imc *IrModelConstraint) error { - return c.Update(IrModelConstraintModel, ids, imc) + return c.Update(IrModelConstraintModel, ids, imc, nil) } // DeleteIrModelConstraint deletes an existing ir.model.constraint record. @@ -81,10 +77,7 @@ func (c *Client) GetIrModelConstraint(id int64) (*IrModelConstraint, error) { if err != nil { return nil, err } - if imcs != nil && len(*imcs) > 0 { - return &((*imcs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.model.constraint not found", id) + return &((*imcs)[0]), nil } // GetIrModelConstraints gets ir.model.constraint existing records. @@ -102,10 +95,7 @@ func (c *Client) FindIrModelConstraint(criteria *Criteria) (*IrModelConstraint, if err := c.SearchRead(IrModelConstraintModel, criteria, NewOptions().Limit(1), imcs); err != nil { return nil, err } - if imcs != nil && len(*imcs) > 0 { - return &((*imcs)[0]), nil - } - return nil, fmt.Errorf("ir.model.constraint was not found with criteria %v", criteria) + return &((*imcs)[0]), nil } // FindIrModelConstraints finds ir.model.constraint records by querying it @@ -121,11 +111,7 @@ func (c *Client) FindIrModelConstraints(criteria *Criteria, options *Options) (* // FindIrModelConstraintIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrModelConstraintIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrModelConstraintModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrModelConstraintModel, criteria, options) } // FindIrModelConstraintId finds record id by querying it with criteria. @@ -134,8 +120,5 @@ func (c *Client) FindIrModelConstraintId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.model.constraint was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_model_data.go b/ir_model_data.go index 2995c929..4347acc2 100644 --- a/ir_model_data.go +++ b/ir_model_data.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrModelData represents ir.model.data model. type IrModelData struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -53,7 +49,7 @@ func (c *Client) CreateIrModelDatas(imds []*IrModelData) ([]int64, error) { for _, v := range imds { vv = append(vv, v) } - return c.Create(IrModelDataModel, vv) + return c.Create(IrModelDataModel, vv, nil) } // UpdateIrModelData updates an existing ir.model.data record. @@ -64,7 +60,7 @@ func (c *Client) UpdateIrModelData(imd *IrModelData) error { // UpdateIrModelDatas updates existing ir.model.data records. // All records (represented by ids) will be updated by imd values. func (c *Client) UpdateIrModelDatas(ids []int64, imd *IrModelData) error { - return c.Update(IrModelDataModel, ids, imd) + return c.Update(IrModelDataModel, ids, imd, nil) } // DeleteIrModelData deletes an existing ir.model.data record. @@ -83,10 +79,7 @@ func (c *Client) GetIrModelData(id int64) (*IrModelData, error) { if err != nil { return nil, err } - if imds != nil && len(*imds) > 0 { - return &((*imds)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.model.data not found", id) + return &((*imds)[0]), nil } // GetIrModelDatas gets ir.model.data existing records. @@ -104,10 +97,7 @@ func (c *Client) FindIrModelData(criteria *Criteria) (*IrModelData, error) { if err := c.SearchRead(IrModelDataModel, criteria, NewOptions().Limit(1), imds); err != nil { return nil, err } - if imds != nil && len(*imds) > 0 { - return &((*imds)[0]), nil - } - return nil, fmt.Errorf("ir.model.data was not found with criteria %v", criteria) + return &((*imds)[0]), nil } // FindIrModelDatas finds ir.model.data records by querying it @@ -123,11 +113,7 @@ func (c *Client) FindIrModelDatas(criteria *Criteria, options *Options) (*IrMode // FindIrModelDataIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrModelDataIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrModelDataModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrModelDataModel, criteria, options) } // FindIrModelDataId finds record id by querying it with criteria. @@ -136,8 +122,5 @@ func (c *Client) FindIrModelDataId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.model.data was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_model_fields.go b/ir_model_fields.go index 32d12eaf..0eb73d6f 100644 --- a/ir_model_fields.go +++ b/ir_model_fields.go @@ -1,48 +1,45 @@ package odoo -import ( - "fmt" -) - // IrModelFields represents ir.model.fields model. type IrModelFields struct { - LastUpdate *Time `xmlrpc:"__last_update,omptempty"` - Column1 *String `xmlrpc:"column1,omptempty"` - Column2 *String `xmlrpc:"column2,omptempty"` - CompleteName *String `xmlrpc:"complete_name,omptempty"` - Compute *String `xmlrpc:"compute,omptempty"` - Copy *Bool `xmlrpc:"copy,omptempty"` - CreateDate *Time `xmlrpc:"create_date,omptempty"` - CreateUid *Many2One `xmlrpc:"create_uid,omptempty"` - Depends *String `xmlrpc:"depends,omptempty"` - DisplayName *String `xmlrpc:"display_name,omptempty"` - Domain *String `xmlrpc:"domain,omptempty"` - FieldDescription *String `xmlrpc:"field_description,omptempty"` - Groups *Relation `xmlrpc:"groups,omptempty"` - Help *String `xmlrpc:"help,omptempty"` - Id *Int `xmlrpc:"id,omptempty"` - Index *Bool `xmlrpc:"index,omptempty"` - Model *String `xmlrpc:"model,omptempty"` - ModelId *Many2One `xmlrpc:"model_id,omptempty"` - Modules *String `xmlrpc:"modules,omptempty"` - Name *String `xmlrpc:"name,omptempty"` - OnDelete *Selection `xmlrpc:"on_delete,omptempty"` - Readonly *Bool `xmlrpc:"readonly,omptempty"` - Related *String `xmlrpc:"related,omptempty"` - Relation *String `xmlrpc:"relation,omptempty"` - RelationField *String `xmlrpc:"relation_field,omptempty"` - RelationTable *String `xmlrpc:"relation_table,omptempty"` - Required *Bool `xmlrpc:"required,omptempty"` - Selectable *Bool `xmlrpc:"selectable,omptempty"` - Selection *String `xmlrpc:"selection,omptempty"` - Size *Int `xmlrpc:"size,omptempty"` - State *Selection `xmlrpc:"state,omptempty"` - Store *Bool `xmlrpc:"store,omptempty"` - TrackVisibility *Selection `xmlrpc:"track_visibility,omptempty"` - Translate *Bool `xmlrpc:"translate,omptempty"` - Ttype *Selection `xmlrpc:"ttype,omptempty"` - WriteDate *Time `xmlrpc:"write_date,omptempty"` - WriteUid *Many2One `xmlrpc:"write_uid,omptempty"` + LastUpdate *Time `xmlrpc:"__last_update,omptempty"` + Column1 *String `xmlrpc:"column1,omptempty"` + Column2 *String `xmlrpc:"column2,omptempty"` + CompleteName *String `xmlrpc:"complete_name,omptempty"` + Compute *String `xmlrpc:"compute,omptempty"` + Copy *Bool `xmlrpc:"copy,omptempty"` + CreateDate *Time `xmlrpc:"create_date,omptempty"` + CreateUid *Many2One `xmlrpc:"create_uid,omptempty"` + Depends *String `xmlrpc:"depends,omptempty"` + DisplayName *String `xmlrpc:"display_name,omptempty"` + Domain *String `xmlrpc:"domain,omptempty"` + FieldDescription *String `xmlrpc:"field_description,omptempty"` + Groups *Relation `xmlrpc:"groups,omptempty"` + Help *String `xmlrpc:"help,omptempty"` + Id *Int `xmlrpc:"id,omptempty"` + Index *Bool `xmlrpc:"index,omptempty"` + Model *String `xmlrpc:"model,omptempty"` + ModelId *Many2One `xmlrpc:"model_id,omptempty"` + Modules *String `xmlrpc:"modules,omptempty"` + Name *String `xmlrpc:"name,omptempty"` + OnDelete *Selection `xmlrpc:"on_delete,omptempty"` + Readonly *Bool `xmlrpc:"readonly,omptempty"` + Related *String `xmlrpc:"related,omptempty"` + Relation *String `xmlrpc:"relation,omptempty"` + RelationField *String `xmlrpc:"relation_field,omptempty"` + RelationTable *String `xmlrpc:"relation_table,omptempty"` + Required *Bool `xmlrpc:"required,omptempty"` + Selectable *Bool `xmlrpc:"selectable,omptempty"` + Selection *String `xmlrpc:"selection,omptempty"` + SerializationFieldId *Many2One `xmlrpc:"serialization_field_id,omptempty"` + Size *Int `xmlrpc:"size,omptempty"` + State *Selection `xmlrpc:"state,omptempty"` + Store *Bool `xmlrpc:"store,omptempty"` + TrackVisibility *Selection `xmlrpc:"track_visibility,omptempty"` + Translate *Bool `xmlrpc:"translate,omptempty"` + Ttype *Selection `xmlrpc:"ttype,omptempty"` + WriteDate *Time `xmlrpc:"write_date,omptempty"` + WriteUid *Many2One `xmlrpc:"write_uid,omptempty"` } // IrModelFieldss represents array of ir.model.fields model. @@ -74,7 +71,7 @@ func (c *Client) CreateIrModelFieldss(imfs []*IrModelFields) ([]int64, error) { for _, v := range imfs { vv = append(vv, v) } - return c.Create(IrModelFieldsModel, vv) + return c.Create(IrModelFieldsModel, vv, nil) } // UpdateIrModelFields updates an existing ir.model.fields record. @@ -85,7 +82,7 @@ func (c *Client) UpdateIrModelFields(imf *IrModelFields) error { // UpdateIrModelFieldss updates existing ir.model.fields records. // All records (represented by ids) will be updated by imf values. func (c *Client) UpdateIrModelFieldss(ids []int64, imf *IrModelFields) error { - return c.Update(IrModelFieldsModel, ids, imf) + return c.Update(IrModelFieldsModel, ids, imf, nil) } // DeleteIrModelFields deletes an existing ir.model.fields record. @@ -104,10 +101,7 @@ func (c *Client) GetIrModelFields(id int64) (*IrModelFields, error) { if err != nil { return nil, err } - if imfs != nil && len(*imfs) > 0 { - return &((*imfs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.model.fields not found", id) + return &((*imfs)[0]), nil } // GetIrModelFieldss gets ir.model.fields existing records. @@ -125,10 +119,7 @@ func (c *Client) FindIrModelFields(criteria *Criteria) (*IrModelFields, error) { if err := c.SearchRead(IrModelFieldsModel, criteria, NewOptions().Limit(1), imfs); err != nil { return nil, err } - if imfs != nil && len(*imfs) > 0 { - return &((*imfs)[0]), nil - } - return nil, fmt.Errorf("ir.model.fields was not found with criteria %v", criteria) + return &((*imfs)[0]), nil } // FindIrModelFieldss finds ir.model.fields records by querying it @@ -144,11 +135,7 @@ func (c *Client) FindIrModelFieldss(criteria *Criteria, options *Options) (*IrMo // FindIrModelFieldsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrModelFieldsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrModelFieldsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrModelFieldsModel, criteria, options) } // FindIrModelFieldsId finds record id by querying it with criteria. @@ -157,8 +144,5 @@ func (c *Client) FindIrModelFieldsId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.model.fields was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_model_relation.go b/ir_model_relation.go index 327bc8bf..2f5d9d4d 100644 --- a/ir_model_relation.go +++ b/ir_model_relation.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrModelRelation represents ir.model.relation model. type IrModelRelation struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateIrModelRelations(imrs []*IrModelRelation) ([]int64, error for _, v := range imrs { vv = append(vv, v) } - return c.Create(IrModelRelationModel, vv) + return c.Create(IrModelRelationModel, vv, nil) } // UpdateIrModelRelation updates an existing ir.model.relation record. @@ -60,7 +56,7 @@ func (c *Client) UpdateIrModelRelation(imr *IrModelRelation) error { // UpdateIrModelRelations updates existing ir.model.relation records. // All records (represented by ids) will be updated by imr values. func (c *Client) UpdateIrModelRelations(ids []int64, imr *IrModelRelation) error { - return c.Update(IrModelRelationModel, ids, imr) + return c.Update(IrModelRelationModel, ids, imr, nil) } // DeleteIrModelRelation deletes an existing ir.model.relation record. @@ -79,10 +75,7 @@ func (c *Client) GetIrModelRelation(id int64) (*IrModelRelation, error) { if err != nil { return nil, err } - if imrs != nil && len(*imrs) > 0 { - return &((*imrs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.model.relation not found", id) + return &((*imrs)[0]), nil } // GetIrModelRelations gets ir.model.relation existing records. @@ -100,10 +93,7 @@ func (c *Client) FindIrModelRelation(criteria *Criteria) (*IrModelRelation, erro if err := c.SearchRead(IrModelRelationModel, criteria, NewOptions().Limit(1), imrs); err != nil { return nil, err } - if imrs != nil && len(*imrs) > 0 { - return &((*imrs)[0]), nil - } - return nil, fmt.Errorf("ir.model.relation was not found with criteria %v", criteria) + return &((*imrs)[0]), nil } // FindIrModelRelations finds ir.model.relation records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindIrModelRelations(criteria *Criteria, options *Options) (*Ir // FindIrModelRelationIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrModelRelationIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrModelRelationModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrModelRelationModel, criteria, options) } // FindIrModelRelationId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindIrModelRelationId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.model.relation was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_module_category.go b/ir_module_category.go index cab152f6..0bd26cec 100644 --- a/ir_module_category.go +++ b/ir_module_category.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrModuleCategory represents ir.module.category model. type IrModuleCategory struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -54,7 +50,7 @@ func (c *Client) CreateIrModuleCategorys(imcs []*IrModuleCategory) ([]int64, err for _, v := range imcs { vv = append(vv, v) } - return c.Create(IrModuleCategoryModel, vv) + return c.Create(IrModuleCategoryModel, vv, nil) } // UpdateIrModuleCategory updates an existing ir.module.category record. @@ -65,7 +61,7 @@ func (c *Client) UpdateIrModuleCategory(imc *IrModuleCategory) error { // UpdateIrModuleCategorys updates existing ir.module.category records. // All records (represented by ids) will be updated by imc values. func (c *Client) UpdateIrModuleCategorys(ids []int64, imc *IrModuleCategory) error { - return c.Update(IrModuleCategoryModel, ids, imc) + return c.Update(IrModuleCategoryModel, ids, imc, nil) } // DeleteIrModuleCategory deletes an existing ir.module.category record. @@ -84,10 +80,7 @@ func (c *Client) GetIrModuleCategory(id int64) (*IrModuleCategory, error) { if err != nil { return nil, err } - if imcs != nil && len(*imcs) > 0 { - return &((*imcs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.module.category not found", id) + return &((*imcs)[0]), nil } // GetIrModuleCategorys gets ir.module.category existing records. @@ -105,10 +98,7 @@ func (c *Client) FindIrModuleCategory(criteria *Criteria) (*IrModuleCategory, er if err := c.SearchRead(IrModuleCategoryModel, criteria, NewOptions().Limit(1), imcs); err != nil { return nil, err } - if imcs != nil && len(*imcs) > 0 { - return &((*imcs)[0]), nil - } - return nil, fmt.Errorf("ir.module.category was not found with criteria %v", criteria) + return &((*imcs)[0]), nil } // FindIrModuleCategorys finds ir.module.category records by querying it @@ -124,11 +114,7 @@ func (c *Client) FindIrModuleCategorys(criteria *Criteria, options *Options) (*I // FindIrModuleCategoryIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrModuleCategoryIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrModuleCategoryModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrModuleCategoryModel, criteria, options) } // FindIrModuleCategoryId finds record id by querying it with criteria. @@ -137,8 +123,5 @@ func (c *Client) FindIrModuleCategoryId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.module.category was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_module_module.go b/ir_module_module.go index a8771f23..4153ca12 100644 --- a/ir_module_module.go +++ b/ir_module_module.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrModuleModule represents ir.module.module model. type IrModuleModule struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -71,7 +67,7 @@ func (c *Client) CreateIrModuleModules(imms []*IrModuleModule) ([]int64, error) for _, v := range imms { vv = append(vv, v) } - return c.Create(IrModuleModuleModel, vv) + return c.Create(IrModuleModuleModel, vv, nil) } // UpdateIrModuleModule updates an existing ir.module.module record. @@ -82,7 +78,7 @@ func (c *Client) UpdateIrModuleModule(imm *IrModuleModule) error { // UpdateIrModuleModules updates existing ir.module.module records. // All records (represented by ids) will be updated by imm values. func (c *Client) UpdateIrModuleModules(ids []int64, imm *IrModuleModule) error { - return c.Update(IrModuleModuleModel, ids, imm) + return c.Update(IrModuleModuleModel, ids, imm, nil) } // DeleteIrModuleModule deletes an existing ir.module.module record. @@ -101,10 +97,7 @@ func (c *Client) GetIrModuleModule(id int64) (*IrModuleModule, error) { if err != nil { return nil, err } - if imms != nil && len(*imms) > 0 { - return &((*imms)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.module.module not found", id) + return &((*imms)[0]), nil } // GetIrModuleModules gets ir.module.module existing records. @@ -122,10 +115,7 @@ func (c *Client) FindIrModuleModule(criteria *Criteria) (*IrModuleModule, error) if err := c.SearchRead(IrModuleModuleModel, criteria, NewOptions().Limit(1), imms); err != nil { return nil, err } - if imms != nil && len(*imms) > 0 { - return &((*imms)[0]), nil - } - return nil, fmt.Errorf("ir.module.module was not found with criteria %v", criteria) + return &((*imms)[0]), nil } // FindIrModuleModules finds ir.module.module records by querying it @@ -141,11 +131,7 @@ func (c *Client) FindIrModuleModules(criteria *Criteria, options *Options) (*IrM // FindIrModuleModuleIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrModuleModuleIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrModuleModuleModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrModuleModuleModel, criteria, options) } // FindIrModuleModuleId finds record id by querying it with criteria. @@ -154,8 +140,5 @@ func (c *Client) FindIrModuleModuleId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.module.module was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_module_module_dependency.go b/ir_module_module_dependency.go index 20884698..ec667de8 100644 --- a/ir_module_module_dependency.go +++ b/ir_module_module_dependency.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrModuleModuleDependency represents ir.module.module.dependency model. type IrModuleModuleDependency struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateIrModuleModuleDependencys(immds []*IrModuleModuleDependen for _, v := range immds { vv = append(vv, v) } - return c.Create(IrModuleModuleDependencyModel, vv) + return c.Create(IrModuleModuleDependencyModel, vv, nil) } // UpdateIrModuleModuleDependency updates an existing ir.module.module.dependency record. @@ -59,7 +55,7 @@ func (c *Client) UpdateIrModuleModuleDependency(immd *IrModuleModuleDependency) // UpdateIrModuleModuleDependencys updates existing ir.module.module.dependency records. // All records (represented by ids) will be updated by immd values. func (c *Client) UpdateIrModuleModuleDependencys(ids []int64, immd *IrModuleModuleDependency) error { - return c.Update(IrModuleModuleDependencyModel, ids, immd) + return c.Update(IrModuleModuleDependencyModel, ids, immd, nil) } // DeleteIrModuleModuleDependency deletes an existing ir.module.module.dependency record. @@ -78,10 +74,7 @@ func (c *Client) GetIrModuleModuleDependency(id int64) (*IrModuleModuleDependenc if err != nil { return nil, err } - if immds != nil && len(*immds) > 0 { - return &((*immds)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.module.module.dependency not found", id) + return &((*immds)[0]), nil } // GetIrModuleModuleDependencys gets ir.module.module.dependency existing records. @@ -99,10 +92,7 @@ func (c *Client) FindIrModuleModuleDependency(criteria *Criteria) (*IrModuleModu if err := c.SearchRead(IrModuleModuleDependencyModel, criteria, NewOptions().Limit(1), immds); err != nil { return nil, err } - if immds != nil && len(*immds) > 0 { - return &((*immds)[0]), nil - } - return nil, fmt.Errorf("ir.module.module.dependency was not found with criteria %v", criteria) + return &((*immds)[0]), nil } // FindIrModuleModuleDependencys finds ir.module.module.dependency records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindIrModuleModuleDependencys(criteria *Criteria, options *Opti // FindIrModuleModuleDependencyIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrModuleModuleDependencyIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrModuleModuleDependencyModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrModuleModuleDependencyModel, criteria, options) } // FindIrModuleModuleDependencyId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindIrModuleModuleDependencyId(criteria *Criteria, options *Opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.module.module.dependency was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_module_module_exclusion.go b/ir_module_module_exclusion.go index e0bb2b15..dd6e8a36 100644 --- a/ir_module_module_exclusion.go +++ b/ir_module_module_exclusion.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrModuleModuleExclusion represents ir.module.module.exclusion model. type IrModuleModuleExclusion struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateIrModuleModuleExclusions(immes []*IrModuleModuleExclusion for _, v := range immes { vv = append(vv, v) } - return c.Create(IrModuleModuleExclusionModel, vv) + return c.Create(IrModuleModuleExclusionModel, vv, nil) } // UpdateIrModuleModuleExclusion updates an existing ir.module.module.exclusion record. @@ -59,7 +55,7 @@ func (c *Client) UpdateIrModuleModuleExclusion(imme *IrModuleModuleExclusion) er // UpdateIrModuleModuleExclusions updates existing ir.module.module.exclusion records. // All records (represented by ids) will be updated by imme values. func (c *Client) UpdateIrModuleModuleExclusions(ids []int64, imme *IrModuleModuleExclusion) error { - return c.Update(IrModuleModuleExclusionModel, ids, imme) + return c.Update(IrModuleModuleExclusionModel, ids, imme, nil) } // DeleteIrModuleModuleExclusion deletes an existing ir.module.module.exclusion record. @@ -78,10 +74,7 @@ func (c *Client) GetIrModuleModuleExclusion(id int64) (*IrModuleModuleExclusion, if err != nil { return nil, err } - if immes != nil && len(*immes) > 0 { - return &((*immes)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.module.module.exclusion not found", id) + return &((*immes)[0]), nil } // GetIrModuleModuleExclusions gets ir.module.module.exclusion existing records. @@ -99,10 +92,7 @@ func (c *Client) FindIrModuleModuleExclusion(criteria *Criteria) (*IrModuleModul if err := c.SearchRead(IrModuleModuleExclusionModel, criteria, NewOptions().Limit(1), immes); err != nil { return nil, err } - if immes != nil && len(*immes) > 0 { - return &((*immes)[0]), nil - } - return nil, fmt.Errorf("ir.module.module.exclusion was not found with criteria %v", criteria) + return &((*immes)[0]), nil } // FindIrModuleModuleExclusions finds ir.module.module.exclusion records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindIrModuleModuleExclusions(criteria *Criteria, options *Optio // FindIrModuleModuleExclusionIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrModuleModuleExclusionIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrModuleModuleExclusionModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrModuleModuleExclusionModel, criteria, options) } // FindIrModuleModuleExclusionId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindIrModuleModuleExclusionId(criteria *Criteria, options *Opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.module.module.exclusion was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_property.go b/ir_property.go index 1d76deb2..807d5e87 100644 --- a/ir_property.go +++ b/ir_property.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrProperty represents ir.property model. type IrProperty struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -55,7 +51,7 @@ func (c *Client) CreateIrPropertys(ips []*IrProperty) ([]int64, error) { for _, v := range ips { vv = append(vv, v) } - return c.Create(IrPropertyModel, vv) + return c.Create(IrPropertyModel, vv, nil) } // UpdateIrProperty updates an existing ir.property record. @@ -66,7 +62,7 @@ func (c *Client) UpdateIrProperty(ip *IrProperty) error { // UpdateIrPropertys updates existing ir.property records. // All records (represented by ids) will be updated by ip values. func (c *Client) UpdateIrPropertys(ids []int64, ip *IrProperty) error { - return c.Update(IrPropertyModel, ids, ip) + return c.Update(IrPropertyModel, ids, ip, nil) } // DeleteIrProperty deletes an existing ir.property record. @@ -85,10 +81,7 @@ func (c *Client) GetIrProperty(id int64) (*IrProperty, error) { if err != nil { return nil, err } - if ips != nil && len(*ips) > 0 { - return &((*ips)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.property not found", id) + return &((*ips)[0]), nil } // GetIrPropertys gets ir.property existing records. @@ -106,10 +99,7 @@ func (c *Client) FindIrProperty(criteria *Criteria) (*IrProperty, error) { if err := c.SearchRead(IrPropertyModel, criteria, NewOptions().Limit(1), ips); err != nil { return nil, err } - if ips != nil && len(*ips) > 0 { - return &((*ips)[0]), nil - } - return nil, fmt.Errorf("ir.property was not found with criteria %v", criteria) + return &((*ips)[0]), nil } // FindIrPropertys finds ir.property records by querying it @@ -125,11 +115,7 @@ func (c *Client) FindIrPropertys(criteria *Criteria, options *Options) (*IrPrope // FindIrPropertyIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrPropertyIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrPropertyModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrPropertyModel, criteria, options) } // FindIrPropertyId finds record id by querying it with criteria. @@ -138,8 +124,5 @@ func (c *Client) FindIrPropertyId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.property was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb.go b/ir_qweb.go index c6fe4b50..f229d671 100644 --- a/ir_qweb.go +++ b/ir_qweb.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQweb represents ir.qweb model. type IrQweb struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebs(iqs []*IrQweb) ([]int64, error) { for _, v := range iqs { vv = append(vv, v) } - return c.Create(IrQwebModel, vv) + return c.Create(IrQwebModel, vv, nil) } // UpdateIrQweb updates an existing ir.qweb record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQweb(iq *IrQweb) error { // UpdateIrQwebs updates existing ir.qweb records. // All records (represented by ids) will be updated by iq values. func (c *Client) UpdateIrQwebs(ids []int64, iq *IrQweb) error { - return c.Update(IrQwebModel, ids, iq) + return c.Update(IrQwebModel, ids, iq, nil) } // DeleteIrQweb deletes an existing ir.qweb record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQweb(id int64) (*IrQweb, error) { if err != nil { return nil, err } - if iqs != nil && len(*iqs) > 0 { - return &((*iqs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb not found", id) + return &((*iqs)[0]), nil } // GetIrQwebs gets ir.qweb existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQweb(criteria *Criteria) (*IrQweb, error) { if err := c.SearchRead(IrQwebModel, criteria, NewOptions().Limit(1), iqs); err != nil { return nil, err } - if iqs != nil && len(*iqs) > 0 { - return &((*iqs)[0]), nil - } - return nil, fmt.Errorf("ir.qweb was not found with criteria %v", criteria) + return &((*iqs)[0]), nil } // FindIrQwebs finds ir.qweb records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebs(criteria *Criteria, options *Options) (*IrQwebs, er // FindIrQwebIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebModel, criteria, options) } // FindIrQwebId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebId(criteria *Criteria, options *Options) (int64, erro if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field.go b/ir_qweb_field.go index f554b603..ec3b5898 100644 --- a/ir_qweb_field.go +++ b/ir_qweb_field.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebField represents ir.qweb.field model. type IrQwebField struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFields(iqfs []*IrQwebField) ([]int64, error) { for _, v := range iqfs { vv = append(vv, v) } - return c.Create(IrQwebFieldModel, vv) + return c.Create(IrQwebFieldModel, vv, nil) } // UpdateIrQwebField updates an existing ir.qweb.field record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebField(iqf *IrQwebField) error { // UpdateIrQwebFields updates existing ir.qweb.field records. // All records (represented by ids) will be updated by iqf values. func (c *Client) UpdateIrQwebFields(ids []int64, iqf *IrQwebField) error { - return c.Update(IrQwebFieldModel, ids, iqf) + return c.Update(IrQwebFieldModel, ids, iqf, nil) } // DeleteIrQwebField deletes an existing ir.qweb.field record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebField(id int64) (*IrQwebField, error) { if err != nil { return nil, err } - if iqfs != nil && len(*iqfs) > 0 { - return &((*iqfs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field not found", id) + return &((*iqfs)[0]), nil } // GetIrQwebFields gets ir.qweb.field existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebField(criteria *Criteria) (*IrQwebField, error) { if err := c.SearchRead(IrQwebFieldModel, criteria, NewOptions().Limit(1), iqfs); err != nil { return nil, err } - if iqfs != nil && len(*iqfs) > 0 { - return &((*iqfs)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field was not found with criteria %v", criteria) + return &((*iqfs)[0]), nil } // FindIrQwebFields finds ir.qweb.field records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFields(criteria *Criteria, options *Options) (*IrQweb // FindIrQwebFieldIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldModel, criteria, options) } // FindIrQwebFieldId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_barcode.go b/ir_qweb_field_barcode.go index 96655380..5271559e 100644 --- a/ir_qweb_field_barcode.go +++ b/ir_qweb_field_barcode.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldBarcode represents ir.qweb.field.barcode model. type IrQwebFieldBarcode struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldBarcodes(iqfbs []*IrQwebFieldBarcode) ([]int64 for _, v := range iqfbs { vv = append(vv, v) } - return c.Create(IrQwebFieldBarcodeModel, vv) + return c.Create(IrQwebFieldBarcodeModel, vv, nil) } // UpdateIrQwebFieldBarcode updates an existing ir.qweb.field.barcode record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldBarcode(iqfb *IrQwebFieldBarcode) error { // UpdateIrQwebFieldBarcodes updates existing ir.qweb.field.barcode records. // All records (represented by ids) will be updated by iqfb values. func (c *Client) UpdateIrQwebFieldBarcodes(ids []int64, iqfb *IrQwebFieldBarcode) error { - return c.Update(IrQwebFieldBarcodeModel, ids, iqfb) + return c.Update(IrQwebFieldBarcodeModel, ids, iqfb, nil) } // DeleteIrQwebFieldBarcode deletes an existing ir.qweb.field.barcode record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldBarcode(id int64) (*IrQwebFieldBarcode, error) { if err != nil { return nil, err } - if iqfbs != nil && len(*iqfbs) > 0 { - return &((*iqfbs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.barcode not found", id) + return &((*iqfbs)[0]), nil } // GetIrQwebFieldBarcodes gets ir.qweb.field.barcode existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldBarcode(criteria *Criteria) (*IrQwebFieldBarcode if err := c.SearchRead(IrQwebFieldBarcodeModel, criteria, NewOptions().Limit(1), iqfbs); err != nil { return nil, err } - if iqfbs != nil && len(*iqfbs) > 0 { - return &((*iqfbs)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.barcode was not found with criteria %v", criteria) + return &((*iqfbs)[0]), nil } // FindIrQwebFieldBarcodes finds ir.qweb.field.barcode records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldBarcodes(criteria *Criteria, options *Options) ( // FindIrQwebFieldBarcodeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldBarcodeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldBarcodeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldBarcodeModel, criteria, options) } // FindIrQwebFieldBarcodeId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldBarcodeId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.barcode was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_contact.go b/ir_qweb_field_contact.go index 136c227e..1c775ae2 100644 --- a/ir_qweb_field_contact.go +++ b/ir_qweb_field_contact.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldContact represents ir.qweb.field.contact model. type IrQwebFieldContact struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldContacts(iqfcs []*IrQwebFieldContact) ([]int64 for _, v := range iqfcs { vv = append(vv, v) } - return c.Create(IrQwebFieldContactModel, vv) + return c.Create(IrQwebFieldContactModel, vv, nil) } // UpdateIrQwebFieldContact updates an existing ir.qweb.field.contact record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldContact(iqfc *IrQwebFieldContact) error { // UpdateIrQwebFieldContacts updates existing ir.qweb.field.contact records. // All records (represented by ids) will be updated by iqfc values. func (c *Client) UpdateIrQwebFieldContacts(ids []int64, iqfc *IrQwebFieldContact) error { - return c.Update(IrQwebFieldContactModel, ids, iqfc) + return c.Update(IrQwebFieldContactModel, ids, iqfc, nil) } // DeleteIrQwebFieldContact deletes an existing ir.qweb.field.contact record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldContact(id int64) (*IrQwebFieldContact, error) { if err != nil { return nil, err } - if iqfcs != nil && len(*iqfcs) > 0 { - return &((*iqfcs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.contact not found", id) + return &((*iqfcs)[0]), nil } // GetIrQwebFieldContacts gets ir.qweb.field.contact existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldContact(criteria *Criteria) (*IrQwebFieldContact if err := c.SearchRead(IrQwebFieldContactModel, criteria, NewOptions().Limit(1), iqfcs); err != nil { return nil, err } - if iqfcs != nil && len(*iqfcs) > 0 { - return &((*iqfcs)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.contact was not found with criteria %v", criteria) + return &((*iqfcs)[0]), nil } // FindIrQwebFieldContacts finds ir.qweb.field.contact records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldContacts(criteria *Criteria, options *Options) ( // FindIrQwebFieldContactIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldContactIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldContactModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldContactModel, criteria, options) } // FindIrQwebFieldContactId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldContactId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.contact was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_date.go b/ir_qweb_field_date.go index fb5f97ed..4142cafa 100644 --- a/ir_qweb_field_date.go +++ b/ir_qweb_field_date.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldDate represents ir.qweb.field.date model. type IrQwebFieldDate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldDates(iqfds []*IrQwebFieldDate) ([]int64, erro for _, v := range iqfds { vv = append(vv, v) } - return c.Create(IrQwebFieldDateModel, vv) + return c.Create(IrQwebFieldDateModel, vv, nil) } // UpdateIrQwebFieldDate updates an existing ir.qweb.field.date record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldDate(iqfd *IrQwebFieldDate) error { // UpdateIrQwebFieldDates updates existing ir.qweb.field.date records. // All records (represented by ids) will be updated by iqfd values. func (c *Client) UpdateIrQwebFieldDates(ids []int64, iqfd *IrQwebFieldDate) error { - return c.Update(IrQwebFieldDateModel, ids, iqfd) + return c.Update(IrQwebFieldDateModel, ids, iqfd, nil) } // DeleteIrQwebFieldDate deletes an existing ir.qweb.field.date record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldDate(id int64) (*IrQwebFieldDate, error) { if err != nil { return nil, err } - if iqfds != nil && len(*iqfds) > 0 { - return &((*iqfds)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.date not found", id) + return &((*iqfds)[0]), nil } // GetIrQwebFieldDates gets ir.qweb.field.date existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldDate(criteria *Criteria) (*IrQwebFieldDate, erro if err := c.SearchRead(IrQwebFieldDateModel, criteria, NewOptions().Limit(1), iqfds); err != nil { return nil, err } - if iqfds != nil && len(*iqfds) > 0 { - return &((*iqfds)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.date was not found with criteria %v", criteria) + return &((*iqfds)[0]), nil } // FindIrQwebFieldDates finds ir.qweb.field.date records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldDates(criteria *Criteria, options *Options) (*Ir // FindIrQwebFieldDateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldDateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldDateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldDateModel, criteria, options) } // FindIrQwebFieldDateId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldDateId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.date was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_datetime.go b/ir_qweb_field_datetime.go index d33c0fd3..ac9e9b53 100644 --- a/ir_qweb_field_datetime.go +++ b/ir_qweb_field_datetime.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldDatetime represents ir.qweb.field.datetime model. type IrQwebFieldDatetime struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldDatetimes(iqfds []*IrQwebFieldDatetime) ([]int for _, v := range iqfds { vv = append(vv, v) } - return c.Create(IrQwebFieldDatetimeModel, vv) + return c.Create(IrQwebFieldDatetimeModel, vv, nil) } // UpdateIrQwebFieldDatetime updates an existing ir.qweb.field.datetime record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldDatetime(iqfd *IrQwebFieldDatetime) error { // UpdateIrQwebFieldDatetimes updates existing ir.qweb.field.datetime records. // All records (represented by ids) will be updated by iqfd values. func (c *Client) UpdateIrQwebFieldDatetimes(ids []int64, iqfd *IrQwebFieldDatetime) error { - return c.Update(IrQwebFieldDatetimeModel, ids, iqfd) + return c.Update(IrQwebFieldDatetimeModel, ids, iqfd, nil) } // DeleteIrQwebFieldDatetime deletes an existing ir.qweb.field.datetime record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldDatetime(id int64) (*IrQwebFieldDatetime, error) if err != nil { return nil, err } - if iqfds != nil && len(*iqfds) > 0 { - return &((*iqfds)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.datetime not found", id) + return &((*iqfds)[0]), nil } // GetIrQwebFieldDatetimes gets ir.qweb.field.datetime existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldDatetime(criteria *Criteria) (*IrQwebFieldDateti if err := c.SearchRead(IrQwebFieldDatetimeModel, criteria, NewOptions().Limit(1), iqfds); err != nil { return nil, err } - if iqfds != nil && len(*iqfds) > 0 { - return &((*iqfds)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.datetime was not found with criteria %v", criteria) + return &((*iqfds)[0]), nil } // FindIrQwebFieldDatetimes finds ir.qweb.field.datetime records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldDatetimes(criteria *Criteria, options *Options) // FindIrQwebFieldDatetimeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldDatetimeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldDatetimeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldDatetimeModel, criteria, options) } // FindIrQwebFieldDatetimeId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldDatetimeId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.datetime was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_duration.go b/ir_qweb_field_duration.go index ed1b0d7a..ec5d1f30 100644 --- a/ir_qweb_field_duration.go +++ b/ir_qweb_field_duration.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldDuration represents ir.qweb.field.duration model. type IrQwebFieldDuration struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldDurations(iqfds []*IrQwebFieldDuration) ([]int for _, v := range iqfds { vv = append(vv, v) } - return c.Create(IrQwebFieldDurationModel, vv) + return c.Create(IrQwebFieldDurationModel, vv, nil) } // UpdateIrQwebFieldDuration updates an existing ir.qweb.field.duration record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldDuration(iqfd *IrQwebFieldDuration) error { // UpdateIrQwebFieldDurations updates existing ir.qweb.field.duration records. // All records (represented by ids) will be updated by iqfd values. func (c *Client) UpdateIrQwebFieldDurations(ids []int64, iqfd *IrQwebFieldDuration) error { - return c.Update(IrQwebFieldDurationModel, ids, iqfd) + return c.Update(IrQwebFieldDurationModel, ids, iqfd, nil) } // DeleteIrQwebFieldDuration deletes an existing ir.qweb.field.duration record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldDuration(id int64) (*IrQwebFieldDuration, error) if err != nil { return nil, err } - if iqfds != nil && len(*iqfds) > 0 { - return &((*iqfds)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.duration not found", id) + return &((*iqfds)[0]), nil } // GetIrQwebFieldDurations gets ir.qweb.field.duration existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldDuration(criteria *Criteria) (*IrQwebFieldDurati if err := c.SearchRead(IrQwebFieldDurationModel, criteria, NewOptions().Limit(1), iqfds); err != nil { return nil, err } - if iqfds != nil && len(*iqfds) > 0 { - return &((*iqfds)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.duration was not found with criteria %v", criteria) + return &((*iqfds)[0]), nil } // FindIrQwebFieldDurations finds ir.qweb.field.duration records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldDurations(criteria *Criteria, options *Options) // FindIrQwebFieldDurationIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldDurationIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldDurationModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldDurationModel, criteria, options) } // FindIrQwebFieldDurationId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldDurationId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.duration was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_float.go b/ir_qweb_field_float.go index b6f9972b..c59756e7 100644 --- a/ir_qweb_field_float.go +++ b/ir_qweb_field_float.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldFloat represents ir.qweb.field.float model. type IrQwebFieldFloat struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldFloats(iqffs []*IrQwebFieldFloat) ([]int64, er for _, v := range iqffs { vv = append(vv, v) } - return c.Create(IrQwebFieldFloatModel, vv) + return c.Create(IrQwebFieldFloatModel, vv, nil) } // UpdateIrQwebFieldFloat updates an existing ir.qweb.field.float record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldFloat(iqff *IrQwebFieldFloat) error { // UpdateIrQwebFieldFloats updates existing ir.qweb.field.float records. // All records (represented by ids) will be updated by iqff values. func (c *Client) UpdateIrQwebFieldFloats(ids []int64, iqff *IrQwebFieldFloat) error { - return c.Update(IrQwebFieldFloatModel, ids, iqff) + return c.Update(IrQwebFieldFloatModel, ids, iqff, nil) } // DeleteIrQwebFieldFloat deletes an existing ir.qweb.field.float record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldFloat(id int64) (*IrQwebFieldFloat, error) { if err != nil { return nil, err } - if iqffs != nil && len(*iqffs) > 0 { - return &((*iqffs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.float not found", id) + return &((*iqffs)[0]), nil } // GetIrQwebFieldFloats gets ir.qweb.field.float existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldFloat(criteria *Criteria) (*IrQwebFieldFloat, er if err := c.SearchRead(IrQwebFieldFloatModel, criteria, NewOptions().Limit(1), iqffs); err != nil { return nil, err } - if iqffs != nil && len(*iqffs) > 0 { - return &((*iqffs)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.float was not found with criteria %v", criteria) + return &((*iqffs)[0]), nil } // FindIrQwebFieldFloats finds ir.qweb.field.float records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldFloats(criteria *Criteria, options *Options) (*I // FindIrQwebFieldFloatIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldFloatIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldFloatModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldFloatModel, criteria, options) } // FindIrQwebFieldFloatId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldFloatId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.float was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_float_time.go b/ir_qweb_field_float_time.go index 2d8ab93c..67b55865 100644 --- a/ir_qweb_field_float_time.go +++ b/ir_qweb_field_float_time.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldFloatTime represents ir.qweb.field.float_time model. type IrQwebFieldFloatTime struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldFloatTimes(iqffs []*IrQwebFieldFloatTime) ([]i for _, v := range iqffs { vv = append(vv, v) } - return c.Create(IrQwebFieldFloatTimeModel, vv) + return c.Create(IrQwebFieldFloatTimeModel, vv, nil) } // UpdateIrQwebFieldFloatTime updates an existing ir.qweb.field.float_time record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldFloatTime(iqff *IrQwebFieldFloatTime) error { // UpdateIrQwebFieldFloatTimes updates existing ir.qweb.field.float_time records. // All records (represented by ids) will be updated by iqff values. func (c *Client) UpdateIrQwebFieldFloatTimes(ids []int64, iqff *IrQwebFieldFloatTime) error { - return c.Update(IrQwebFieldFloatTimeModel, ids, iqff) + return c.Update(IrQwebFieldFloatTimeModel, ids, iqff, nil) } // DeleteIrQwebFieldFloatTime deletes an existing ir.qweb.field.float_time record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldFloatTime(id int64) (*IrQwebFieldFloatTime, error if err != nil { return nil, err } - if iqffs != nil && len(*iqffs) > 0 { - return &((*iqffs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.float_time not found", id) + return &((*iqffs)[0]), nil } // GetIrQwebFieldFloatTimes gets ir.qweb.field.float_time existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldFloatTime(criteria *Criteria) (*IrQwebFieldFloat if err := c.SearchRead(IrQwebFieldFloatTimeModel, criteria, NewOptions().Limit(1), iqffs); err != nil { return nil, err } - if iqffs != nil && len(*iqffs) > 0 { - return &((*iqffs)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.float_time was not found with criteria %v", criteria) + return &((*iqffs)[0]), nil } // FindIrQwebFieldFloatTimes finds ir.qweb.field.float_time records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldFloatTimes(criteria *Criteria, options *Options) // FindIrQwebFieldFloatTimeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldFloatTimeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldFloatTimeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldFloatTimeModel, criteria, options) } // FindIrQwebFieldFloatTimeId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldFloatTimeId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.float_time was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_html.go b/ir_qweb_field_html.go index afda7150..916f1165 100644 --- a/ir_qweb_field_html.go +++ b/ir_qweb_field_html.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldHtml represents ir.qweb.field.html model. type IrQwebFieldHtml struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldHtmls(iqfhs []*IrQwebFieldHtml) ([]int64, erro for _, v := range iqfhs { vv = append(vv, v) } - return c.Create(IrQwebFieldHtmlModel, vv) + return c.Create(IrQwebFieldHtmlModel, vv, nil) } // UpdateIrQwebFieldHtml updates an existing ir.qweb.field.html record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldHtml(iqfh *IrQwebFieldHtml) error { // UpdateIrQwebFieldHtmls updates existing ir.qweb.field.html records. // All records (represented by ids) will be updated by iqfh values. func (c *Client) UpdateIrQwebFieldHtmls(ids []int64, iqfh *IrQwebFieldHtml) error { - return c.Update(IrQwebFieldHtmlModel, ids, iqfh) + return c.Update(IrQwebFieldHtmlModel, ids, iqfh, nil) } // DeleteIrQwebFieldHtml deletes an existing ir.qweb.field.html record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldHtml(id int64) (*IrQwebFieldHtml, error) { if err != nil { return nil, err } - if iqfhs != nil && len(*iqfhs) > 0 { - return &((*iqfhs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.html not found", id) + return &((*iqfhs)[0]), nil } // GetIrQwebFieldHtmls gets ir.qweb.field.html existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldHtml(criteria *Criteria) (*IrQwebFieldHtml, erro if err := c.SearchRead(IrQwebFieldHtmlModel, criteria, NewOptions().Limit(1), iqfhs); err != nil { return nil, err } - if iqfhs != nil && len(*iqfhs) > 0 { - return &((*iqfhs)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.html was not found with criteria %v", criteria) + return &((*iqfhs)[0]), nil } // FindIrQwebFieldHtmls finds ir.qweb.field.html records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldHtmls(criteria *Criteria, options *Options) (*Ir // FindIrQwebFieldHtmlIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldHtmlIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldHtmlModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldHtmlModel, criteria, options) } // FindIrQwebFieldHtmlId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldHtmlId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.html was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_image.go b/ir_qweb_field_image.go index 5344be52..5c058f88 100644 --- a/ir_qweb_field_image.go +++ b/ir_qweb_field_image.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldImage represents ir.qweb.field.image model. type IrQwebFieldImage struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldImages(iqfis []*IrQwebFieldImage) ([]int64, er for _, v := range iqfis { vv = append(vv, v) } - return c.Create(IrQwebFieldImageModel, vv) + return c.Create(IrQwebFieldImageModel, vv, nil) } // UpdateIrQwebFieldImage updates an existing ir.qweb.field.image record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldImage(iqfi *IrQwebFieldImage) error { // UpdateIrQwebFieldImages updates existing ir.qweb.field.image records. // All records (represented by ids) will be updated by iqfi values. func (c *Client) UpdateIrQwebFieldImages(ids []int64, iqfi *IrQwebFieldImage) error { - return c.Update(IrQwebFieldImageModel, ids, iqfi) + return c.Update(IrQwebFieldImageModel, ids, iqfi, nil) } // DeleteIrQwebFieldImage deletes an existing ir.qweb.field.image record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldImage(id int64) (*IrQwebFieldImage, error) { if err != nil { return nil, err } - if iqfis != nil && len(*iqfis) > 0 { - return &((*iqfis)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.image not found", id) + return &((*iqfis)[0]), nil } // GetIrQwebFieldImages gets ir.qweb.field.image existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldImage(criteria *Criteria) (*IrQwebFieldImage, er if err := c.SearchRead(IrQwebFieldImageModel, criteria, NewOptions().Limit(1), iqfis); err != nil { return nil, err } - if iqfis != nil && len(*iqfis) > 0 { - return &((*iqfis)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.image was not found with criteria %v", criteria) + return &((*iqfis)[0]), nil } // FindIrQwebFieldImages finds ir.qweb.field.image records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldImages(criteria *Criteria, options *Options) (*I // FindIrQwebFieldImageIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldImageIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldImageModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldImageModel, criteria, options) } // FindIrQwebFieldImageId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldImageId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.image was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_integer.go b/ir_qweb_field_integer.go index 9303ffb9..52ca86ae 100644 --- a/ir_qweb_field_integer.go +++ b/ir_qweb_field_integer.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldInteger represents ir.qweb.field.integer model. type IrQwebFieldInteger struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldIntegers(iqfis []*IrQwebFieldInteger) ([]int64 for _, v := range iqfis { vv = append(vv, v) } - return c.Create(IrQwebFieldIntegerModel, vv) + return c.Create(IrQwebFieldIntegerModel, vv, nil) } // UpdateIrQwebFieldInteger updates an existing ir.qweb.field.integer record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldInteger(iqfi *IrQwebFieldInteger) error { // UpdateIrQwebFieldIntegers updates existing ir.qweb.field.integer records. // All records (represented by ids) will be updated by iqfi values. func (c *Client) UpdateIrQwebFieldIntegers(ids []int64, iqfi *IrQwebFieldInteger) error { - return c.Update(IrQwebFieldIntegerModel, ids, iqfi) + return c.Update(IrQwebFieldIntegerModel, ids, iqfi, nil) } // DeleteIrQwebFieldInteger deletes an existing ir.qweb.field.integer record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldInteger(id int64) (*IrQwebFieldInteger, error) { if err != nil { return nil, err } - if iqfis != nil && len(*iqfis) > 0 { - return &((*iqfis)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.integer not found", id) + return &((*iqfis)[0]), nil } // GetIrQwebFieldIntegers gets ir.qweb.field.integer existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldInteger(criteria *Criteria) (*IrQwebFieldInteger if err := c.SearchRead(IrQwebFieldIntegerModel, criteria, NewOptions().Limit(1), iqfis); err != nil { return nil, err } - if iqfis != nil && len(*iqfis) > 0 { - return &((*iqfis)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.integer was not found with criteria %v", criteria) + return &((*iqfis)[0]), nil } // FindIrQwebFieldIntegers finds ir.qweb.field.integer records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldIntegers(criteria *Criteria, options *Options) ( // FindIrQwebFieldIntegerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldIntegerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldIntegerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldIntegerModel, criteria, options) } // FindIrQwebFieldIntegerId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldIntegerId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.integer was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_many2one.go b/ir_qweb_field_many2one.go index e34602a7..2dd24d69 100644 --- a/ir_qweb_field_many2one.go +++ b/ir_qweb_field_many2one.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldMany2One represents ir.qweb.field.many2one model. type IrQwebFieldMany2One struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldMany2Ones(iqfms []*IrQwebFieldMany2One) ([]int for _, v := range iqfms { vv = append(vv, v) } - return c.Create(IrQwebFieldMany2OneModel, vv) + return c.Create(IrQwebFieldMany2OneModel, vv, nil) } // UpdateIrQwebFieldMany2One updates an existing ir.qweb.field.many2one record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldMany2One(iqfm *IrQwebFieldMany2One) error { // UpdateIrQwebFieldMany2Ones updates existing ir.qweb.field.many2one records. // All records (represented by ids) will be updated by iqfm values. func (c *Client) UpdateIrQwebFieldMany2Ones(ids []int64, iqfm *IrQwebFieldMany2One) error { - return c.Update(IrQwebFieldMany2OneModel, ids, iqfm) + return c.Update(IrQwebFieldMany2OneModel, ids, iqfm, nil) } // DeleteIrQwebFieldMany2One deletes an existing ir.qweb.field.many2one record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldMany2One(id int64) (*IrQwebFieldMany2One, error) if err != nil { return nil, err } - if iqfms != nil && len(*iqfms) > 0 { - return &((*iqfms)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.many2one not found", id) + return &((*iqfms)[0]), nil } // GetIrQwebFieldMany2Ones gets ir.qweb.field.many2one existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldMany2One(criteria *Criteria) (*IrQwebFieldMany2O if err := c.SearchRead(IrQwebFieldMany2OneModel, criteria, NewOptions().Limit(1), iqfms); err != nil { return nil, err } - if iqfms != nil && len(*iqfms) > 0 { - return &((*iqfms)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.many2one was not found with criteria %v", criteria) + return &((*iqfms)[0]), nil } // FindIrQwebFieldMany2Ones finds ir.qweb.field.many2one records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldMany2Ones(criteria *Criteria, options *Options) // FindIrQwebFieldMany2OneIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldMany2OneIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldMany2OneModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldMany2OneModel, criteria, options) } // FindIrQwebFieldMany2OneId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldMany2OneId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.many2one was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_monetary.go b/ir_qweb_field_monetary.go index bc23430f..e17dcc1f 100644 --- a/ir_qweb_field_monetary.go +++ b/ir_qweb_field_monetary.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldMonetary represents ir.qweb.field.monetary model. type IrQwebFieldMonetary struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldMonetarys(iqfms []*IrQwebFieldMonetary) ([]int for _, v := range iqfms { vv = append(vv, v) } - return c.Create(IrQwebFieldMonetaryModel, vv) + return c.Create(IrQwebFieldMonetaryModel, vv, nil) } // UpdateIrQwebFieldMonetary updates an existing ir.qweb.field.monetary record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldMonetary(iqfm *IrQwebFieldMonetary) error { // UpdateIrQwebFieldMonetarys updates existing ir.qweb.field.monetary records. // All records (represented by ids) will be updated by iqfm values. func (c *Client) UpdateIrQwebFieldMonetarys(ids []int64, iqfm *IrQwebFieldMonetary) error { - return c.Update(IrQwebFieldMonetaryModel, ids, iqfm) + return c.Update(IrQwebFieldMonetaryModel, ids, iqfm, nil) } // DeleteIrQwebFieldMonetary deletes an existing ir.qweb.field.monetary record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldMonetary(id int64) (*IrQwebFieldMonetary, error) if err != nil { return nil, err } - if iqfms != nil && len(*iqfms) > 0 { - return &((*iqfms)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.monetary not found", id) + return &((*iqfms)[0]), nil } // GetIrQwebFieldMonetarys gets ir.qweb.field.monetary existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldMonetary(criteria *Criteria) (*IrQwebFieldMoneta if err := c.SearchRead(IrQwebFieldMonetaryModel, criteria, NewOptions().Limit(1), iqfms); err != nil { return nil, err } - if iqfms != nil && len(*iqfms) > 0 { - return &((*iqfms)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.monetary was not found with criteria %v", criteria) + return &((*iqfms)[0]), nil } // FindIrQwebFieldMonetarys finds ir.qweb.field.monetary records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldMonetarys(criteria *Criteria, options *Options) // FindIrQwebFieldMonetaryIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldMonetaryIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldMonetaryModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldMonetaryModel, criteria, options) } // FindIrQwebFieldMonetaryId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldMonetaryId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.monetary was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_qweb.go b/ir_qweb_field_qweb.go index 34e55c71..75055c8d 100644 --- a/ir_qweb_field_qweb.go +++ b/ir_qweb_field_qweb.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldQweb represents ir.qweb.field.qweb model. type IrQwebFieldQweb struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldQwebs(iqfqs []*IrQwebFieldQweb) ([]int64, erro for _, v := range iqfqs { vv = append(vv, v) } - return c.Create(IrQwebFieldQwebModel, vv) + return c.Create(IrQwebFieldQwebModel, vv, nil) } // UpdateIrQwebFieldQweb updates an existing ir.qweb.field.qweb record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldQweb(iqfq *IrQwebFieldQweb) error { // UpdateIrQwebFieldQwebs updates existing ir.qweb.field.qweb records. // All records (represented by ids) will be updated by iqfq values. func (c *Client) UpdateIrQwebFieldQwebs(ids []int64, iqfq *IrQwebFieldQweb) error { - return c.Update(IrQwebFieldQwebModel, ids, iqfq) + return c.Update(IrQwebFieldQwebModel, ids, iqfq, nil) } // DeleteIrQwebFieldQweb deletes an existing ir.qweb.field.qweb record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldQweb(id int64) (*IrQwebFieldQweb, error) { if err != nil { return nil, err } - if iqfqs != nil && len(*iqfqs) > 0 { - return &((*iqfqs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.qweb not found", id) + return &((*iqfqs)[0]), nil } // GetIrQwebFieldQwebs gets ir.qweb.field.qweb existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldQweb(criteria *Criteria) (*IrQwebFieldQweb, erro if err := c.SearchRead(IrQwebFieldQwebModel, criteria, NewOptions().Limit(1), iqfqs); err != nil { return nil, err } - if iqfqs != nil && len(*iqfqs) > 0 { - return &((*iqfqs)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.qweb was not found with criteria %v", criteria) + return &((*iqfqs)[0]), nil } // FindIrQwebFieldQwebs finds ir.qweb.field.qweb records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldQwebs(criteria *Criteria, options *Options) (*Ir // FindIrQwebFieldQwebIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldQwebIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldQwebModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldQwebModel, criteria, options) } // FindIrQwebFieldQwebId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldQwebId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.qweb was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_relative.go b/ir_qweb_field_relative.go index b3dea994..4e424119 100644 --- a/ir_qweb_field_relative.go +++ b/ir_qweb_field_relative.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldRelative represents ir.qweb.field.relative model. type IrQwebFieldRelative struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldRelatives(iqfrs []*IrQwebFieldRelative) ([]int for _, v := range iqfrs { vv = append(vv, v) } - return c.Create(IrQwebFieldRelativeModel, vv) + return c.Create(IrQwebFieldRelativeModel, vv, nil) } // UpdateIrQwebFieldRelative updates an existing ir.qweb.field.relative record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldRelative(iqfr *IrQwebFieldRelative) error { // UpdateIrQwebFieldRelatives updates existing ir.qweb.field.relative records. // All records (represented by ids) will be updated by iqfr values. func (c *Client) UpdateIrQwebFieldRelatives(ids []int64, iqfr *IrQwebFieldRelative) error { - return c.Update(IrQwebFieldRelativeModel, ids, iqfr) + return c.Update(IrQwebFieldRelativeModel, ids, iqfr, nil) } // DeleteIrQwebFieldRelative deletes an existing ir.qweb.field.relative record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldRelative(id int64) (*IrQwebFieldRelative, error) if err != nil { return nil, err } - if iqfrs != nil && len(*iqfrs) > 0 { - return &((*iqfrs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.relative not found", id) + return &((*iqfrs)[0]), nil } // GetIrQwebFieldRelatives gets ir.qweb.field.relative existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldRelative(criteria *Criteria) (*IrQwebFieldRelati if err := c.SearchRead(IrQwebFieldRelativeModel, criteria, NewOptions().Limit(1), iqfrs); err != nil { return nil, err } - if iqfrs != nil && len(*iqfrs) > 0 { - return &((*iqfrs)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.relative was not found with criteria %v", criteria) + return &((*iqfrs)[0]), nil } // FindIrQwebFieldRelatives finds ir.qweb.field.relative records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldRelatives(criteria *Criteria, options *Options) // FindIrQwebFieldRelativeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldRelativeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldRelativeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldRelativeModel, criteria, options) } // FindIrQwebFieldRelativeId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldRelativeId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.relative was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_selection.go b/ir_qweb_field_selection.go index 2b789d82..56f25cc9 100644 --- a/ir_qweb_field_selection.go +++ b/ir_qweb_field_selection.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldSelection represents ir.qweb.field.selection model. type IrQwebFieldSelection struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldSelections(iqfss []*IrQwebFieldSelection) ([]i for _, v := range iqfss { vv = append(vv, v) } - return c.Create(IrQwebFieldSelectionModel, vv) + return c.Create(IrQwebFieldSelectionModel, vv, nil) } // UpdateIrQwebFieldSelection updates an existing ir.qweb.field.selection record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldSelection(iqfs *IrQwebFieldSelection) error { // UpdateIrQwebFieldSelections updates existing ir.qweb.field.selection records. // All records (represented by ids) will be updated by iqfs values. func (c *Client) UpdateIrQwebFieldSelections(ids []int64, iqfs *IrQwebFieldSelection) error { - return c.Update(IrQwebFieldSelectionModel, ids, iqfs) + return c.Update(IrQwebFieldSelectionModel, ids, iqfs, nil) } // DeleteIrQwebFieldSelection deletes an existing ir.qweb.field.selection record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldSelection(id int64) (*IrQwebFieldSelection, error if err != nil { return nil, err } - if iqfss != nil && len(*iqfss) > 0 { - return &((*iqfss)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.selection not found", id) + return &((*iqfss)[0]), nil } // GetIrQwebFieldSelections gets ir.qweb.field.selection existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldSelection(criteria *Criteria) (*IrQwebFieldSelec if err := c.SearchRead(IrQwebFieldSelectionModel, criteria, NewOptions().Limit(1), iqfss); err != nil { return nil, err } - if iqfss != nil && len(*iqfss) > 0 { - return &((*iqfss)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.selection was not found with criteria %v", criteria) + return &((*iqfss)[0]), nil } // FindIrQwebFieldSelections finds ir.qweb.field.selection records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldSelections(criteria *Criteria, options *Options) // FindIrQwebFieldSelectionIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldSelectionIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldSelectionModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldSelectionModel, criteria, options) } // FindIrQwebFieldSelectionId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldSelectionId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.selection was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_qweb_field_text.go b/ir_qweb_field_text.go index 2c6bd296..23ee3db2 100644 --- a/ir_qweb_field_text.go +++ b/ir_qweb_field_text.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrQwebFieldText represents ir.qweb.field.text model. type IrQwebFieldText struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateIrQwebFieldTexts(iqfts []*IrQwebFieldText) ([]int64, erro for _, v := range iqfts { vv = append(vv, v) } - return c.Create(IrQwebFieldTextModel, vv) + return c.Create(IrQwebFieldTextModel, vv, nil) } // UpdateIrQwebFieldText updates an existing ir.qweb.field.text record. @@ -51,7 +47,7 @@ func (c *Client) UpdateIrQwebFieldText(iqft *IrQwebFieldText) error { // UpdateIrQwebFieldTexts updates existing ir.qweb.field.text records. // All records (represented by ids) will be updated by iqft values. func (c *Client) UpdateIrQwebFieldTexts(ids []int64, iqft *IrQwebFieldText) error { - return c.Update(IrQwebFieldTextModel, ids, iqft) + return c.Update(IrQwebFieldTextModel, ids, iqft, nil) } // DeleteIrQwebFieldText deletes an existing ir.qweb.field.text record. @@ -70,10 +66,7 @@ func (c *Client) GetIrQwebFieldText(id int64) (*IrQwebFieldText, error) { if err != nil { return nil, err } - if iqfts != nil && len(*iqfts) > 0 { - return &((*iqfts)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.qweb.field.text not found", id) + return &((*iqfts)[0]), nil } // GetIrQwebFieldTexts gets ir.qweb.field.text existing records. @@ -91,10 +84,7 @@ func (c *Client) FindIrQwebFieldText(criteria *Criteria) (*IrQwebFieldText, erro if err := c.SearchRead(IrQwebFieldTextModel, criteria, NewOptions().Limit(1), iqfts); err != nil { return nil, err } - if iqfts != nil && len(*iqfts) > 0 { - return &((*iqfts)[0]), nil - } - return nil, fmt.Errorf("ir.qweb.field.text was not found with criteria %v", criteria) + return &((*iqfts)[0]), nil } // FindIrQwebFieldTexts finds ir.qweb.field.text records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindIrQwebFieldTexts(criteria *Criteria, options *Options) (*Ir // FindIrQwebFieldTextIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrQwebFieldTextIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrQwebFieldTextModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrQwebFieldTextModel, criteria, options) } // FindIrQwebFieldTextId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindIrQwebFieldTextId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.qweb.field.text was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_rule.go b/ir_rule.go index 15060686..12e039a0 100644 --- a/ir_rule.go +++ b/ir_rule.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrRule represents ir.rule model. type IrRule struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -54,7 +50,7 @@ func (c *Client) CreateIrRules(irs []*IrRule) ([]int64, error) { for _, v := range irs { vv = append(vv, v) } - return c.Create(IrRuleModel, vv) + return c.Create(IrRuleModel, vv, nil) } // UpdateIrRule updates an existing ir.rule record. @@ -65,7 +61,7 @@ func (c *Client) UpdateIrRule(ir *IrRule) error { // UpdateIrRules updates existing ir.rule records. // All records (represented by ids) will be updated by ir values. func (c *Client) UpdateIrRules(ids []int64, ir *IrRule) error { - return c.Update(IrRuleModel, ids, ir) + return c.Update(IrRuleModel, ids, ir, nil) } // DeleteIrRule deletes an existing ir.rule record. @@ -84,10 +80,7 @@ func (c *Client) GetIrRule(id int64) (*IrRule, error) { if err != nil { return nil, err } - if irs != nil && len(*irs) > 0 { - return &((*irs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.rule not found", id) + return &((*irs)[0]), nil } // GetIrRules gets ir.rule existing records. @@ -105,10 +98,7 @@ func (c *Client) FindIrRule(criteria *Criteria) (*IrRule, error) { if err := c.SearchRead(IrRuleModel, criteria, NewOptions().Limit(1), irs); err != nil { return nil, err } - if irs != nil && len(*irs) > 0 { - return &((*irs)[0]), nil - } - return nil, fmt.Errorf("ir.rule was not found with criteria %v", criteria) + return &((*irs)[0]), nil } // FindIrRules finds ir.rule records by querying it @@ -124,11 +114,7 @@ func (c *Client) FindIrRules(criteria *Criteria, options *Options) (*IrRules, er // FindIrRuleIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrRuleIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrRuleModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrRuleModel, criteria, options) } // FindIrRuleId finds record id by querying it with criteria. @@ -137,8 +123,5 @@ func (c *Client) FindIrRuleId(criteria *Criteria, options *Options) (int64, erro if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.rule was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_sequence.go b/ir_sequence.go index 86bcf852..41cba6c2 100644 --- a/ir_sequence.go +++ b/ir_sequence.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrSequence represents ir.sequence model. type IrSequence struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -57,7 +53,7 @@ func (c *Client) CreateIrSequences(iss []*IrSequence) ([]int64, error) { for _, v := range iss { vv = append(vv, v) } - return c.Create(IrSequenceModel, vv) + return c.Create(IrSequenceModel, vv, nil) } // UpdateIrSequence updates an existing ir.sequence record. @@ -68,7 +64,7 @@ func (c *Client) UpdateIrSequence(is *IrSequence) error { // UpdateIrSequences updates existing ir.sequence records. // All records (represented by ids) will be updated by is values. func (c *Client) UpdateIrSequences(ids []int64, is *IrSequence) error { - return c.Update(IrSequenceModel, ids, is) + return c.Update(IrSequenceModel, ids, is, nil) } // DeleteIrSequence deletes an existing ir.sequence record. @@ -87,10 +83,7 @@ func (c *Client) GetIrSequence(id int64) (*IrSequence, error) { if err != nil { return nil, err } - if iss != nil && len(*iss) > 0 { - return &((*iss)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.sequence not found", id) + return &((*iss)[0]), nil } // GetIrSequences gets ir.sequence existing records. @@ -108,10 +101,7 @@ func (c *Client) FindIrSequence(criteria *Criteria) (*IrSequence, error) { if err := c.SearchRead(IrSequenceModel, criteria, NewOptions().Limit(1), iss); err != nil { return nil, err } - if iss != nil && len(*iss) > 0 { - return &((*iss)[0]), nil - } - return nil, fmt.Errorf("ir.sequence was not found with criteria %v", criteria) + return &((*iss)[0]), nil } // FindIrSequences finds ir.sequence records by querying it @@ -127,11 +117,7 @@ func (c *Client) FindIrSequences(criteria *Criteria, options *Options) (*IrSeque // FindIrSequenceIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrSequenceIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrSequenceModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrSequenceModel, criteria, options) } // FindIrSequenceId finds record id by querying it with criteria. @@ -140,8 +126,5 @@ func (c *Client) FindIrSequenceId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.sequence was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_sequence_date_range.go b/ir_sequence_date_range.go index 481d9c7d..dabb814b 100644 --- a/ir_sequence_date_range.go +++ b/ir_sequence_date_range.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrSequenceDateRange represents ir.sequence.date_range model. type IrSequenceDateRange struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateIrSequenceDateRanges(isds []*IrSequenceDateRange) ([]int6 for _, v := range isds { vv = append(vv, v) } - return c.Create(IrSequenceDateRangeModel, vv) + return c.Create(IrSequenceDateRangeModel, vv, nil) } // UpdateIrSequenceDateRange updates an existing ir.sequence.date_range record. @@ -60,7 +56,7 @@ func (c *Client) UpdateIrSequenceDateRange(isd *IrSequenceDateRange) error { // UpdateIrSequenceDateRanges updates existing ir.sequence.date_range records. // All records (represented by ids) will be updated by isd values. func (c *Client) UpdateIrSequenceDateRanges(ids []int64, isd *IrSequenceDateRange) error { - return c.Update(IrSequenceDateRangeModel, ids, isd) + return c.Update(IrSequenceDateRangeModel, ids, isd, nil) } // DeleteIrSequenceDateRange deletes an existing ir.sequence.date_range record. @@ -79,10 +75,7 @@ func (c *Client) GetIrSequenceDateRange(id int64) (*IrSequenceDateRange, error) if err != nil { return nil, err } - if isds != nil && len(*isds) > 0 { - return &((*isds)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.sequence.date_range not found", id) + return &((*isds)[0]), nil } // GetIrSequenceDateRanges gets ir.sequence.date_range existing records. @@ -100,10 +93,7 @@ func (c *Client) FindIrSequenceDateRange(criteria *Criteria) (*IrSequenceDateRan if err := c.SearchRead(IrSequenceDateRangeModel, criteria, NewOptions().Limit(1), isds); err != nil { return nil, err } - if isds != nil && len(*isds) > 0 { - return &((*isds)[0]), nil - } - return nil, fmt.Errorf("ir.sequence.date_range was not found with criteria %v", criteria) + return &((*isds)[0]), nil } // FindIrSequenceDateRanges finds ir.sequence.date_range records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindIrSequenceDateRanges(criteria *Criteria, options *Options) // FindIrSequenceDateRangeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrSequenceDateRangeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrSequenceDateRangeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrSequenceDateRangeModel, criteria, options) } // FindIrSequenceDateRangeId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindIrSequenceDateRangeId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.sequence.date_range was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_server_object_lines.go b/ir_server_object_lines.go index 267d45d7..106191c4 100644 --- a/ir_server_object_lines.go +++ b/ir_server_object_lines.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrServerObjectLines represents ir.server.object.lines model. type IrServerObjectLines struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateIrServerObjectLiness(isols []*IrServerObjectLines) ([]int for _, v := range isols { vv = append(vv, v) } - return c.Create(IrServerObjectLinesModel, vv) + return c.Create(IrServerObjectLinesModel, vv, nil) } // UpdateIrServerObjectLines updates an existing ir.server.object.lines record. @@ -59,7 +55,7 @@ func (c *Client) UpdateIrServerObjectLines(isol *IrServerObjectLines) error { // UpdateIrServerObjectLiness updates existing ir.server.object.lines records. // All records (represented by ids) will be updated by isol values. func (c *Client) UpdateIrServerObjectLiness(ids []int64, isol *IrServerObjectLines) error { - return c.Update(IrServerObjectLinesModel, ids, isol) + return c.Update(IrServerObjectLinesModel, ids, isol, nil) } // DeleteIrServerObjectLines deletes an existing ir.server.object.lines record. @@ -78,10 +74,7 @@ func (c *Client) GetIrServerObjectLines(id int64) (*IrServerObjectLines, error) if err != nil { return nil, err } - if isols != nil && len(*isols) > 0 { - return &((*isols)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.server.object.lines not found", id) + return &((*isols)[0]), nil } // GetIrServerObjectLiness gets ir.server.object.lines existing records. @@ -99,10 +92,7 @@ func (c *Client) FindIrServerObjectLines(criteria *Criteria) (*IrServerObjectLin if err := c.SearchRead(IrServerObjectLinesModel, criteria, NewOptions().Limit(1), isols); err != nil { return nil, err } - if isols != nil && len(*isols) > 0 { - return &((*isols)[0]), nil - } - return nil, fmt.Errorf("ir.server.object.lines was not found with criteria %v", criteria) + return &((*isols)[0]), nil } // FindIrServerObjectLiness finds ir.server.object.lines records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindIrServerObjectLiness(criteria *Criteria, options *Options) // FindIrServerObjectLinesIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrServerObjectLinesIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrServerObjectLinesModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrServerObjectLinesModel, criteria, options) } // FindIrServerObjectLinesId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindIrServerObjectLinesId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.server.object.lines was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_translation.go b/ir_translation.go index b2d486b3..104b4528 100644 --- a/ir_translation.go +++ b/ir_translation.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrTranslation represents ir.translation model. type IrTranslation struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateIrTranslations(its []*IrTranslation) ([]int64, error) { for _, v := range its { vv = append(vv, v) } - return c.Create(IrTranslationModel, vv) + return c.Create(IrTranslationModel, vv, nil) } // UpdateIrTranslation updates an existing ir.translation record. @@ -61,7 +57,7 @@ func (c *Client) UpdateIrTranslation(it *IrTranslation) error { // UpdateIrTranslations updates existing ir.translation records. // All records (represented by ids) will be updated by it values. func (c *Client) UpdateIrTranslations(ids []int64, it *IrTranslation) error { - return c.Update(IrTranslationModel, ids, it) + return c.Update(IrTranslationModel, ids, it, nil) } // DeleteIrTranslation deletes an existing ir.translation record. @@ -80,10 +76,7 @@ func (c *Client) GetIrTranslation(id int64) (*IrTranslation, error) { if err != nil { return nil, err } - if its != nil && len(*its) > 0 { - return &((*its)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.translation not found", id) + return &((*its)[0]), nil } // GetIrTranslations gets ir.translation existing records. @@ -101,10 +94,7 @@ func (c *Client) FindIrTranslation(criteria *Criteria) (*IrTranslation, error) { if err := c.SearchRead(IrTranslationModel, criteria, NewOptions().Limit(1), its); err != nil { return nil, err } - if its != nil && len(*its) > 0 { - return &((*its)[0]), nil - } - return nil, fmt.Errorf("ir.translation was not found with criteria %v", criteria) + return &((*its)[0]), nil } // FindIrTranslations finds ir.translation records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindIrTranslations(criteria *Criteria, options *Options) (*IrTr // FindIrTranslationIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrTranslationIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrTranslationModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrTranslationModel, criteria, options) } // FindIrTranslationId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindIrTranslationId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.translation was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_ui_menu.go b/ir_ui_menu.go index 6ecea619..bdf7ea8e 100644 --- a/ir_ui_menu.go +++ b/ir_ui_menu.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrUiMenu represents ir.ui.menu model. type IrUiMenu struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -56,7 +52,7 @@ func (c *Client) CreateIrUiMenus(iums []*IrUiMenu) ([]int64, error) { for _, v := range iums { vv = append(vv, v) } - return c.Create(IrUiMenuModel, vv) + return c.Create(IrUiMenuModel, vv, nil) } // UpdateIrUiMenu updates an existing ir.ui.menu record. @@ -67,7 +63,7 @@ func (c *Client) UpdateIrUiMenu(ium *IrUiMenu) error { // UpdateIrUiMenus updates existing ir.ui.menu records. // All records (represented by ids) will be updated by ium values. func (c *Client) UpdateIrUiMenus(ids []int64, ium *IrUiMenu) error { - return c.Update(IrUiMenuModel, ids, ium) + return c.Update(IrUiMenuModel, ids, ium, nil) } // DeleteIrUiMenu deletes an existing ir.ui.menu record. @@ -86,10 +82,7 @@ func (c *Client) GetIrUiMenu(id int64) (*IrUiMenu, error) { if err != nil { return nil, err } - if iums != nil && len(*iums) > 0 { - return &((*iums)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.ui.menu not found", id) + return &((*iums)[0]), nil } // GetIrUiMenus gets ir.ui.menu existing records. @@ -107,10 +100,7 @@ func (c *Client) FindIrUiMenu(criteria *Criteria) (*IrUiMenu, error) { if err := c.SearchRead(IrUiMenuModel, criteria, NewOptions().Limit(1), iums); err != nil { return nil, err } - if iums != nil && len(*iums) > 0 { - return &((*iums)[0]), nil - } - return nil, fmt.Errorf("ir.ui.menu was not found with criteria %v", criteria) + return &((*iums)[0]), nil } // FindIrUiMenus finds ir.ui.menu records by querying it @@ -126,11 +116,7 @@ func (c *Client) FindIrUiMenus(criteria *Criteria, options *Options) (*IrUiMenus // FindIrUiMenuIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrUiMenuIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrUiMenuModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrUiMenuModel, criteria, options) } // FindIrUiMenuId finds record id by querying it with criteria. @@ -139,8 +125,5 @@ func (c *Client) FindIrUiMenuId(criteria *Criteria, options *Options) (int64, er if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.ui.menu was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_ui_view.go b/ir_ui_view.go index a35ece92..d66be244 100644 --- a/ir_ui_view.go +++ b/ir_ui_view.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrUiView represents ir.ui.view model. type IrUiView struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -62,7 +58,7 @@ func (c *Client) CreateIrUiViews(iuvs []*IrUiView) ([]int64, error) { for _, v := range iuvs { vv = append(vv, v) } - return c.Create(IrUiViewModel, vv) + return c.Create(IrUiViewModel, vv, nil) } // UpdateIrUiView updates an existing ir.ui.view record. @@ -73,7 +69,7 @@ func (c *Client) UpdateIrUiView(iuv *IrUiView) error { // UpdateIrUiViews updates existing ir.ui.view records. // All records (represented by ids) will be updated by iuv values. func (c *Client) UpdateIrUiViews(ids []int64, iuv *IrUiView) error { - return c.Update(IrUiViewModel, ids, iuv) + return c.Update(IrUiViewModel, ids, iuv, nil) } // DeleteIrUiView deletes an existing ir.ui.view record. @@ -92,10 +88,7 @@ func (c *Client) GetIrUiView(id int64) (*IrUiView, error) { if err != nil { return nil, err } - if iuvs != nil && len(*iuvs) > 0 { - return &((*iuvs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.ui.view not found", id) + return &((*iuvs)[0]), nil } // GetIrUiViews gets ir.ui.view existing records. @@ -113,10 +106,7 @@ func (c *Client) FindIrUiView(criteria *Criteria) (*IrUiView, error) { if err := c.SearchRead(IrUiViewModel, criteria, NewOptions().Limit(1), iuvs); err != nil { return nil, err } - if iuvs != nil && len(*iuvs) > 0 { - return &((*iuvs)[0]), nil - } - return nil, fmt.Errorf("ir.ui.view was not found with criteria %v", criteria) + return &((*iuvs)[0]), nil } // FindIrUiViews finds ir.ui.view records by querying it @@ -132,11 +122,7 @@ func (c *Client) FindIrUiViews(criteria *Criteria, options *Options) (*IrUiViews // FindIrUiViewIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrUiViewIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrUiViewModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrUiViewModel, criteria, options) } // FindIrUiViewId finds record id by querying it with criteria. @@ -145,8 +131,5 @@ func (c *Client) FindIrUiViewId(criteria *Criteria, options *Options) (int64, er if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.ui.view was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/ir_ui_view_custom.go b/ir_ui_view_custom.go index bb1a3953..ea06bb61 100644 --- a/ir_ui_view_custom.go +++ b/ir_ui_view_custom.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // IrUiViewCustom represents ir.ui.view.custom model. type IrUiViewCustom struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateIrUiViewCustoms(iuvcs []*IrUiViewCustom) ([]int64, error) for _, v := range iuvcs { vv = append(vv, v) } - return c.Create(IrUiViewCustomModel, vv) + return c.Create(IrUiViewCustomModel, vv, nil) } // UpdateIrUiViewCustom updates an existing ir.ui.view.custom record. @@ -58,7 +54,7 @@ func (c *Client) UpdateIrUiViewCustom(iuvc *IrUiViewCustom) error { // UpdateIrUiViewCustoms updates existing ir.ui.view.custom records. // All records (represented by ids) will be updated by iuvc values. func (c *Client) UpdateIrUiViewCustoms(ids []int64, iuvc *IrUiViewCustom) error { - return c.Update(IrUiViewCustomModel, ids, iuvc) + return c.Update(IrUiViewCustomModel, ids, iuvc, nil) } // DeleteIrUiViewCustom deletes an existing ir.ui.view.custom record. @@ -77,10 +73,7 @@ func (c *Client) GetIrUiViewCustom(id int64) (*IrUiViewCustom, error) { if err != nil { return nil, err } - if iuvcs != nil && len(*iuvcs) > 0 { - return &((*iuvcs)[0]), nil - } - return nil, fmt.Errorf("id %v of ir.ui.view.custom not found", id) + return &((*iuvcs)[0]), nil } // GetIrUiViewCustoms gets ir.ui.view.custom existing records. @@ -98,10 +91,7 @@ func (c *Client) FindIrUiViewCustom(criteria *Criteria) (*IrUiViewCustom, error) if err := c.SearchRead(IrUiViewCustomModel, criteria, NewOptions().Limit(1), iuvcs); err != nil { return nil, err } - if iuvcs != nil && len(*iuvcs) > 0 { - return &((*iuvcs)[0]), nil - } - return nil, fmt.Errorf("ir.ui.view.custom was not found with criteria %v", criteria) + return &((*iuvcs)[0]), nil } // FindIrUiViewCustoms finds ir.ui.view.custom records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindIrUiViewCustoms(criteria *Criteria, options *Options) (*IrU // FindIrUiViewCustomIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindIrUiViewCustomIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(IrUiViewCustomModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(IrUiViewCustomModel, criteria, options) } // FindIrUiViewCustomId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindIrUiViewCustomId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("ir.ui.view.custom was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/link_tracker.go b/link_tracker.go index cc246f78..8634ef7d 100644 --- a/link_tracker.go +++ b/link_tracker.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // LinkTracker represents link.tracker model. type LinkTracker struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -60,7 +56,7 @@ func (c *Client) CreateLinkTrackers(lts []*LinkTracker) ([]int64, error) { for _, v := range lts { vv = append(vv, v) } - return c.Create(LinkTrackerModel, vv) + return c.Create(LinkTrackerModel, vv, nil) } // UpdateLinkTracker updates an existing link.tracker record. @@ -71,7 +67,7 @@ func (c *Client) UpdateLinkTracker(lt *LinkTracker) error { // UpdateLinkTrackers updates existing link.tracker records. // All records (represented by ids) will be updated by lt values. func (c *Client) UpdateLinkTrackers(ids []int64, lt *LinkTracker) error { - return c.Update(LinkTrackerModel, ids, lt) + return c.Update(LinkTrackerModel, ids, lt, nil) } // DeleteLinkTracker deletes an existing link.tracker record. @@ -90,10 +86,7 @@ func (c *Client) GetLinkTracker(id int64) (*LinkTracker, error) { if err != nil { return nil, err } - if lts != nil && len(*lts) > 0 { - return &((*lts)[0]), nil - } - return nil, fmt.Errorf("id %v of link.tracker not found", id) + return &((*lts)[0]), nil } // GetLinkTrackers gets link.tracker existing records. @@ -111,10 +104,7 @@ func (c *Client) FindLinkTracker(criteria *Criteria) (*LinkTracker, error) { if err := c.SearchRead(LinkTrackerModel, criteria, NewOptions().Limit(1), lts); err != nil { return nil, err } - if lts != nil && len(*lts) > 0 { - return &((*lts)[0]), nil - } - return nil, fmt.Errorf("link.tracker was not found with criteria %v", criteria) + return &((*lts)[0]), nil } // FindLinkTrackers finds link.tracker records by querying it @@ -130,11 +120,7 @@ func (c *Client) FindLinkTrackers(criteria *Criteria, options *Options) (*LinkTr // FindLinkTrackerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindLinkTrackerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(LinkTrackerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(LinkTrackerModel, criteria, options) } // FindLinkTrackerId finds record id by querying it with criteria. @@ -143,8 +129,5 @@ func (c *Client) FindLinkTrackerId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("link.tracker was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/link_tracker_click.go b/link_tracker_click.go index 881a08ae..de921b43 100644 --- a/link_tracker_click.go +++ b/link_tracker_click.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // LinkTrackerClick represents link.tracker.click model. type LinkTrackerClick struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -51,7 +47,7 @@ func (c *Client) CreateLinkTrackerClicks(ltcs []*LinkTrackerClick) ([]int64, err for _, v := range ltcs { vv = append(vv, v) } - return c.Create(LinkTrackerClickModel, vv) + return c.Create(LinkTrackerClickModel, vv, nil) } // UpdateLinkTrackerClick updates an existing link.tracker.click record. @@ -62,7 +58,7 @@ func (c *Client) UpdateLinkTrackerClick(ltc *LinkTrackerClick) error { // UpdateLinkTrackerClicks updates existing link.tracker.click records. // All records (represented by ids) will be updated by ltc values. func (c *Client) UpdateLinkTrackerClicks(ids []int64, ltc *LinkTrackerClick) error { - return c.Update(LinkTrackerClickModel, ids, ltc) + return c.Update(LinkTrackerClickModel, ids, ltc, nil) } // DeleteLinkTrackerClick deletes an existing link.tracker.click record. @@ -81,10 +77,7 @@ func (c *Client) GetLinkTrackerClick(id int64) (*LinkTrackerClick, error) { if err != nil { return nil, err } - if ltcs != nil && len(*ltcs) > 0 { - return &((*ltcs)[0]), nil - } - return nil, fmt.Errorf("id %v of link.tracker.click not found", id) + return &((*ltcs)[0]), nil } // GetLinkTrackerClicks gets link.tracker.click existing records. @@ -102,10 +95,7 @@ func (c *Client) FindLinkTrackerClick(criteria *Criteria) (*LinkTrackerClick, er if err := c.SearchRead(LinkTrackerClickModel, criteria, NewOptions().Limit(1), ltcs); err != nil { return nil, err } - if ltcs != nil && len(*ltcs) > 0 { - return &((*ltcs)[0]), nil - } - return nil, fmt.Errorf("link.tracker.click was not found with criteria %v", criteria) + return &((*ltcs)[0]), nil } // FindLinkTrackerClicks finds link.tracker.click records by querying it @@ -121,11 +111,7 @@ func (c *Client) FindLinkTrackerClicks(criteria *Criteria, options *Options) (*L // FindLinkTrackerClickIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindLinkTrackerClickIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(LinkTrackerClickModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(LinkTrackerClickModel, criteria, options) } // FindLinkTrackerClickId finds record id by querying it with criteria. @@ -134,8 +120,5 @@ func (c *Client) FindLinkTrackerClickId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("link.tracker.click was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/link_tracker_code.go b/link_tracker_code.go index 6d9e0268..59ebbb4e 100644 --- a/link_tracker_code.go +++ b/link_tracker_code.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // LinkTrackerCode represents link.tracker.code model. type LinkTrackerCode struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateLinkTrackerCodes(ltcs []*LinkTrackerCode) ([]int64, error for _, v := range ltcs { vv = append(vv, v) } - return c.Create(LinkTrackerCodeModel, vv) + return c.Create(LinkTrackerCodeModel, vv, nil) } // UpdateLinkTrackerCode updates an existing link.tracker.code record. @@ -57,7 +53,7 @@ func (c *Client) UpdateLinkTrackerCode(ltc *LinkTrackerCode) error { // UpdateLinkTrackerCodes updates existing link.tracker.code records. // All records (represented by ids) will be updated by ltc values. func (c *Client) UpdateLinkTrackerCodes(ids []int64, ltc *LinkTrackerCode) error { - return c.Update(LinkTrackerCodeModel, ids, ltc) + return c.Update(LinkTrackerCodeModel, ids, ltc, nil) } // DeleteLinkTrackerCode deletes an existing link.tracker.code record. @@ -76,10 +72,7 @@ func (c *Client) GetLinkTrackerCode(id int64) (*LinkTrackerCode, error) { if err != nil { return nil, err } - if ltcs != nil && len(*ltcs) > 0 { - return &((*ltcs)[0]), nil - } - return nil, fmt.Errorf("id %v of link.tracker.code not found", id) + return &((*ltcs)[0]), nil } // GetLinkTrackerCodes gets link.tracker.code existing records. @@ -97,10 +90,7 @@ func (c *Client) FindLinkTrackerCode(criteria *Criteria) (*LinkTrackerCode, erro if err := c.SearchRead(LinkTrackerCodeModel, criteria, NewOptions().Limit(1), ltcs); err != nil { return nil, err } - if ltcs != nil && len(*ltcs) > 0 { - return &((*ltcs)[0]), nil - } - return nil, fmt.Errorf("link.tracker.code was not found with criteria %v", criteria) + return &((*ltcs)[0]), nil } // FindLinkTrackerCodes finds link.tracker.code records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindLinkTrackerCodes(criteria *Criteria, options *Options) (*Li // FindLinkTrackerCodeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindLinkTrackerCodeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(LinkTrackerCodeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(LinkTrackerCodeModel, criteria, options) } // FindLinkTrackerCodeId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindLinkTrackerCodeId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("link.tracker.code was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_activity.go b/mail_activity.go index 7c877954..73335d8a 100644 --- a/mail_activity.go +++ b/mail_activity.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailActivity represents mail.activity model. type MailActivity struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -61,7 +57,7 @@ func (c *Client) CreateMailActivitys(mas []*MailActivity) ([]int64, error) { for _, v := range mas { vv = append(vv, v) } - return c.Create(MailActivityModel, vv) + return c.Create(MailActivityModel, vv, nil) } // UpdateMailActivity updates an existing mail.activity record. @@ -72,7 +68,7 @@ func (c *Client) UpdateMailActivity(ma *MailActivity) error { // UpdateMailActivitys updates existing mail.activity records. // All records (represented by ids) will be updated by ma values. func (c *Client) UpdateMailActivitys(ids []int64, ma *MailActivity) error { - return c.Update(MailActivityModel, ids, ma) + return c.Update(MailActivityModel, ids, ma, nil) } // DeleteMailActivity deletes an existing mail.activity record. @@ -91,10 +87,7 @@ func (c *Client) GetMailActivity(id int64) (*MailActivity, error) { if err != nil { return nil, err } - if mas != nil && len(*mas) > 0 { - return &((*mas)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.activity not found", id) + return &((*mas)[0]), nil } // GetMailActivitys gets mail.activity existing records. @@ -112,10 +105,7 @@ func (c *Client) FindMailActivity(criteria *Criteria) (*MailActivity, error) { if err := c.SearchRead(MailActivityModel, criteria, NewOptions().Limit(1), mas); err != nil { return nil, err } - if mas != nil && len(*mas) > 0 { - return &((*mas)[0]), nil - } - return nil, fmt.Errorf("mail.activity was not found with criteria %v", criteria) + return &((*mas)[0]), nil } // FindMailActivitys finds mail.activity records by querying it @@ -131,11 +121,7 @@ func (c *Client) FindMailActivitys(criteria *Criteria, options *Options) (*MailA // FindMailActivityIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailActivityIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailActivityModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailActivityModel, criteria, options) } // FindMailActivityId finds record id by querying it with criteria. @@ -144,8 +130,5 @@ func (c *Client) FindMailActivityId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.activity was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_activity_mixin.go b/mail_activity_mixin.go index e8861b0b..63a8e92b 100644 --- a/mail_activity_mixin.go +++ b/mail_activity_mixin.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailActivityMixin represents mail.activity.mixin model. type MailActivityMixin struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateMailActivityMixins(mams []*MailActivityMixin) ([]int64, e for _, v := range mams { vv = append(vv, v) } - return c.Create(MailActivityMixinModel, vv) + return c.Create(MailActivityMixinModel, vv, nil) } // UpdateMailActivityMixin updates an existing mail.activity.mixin record. @@ -57,7 +53,7 @@ func (c *Client) UpdateMailActivityMixin(mam *MailActivityMixin) error { // UpdateMailActivityMixins updates existing mail.activity.mixin records. // All records (represented by ids) will be updated by mam values. func (c *Client) UpdateMailActivityMixins(ids []int64, mam *MailActivityMixin) error { - return c.Update(MailActivityMixinModel, ids, mam) + return c.Update(MailActivityMixinModel, ids, mam, nil) } // DeleteMailActivityMixin deletes an existing mail.activity.mixin record. @@ -76,10 +72,7 @@ func (c *Client) GetMailActivityMixin(id int64) (*MailActivityMixin, error) { if err != nil { return nil, err } - if mams != nil && len(*mams) > 0 { - return &((*mams)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.activity.mixin not found", id) + return &((*mams)[0]), nil } // GetMailActivityMixins gets mail.activity.mixin existing records. @@ -97,10 +90,7 @@ func (c *Client) FindMailActivityMixin(criteria *Criteria) (*MailActivityMixin, if err := c.SearchRead(MailActivityMixinModel, criteria, NewOptions().Limit(1), mams); err != nil { return nil, err } - if mams != nil && len(*mams) > 0 { - return &((*mams)[0]), nil - } - return nil, fmt.Errorf("mail.activity.mixin was not found with criteria %v", criteria) + return &((*mams)[0]), nil } // FindMailActivityMixins finds mail.activity.mixin records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindMailActivityMixins(criteria *Criteria, options *Options) (* // FindMailActivityMixinIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailActivityMixinIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailActivityMixinModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailActivityMixinModel, criteria, options) } // FindMailActivityMixinId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindMailActivityMixinId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.activity.mixin was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_activity_type.go b/mail_activity_type.go index 0102ad6c..13e6a406 100644 --- a/mail_activity_type.go +++ b/mail_activity_type.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailActivityType represents mail.activity.type model. type MailActivityType struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -53,7 +49,7 @@ func (c *Client) CreateMailActivityTypes(mats []*MailActivityType) ([]int64, err for _, v := range mats { vv = append(vv, v) } - return c.Create(MailActivityTypeModel, vv) + return c.Create(MailActivityTypeModel, vv, nil) } // UpdateMailActivityType updates an existing mail.activity.type record. @@ -64,7 +60,7 @@ func (c *Client) UpdateMailActivityType(mat *MailActivityType) error { // UpdateMailActivityTypes updates existing mail.activity.type records. // All records (represented by ids) will be updated by mat values. func (c *Client) UpdateMailActivityTypes(ids []int64, mat *MailActivityType) error { - return c.Update(MailActivityTypeModel, ids, mat) + return c.Update(MailActivityTypeModel, ids, mat, nil) } // DeleteMailActivityType deletes an existing mail.activity.type record. @@ -83,10 +79,7 @@ func (c *Client) GetMailActivityType(id int64) (*MailActivityType, error) { if err != nil { return nil, err } - if mats != nil && len(*mats) > 0 { - return &((*mats)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.activity.type not found", id) + return &((*mats)[0]), nil } // GetMailActivityTypes gets mail.activity.type existing records. @@ -104,10 +97,7 @@ func (c *Client) FindMailActivityType(criteria *Criteria) (*MailActivityType, er if err := c.SearchRead(MailActivityTypeModel, criteria, NewOptions().Limit(1), mats); err != nil { return nil, err } - if mats != nil && len(*mats) > 0 { - return &((*mats)[0]), nil - } - return nil, fmt.Errorf("mail.activity.type was not found with criteria %v", criteria) + return &((*mats)[0]), nil } // FindMailActivityTypes finds mail.activity.type records by querying it @@ -123,11 +113,7 @@ func (c *Client) FindMailActivityTypes(criteria *Criteria, options *Options) (*M // FindMailActivityTypeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailActivityTypeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailActivityTypeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailActivityTypeModel, criteria, options) } // FindMailActivityTypeId finds record id by querying it with criteria. @@ -136,8 +122,5 @@ func (c *Client) FindMailActivityTypeId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.activity.type was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_alias.go b/mail_alias.go index 73f14290..222b1e1d 100644 --- a/mail_alias.go +++ b/mail_alias.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailAlias represents mail.alias model. type MailAlias struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -53,7 +49,7 @@ func (c *Client) CreateMailAliass(mas []*MailAlias) ([]int64, error) { for _, v := range mas { vv = append(vv, v) } - return c.Create(MailAliasModel, vv) + return c.Create(MailAliasModel, vv, nil) } // UpdateMailAlias updates an existing mail.alias record. @@ -64,7 +60,7 @@ func (c *Client) UpdateMailAlias(ma *MailAlias) error { // UpdateMailAliass updates existing mail.alias records. // All records (represented by ids) will be updated by ma values. func (c *Client) UpdateMailAliass(ids []int64, ma *MailAlias) error { - return c.Update(MailAliasModel, ids, ma) + return c.Update(MailAliasModel, ids, ma, nil) } // DeleteMailAlias deletes an existing mail.alias record. @@ -83,10 +79,7 @@ func (c *Client) GetMailAlias(id int64) (*MailAlias, error) { if err != nil { return nil, err } - if mas != nil && len(*mas) > 0 { - return &((*mas)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.alias not found", id) + return &((*mas)[0]), nil } // GetMailAliass gets mail.alias existing records. @@ -104,10 +97,7 @@ func (c *Client) FindMailAlias(criteria *Criteria) (*MailAlias, error) { if err := c.SearchRead(MailAliasModel, criteria, NewOptions().Limit(1), mas); err != nil { return nil, err } - if mas != nil && len(*mas) > 0 { - return &((*mas)[0]), nil - } - return nil, fmt.Errorf("mail.alias was not found with criteria %v", criteria) + return &((*mas)[0]), nil } // FindMailAliass finds mail.alias records by querying it @@ -123,11 +113,7 @@ func (c *Client) FindMailAliass(criteria *Criteria, options *Options) (*MailAlia // FindMailAliasIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailAliasIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailAliasModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailAliasModel, criteria, options) } // FindMailAliasId finds record id by querying it with criteria. @@ -136,8 +122,5 @@ func (c *Client) FindMailAliasId(criteria *Criteria, options *Options) (int64, e if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.alias was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_alias_mixin.go b/mail_alias_mixin.go index d6e056fa..a0b687cb 100644 --- a/mail_alias_mixin.go +++ b/mail_alias_mixin.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailAliasMixin represents mail.alias.mixin model. type MailAliasMixin struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -54,7 +50,7 @@ func (c *Client) CreateMailAliasMixins(mams []*MailAliasMixin) ([]int64, error) for _, v := range mams { vv = append(vv, v) } - return c.Create(MailAliasMixinModel, vv) + return c.Create(MailAliasMixinModel, vv, nil) } // UpdateMailAliasMixin updates an existing mail.alias.mixin record. @@ -65,7 +61,7 @@ func (c *Client) UpdateMailAliasMixin(mam *MailAliasMixin) error { // UpdateMailAliasMixins updates existing mail.alias.mixin records. // All records (represented by ids) will be updated by mam values. func (c *Client) UpdateMailAliasMixins(ids []int64, mam *MailAliasMixin) error { - return c.Update(MailAliasMixinModel, ids, mam) + return c.Update(MailAliasMixinModel, ids, mam, nil) } // DeleteMailAliasMixin deletes an existing mail.alias.mixin record. @@ -84,10 +80,7 @@ func (c *Client) GetMailAliasMixin(id int64) (*MailAliasMixin, error) { if err != nil { return nil, err } - if mams != nil && len(*mams) > 0 { - return &((*mams)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.alias.mixin not found", id) + return &((*mams)[0]), nil } // GetMailAliasMixins gets mail.alias.mixin existing records. @@ -105,10 +98,7 @@ func (c *Client) FindMailAliasMixin(criteria *Criteria) (*MailAliasMixin, error) if err := c.SearchRead(MailAliasMixinModel, criteria, NewOptions().Limit(1), mams); err != nil { return nil, err } - if mams != nil && len(*mams) > 0 { - return &((*mams)[0]), nil - } - return nil, fmt.Errorf("mail.alias.mixin was not found with criteria %v", criteria) + return &((*mams)[0]), nil } // FindMailAliasMixins finds mail.alias.mixin records by querying it @@ -124,11 +114,7 @@ func (c *Client) FindMailAliasMixins(criteria *Criteria, options *Options) (*Mai // FindMailAliasMixinIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailAliasMixinIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailAliasMixinModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailAliasMixinModel, criteria, options) } // FindMailAliasMixinId finds record id by querying it with criteria. @@ -137,8 +123,5 @@ func (c *Client) FindMailAliasMixinId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.alias.mixin was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_channel.go b/mail_channel.go index 3c1a2f7f..de8d74f1 100644 --- a/mail_channel.go +++ b/mail_channel.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailChannel represents mail.channel model. type MailChannel struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -88,7 +84,7 @@ func (c *Client) CreateMailChannels(mcs []*MailChannel) ([]int64, error) { for _, v := range mcs { vv = append(vv, v) } - return c.Create(MailChannelModel, vv) + return c.Create(MailChannelModel, vv, nil) } // UpdateMailChannel updates an existing mail.channel record. @@ -99,7 +95,7 @@ func (c *Client) UpdateMailChannel(mc *MailChannel) error { // UpdateMailChannels updates existing mail.channel records. // All records (represented by ids) will be updated by mc values. func (c *Client) UpdateMailChannels(ids []int64, mc *MailChannel) error { - return c.Update(MailChannelModel, ids, mc) + return c.Update(MailChannelModel, ids, mc, nil) } // DeleteMailChannel deletes an existing mail.channel record. @@ -118,10 +114,7 @@ func (c *Client) GetMailChannel(id int64) (*MailChannel, error) { if err != nil { return nil, err } - if mcs != nil && len(*mcs) > 0 { - return &((*mcs)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.channel not found", id) + return &((*mcs)[0]), nil } // GetMailChannels gets mail.channel existing records. @@ -139,10 +132,7 @@ func (c *Client) FindMailChannel(criteria *Criteria) (*MailChannel, error) { if err := c.SearchRead(MailChannelModel, criteria, NewOptions().Limit(1), mcs); err != nil { return nil, err } - if mcs != nil && len(*mcs) > 0 { - return &((*mcs)[0]), nil - } - return nil, fmt.Errorf("mail.channel was not found with criteria %v", criteria) + return &((*mcs)[0]), nil } // FindMailChannels finds mail.channel records by querying it @@ -158,11 +148,7 @@ func (c *Client) FindMailChannels(criteria *Criteria, options *Options) (*MailCh // FindMailChannelIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailChannelIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailChannelModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailChannelModel, criteria, options) } // FindMailChannelId finds record id by querying it with criteria. @@ -171,8 +157,5 @@ func (c *Client) FindMailChannelId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.channel was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_channel_partner.go b/mail_channel_partner.go index 798f72f4..7225c2c9 100644 --- a/mail_channel_partner.go +++ b/mail_channel_partner.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailChannelPartner represents mail.channel.partner model. type MailChannelPartner struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -51,7 +47,7 @@ func (c *Client) CreateMailChannelPartners(mcps []*MailChannelPartner) ([]int64, for _, v := range mcps { vv = append(vv, v) } - return c.Create(MailChannelPartnerModel, vv) + return c.Create(MailChannelPartnerModel, vv, nil) } // UpdateMailChannelPartner updates an existing mail.channel.partner record. @@ -62,7 +58,7 @@ func (c *Client) UpdateMailChannelPartner(mcp *MailChannelPartner) error { // UpdateMailChannelPartners updates existing mail.channel.partner records. // All records (represented by ids) will be updated by mcp values. func (c *Client) UpdateMailChannelPartners(ids []int64, mcp *MailChannelPartner) error { - return c.Update(MailChannelPartnerModel, ids, mcp) + return c.Update(MailChannelPartnerModel, ids, mcp, nil) } // DeleteMailChannelPartner deletes an existing mail.channel.partner record. @@ -81,10 +77,7 @@ func (c *Client) GetMailChannelPartner(id int64) (*MailChannelPartner, error) { if err != nil { return nil, err } - if mcps != nil && len(*mcps) > 0 { - return &((*mcps)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.channel.partner not found", id) + return &((*mcps)[0]), nil } // GetMailChannelPartners gets mail.channel.partner existing records. @@ -102,10 +95,7 @@ func (c *Client) FindMailChannelPartner(criteria *Criteria) (*MailChannelPartner if err := c.SearchRead(MailChannelPartnerModel, criteria, NewOptions().Limit(1), mcps); err != nil { return nil, err } - if mcps != nil && len(*mcps) > 0 { - return &((*mcps)[0]), nil - } - return nil, fmt.Errorf("mail.channel.partner was not found with criteria %v", criteria) + return &((*mcps)[0]), nil } // FindMailChannelPartners finds mail.channel.partner records by querying it @@ -121,11 +111,7 @@ func (c *Client) FindMailChannelPartners(criteria *Criteria, options *Options) ( // FindMailChannelPartnerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailChannelPartnerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailChannelPartnerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailChannelPartnerModel, criteria, options) } // FindMailChannelPartnerId finds record id by querying it with criteria. @@ -134,8 +120,5 @@ func (c *Client) FindMailChannelPartnerId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.channel.partner was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_compose_message.go b/mail_compose_message.go index 47eb51b9..1fcc587d 100644 --- a/mail_compose_message.go +++ b/mail_compose_message.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailComposeMessage represents mail.compose.message model. type MailComposeMessage struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -85,7 +81,7 @@ func (c *Client) CreateMailComposeMessages(mcms []*MailComposeMessage) ([]int64, for _, v := range mcms { vv = append(vv, v) } - return c.Create(MailComposeMessageModel, vv) + return c.Create(MailComposeMessageModel, vv, nil) } // UpdateMailComposeMessage updates an existing mail.compose.message record. @@ -96,7 +92,7 @@ func (c *Client) UpdateMailComposeMessage(mcm *MailComposeMessage) error { // UpdateMailComposeMessages updates existing mail.compose.message records. // All records (represented by ids) will be updated by mcm values. func (c *Client) UpdateMailComposeMessages(ids []int64, mcm *MailComposeMessage) error { - return c.Update(MailComposeMessageModel, ids, mcm) + return c.Update(MailComposeMessageModel, ids, mcm, nil) } // DeleteMailComposeMessage deletes an existing mail.compose.message record. @@ -115,10 +111,7 @@ func (c *Client) GetMailComposeMessage(id int64) (*MailComposeMessage, error) { if err != nil { return nil, err } - if mcms != nil && len(*mcms) > 0 { - return &((*mcms)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.compose.message not found", id) + return &((*mcms)[0]), nil } // GetMailComposeMessages gets mail.compose.message existing records. @@ -136,10 +129,7 @@ func (c *Client) FindMailComposeMessage(criteria *Criteria) (*MailComposeMessage if err := c.SearchRead(MailComposeMessageModel, criteria, NewOptions().Limit(1), mcms); err != nil { return nil, err } - if mcms != nil && len(*mcms) > 0 { - return &((*mcms)[0]), nil - } - return nil, fmt.Errorf("mail.compose.message was not found with criteria %v", criteria) + return &((*mcms)[0]), nil } // FindMailComposeMessages finds mail.compose.message records by querying it @@ -155,11 +145,7 @@ func (c *Client) FindMailComposeMessages(criteria *Criteria, options *Options) ( // FindMailComposeMessageIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailComposeMessageIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailComposeMessageModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailComposeMessageModel, criteria, options) } // FindMailComposeMessageId finds record id by querying it with criteria. @@ -168,8 +154,5 @@ func (c *Client) FindMailComposeMessageId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.compose.message was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_followers.go b/mail_followers.go index e21f54a5..c3c2a186 100644 --- a/mail_followers.go +++ b/mail_followers.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailFollowers represents mail.followers model. type MailFollowers struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateMailFollowerss(mfs []*MailFollowers) ([]int64, error) { for _, v := range mfs { vv = append(vv, v) } - return c.Create(MailFollowersModel, vv) + return c.Create(MailFollowersModel, vv, nil) } // UpdateMailFollowers updates an existing mail.followers record. @@ -56,7 +52,7 @@ func (c *Client) UpdateMailFollowers(mf *MailFollowers) error { // UpdateMailFollowerss updates existing mail.followers records. // All records (represented by ids) will be updated by mf values. func (c *Client) UpdateMailFollowerss(ids []int64, mf *MailFollowers) error { - return c.Update(MailFollowersModel, ids, mf) + return c.Update(MailFollowersModel, ids, mf, nil) } // DeleteMailFollowers deletes an existing mail.followers record. @@ -75,10 +71,7 @@ func (c *Client) GetMailFollowers(id int64) (*MailFollowers, error) { if err != nil { return nil, err } - if mfs != nil && len(*mfs) > 0 { - return &((*mfs)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.followers not found", id) + return &((*mfs)[0]), nil } // GetMailFollowerss gets mail.followers existing records. @@ -96,10 +89,7 @@ func (c *Client) FindMailFollowers(criteria *Criteria) (*MailFollowers, error) { if err := c.SearchRead(MailFollowersModel, criteria, NewOptions().Limit(1), mfs); err != nil { return nil, err } - if mfs != nil && len(*mfs) > 0 { - return &((*mfs)[0]), nil - } - return nil, fmt.Errorf("mail.followers was not found with criteria %v", criteria) + return &((*mfs)[0]), nil } // FindMailFollowerss finds mail.followers records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindMailFollowerss(criteria *Criteria, options *Options) (*Mail // FindMailFollowersIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailFollowersIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailFollowersModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailFollowersModel, criteria, options) } // FindMailFollowersId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindMailFollowersId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.followers was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_mail.go b/mail_mail.go index 37c1b817..0c915431 100644 --- a/mail_mail.go +++ b/mail_mail.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailMail represents mail.mail model. type MailMail struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -88,7 +84,7 @@ func (c *Client) CreateMailMails(mms []*MailMail) ([]int64, error) { for _, v := range mms { vv = append(vv, v) } - return c.Create(MailMailModel, vv) + return c.Create(MailMailModel, vv, nil) } // UpdateMailMail updates an existing mail.mail record. @@ -99,7 +95,7 @@ func (c *Client) UpdateMailMail(mm *MailMail) error { // UpdateMailMails updates existing mail.mail records. // All records (represented by ids) will be updated by mm values. func (c *Client) UpdateMailMails(ids []int64, mm *MailMail) error { - return c.Update(MailMailModel, ids, mm) + return c.Update(MailMailModel, ids, mm, nil) } // DeleteMailMail deletes an existing mail.mail record. @@ -118,10 +114,7 @@ func (c *Client) GetMailMail(id int64) (*MailMail, error) { if err != nil { return nil, err } - if mms != nil && len(*mms) > 0 { - return &((*mms)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.mail not found", id) + return &((*mms)[0]), nil } // GetMailMails gets mail.mail existing records. @@ -139,10 +132,7 @@ func (c *Client) FindMailMail(criteria *Criteria) (*MailMail, error) { if err := c.SearchRead(MailMailModel, criteria, NewOptions().Limit(1), mms); err != nil { return nil, err } - if mms != nil && len(*mms) > 0 { - return &((*mms)[0]), nil - } - return nil, fmt.Errorf("mail.mail was not found with criteria %v", criteria) + return &((*mms)[0]), nil } // FindMailMails finds mail.mail records by querying it @@ -158,11 +148,7 @@ func (c *Client) FindMailMails(criteria *Criteria, options *Options) (*MailMails // FindMailMailIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailMailIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailMailModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailMailModel, criteria, options) } // FindMailMailId finds record id by querying it with criteria. @@ -171,8 +157,5 @@ func (c *Client) FindMailMailId(criteria *Criteria, options *Options) (int64, er if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.mail was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_mail_statistics.go b/mail_mail_statistics.go index dba4f371..b50ceb04 100644 --- a/mail_mail_statistics.go +++ b/mail_mail_statistics.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailMailStatistics represents mail.mail.statistics model. type MailMailStatistics struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -62,7 +58,7 @@ func (c *Client) CreateMailMailStatisticss(mmss []*MailMailStatistics) ([]int64, for _, v := range mmss { vv = append(vv, v) } - return c.Create(MailMailStatisticsModel, vv) + return c.Create(MailMailStatisticsModel, vv, nil) } // UpdateMailMailStatistics updates an existing mail.mail.statistics record. @@ -73,7 +69,7 @@ func (c *Client) UpdateMailMailStatistics(mms *MailMailStatistics) error { // UpdateMailMailStatisticss updates existing mail.mail.statistics records. // All records (represented by ids) will be updated by mms values. func (c *Client) UpdateMailMailStatisticss(ids []int64, mms *MailMailStatistics) error { - return c.Update(MailMailStatisticsModel, ids, mms) + return c.Update(MailMailStatisticsModel, ids, mms, nil) } // DeleteMailMailStatistics deletes an existing mail.mail.statistics record. @@ -92,10 +88,7 @@ func (c *Client) GetMailMailStatistics(id int64) (*MailMailStatistics, error) { if err != nil { return nil, err } - if mmss != nil && len(*mmss) > 0 { - return &((*mmss)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.mail.statistics not found", id) + return &((*mmss)[0]), nil } // GetMailMailStatisticss gets mail.mail.statistics existing records. @@ -113,10 +106,7 @@ func (c *Client) FindMailMailStatistics(criteria *Criteria) (*MailMailStatistics if err := c.SearchRead(MailMailStatisticsModel, criteria, NewOptions().Limit(1), mmss); err != nil { return nil, err } - if mmss != nil && len(*mmss) > 0 { - return &((*mmss)[0]), nil - } - return nil, fmt.Errorf("mail.mail.statistics was not found with criteria %v", criteria) + return &((*mmss)[0]), nil } // FindMailMailStatisticss finds mail.mail.statistics records by querying it @@ -132,11 +122,7 @@ func (c *Client) FindMailMailStatisticss(criteria *Criteria, options *Options) ( // FindMailMailStatisticsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailMailStatisticsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailMailStatisticsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailMailStatisticsModel, criteria, options) } // FindMailMailStatisticsId finds record id by querying it with criteria. @@ -145,8 +131,5 @@ func (c *Client) FindMailMailStatisticsId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.mail.statistics was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_mass_mailing.go b/mail_mass_mailing.go index 9a86819b..8456de1f 100644 --- a/mail_mass_mailing.go +++ b/mail_mass_mailing.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailMassMailing represents mail.mass_mailing model. type MailMassMailing struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -81,7 +77,7 @@ func (c *Client) CreateMailMassMailings(mms []*MailMassMailing) ([]int64, error) for _, v := range mms { vv = append(vv, v) } - return c.Create(MailMassMailingModel, vv) + return c.Create(MailMassMailingModel, vv, nil) } // UpdateMailMassMailing updates an existing mail.mass_mailing record. @@ -92,7 +88,7 @@ func (c *Client) UpdateMailMassMailing(mm *MailMassMailing) error { // UpdateMailMassMailings updates existing mail.mass_mailing records. // All records (represented by ids) will be updated by mm values. func (c *Client) UpdateMailMassMailings(ids []int64, mm *MailMassMailing) error { - return c.Update(MailMassMailingModel, ids, mm) + return c.Update(MailMassMailingModel, ids, mm, nil) } // DeleteMailMassMailing deletes an existing mail.mass_mailing record. @@ -111,10 +107,7 @@ func (c *Client) GetMailMassMailing(id int64) (*MailMassMailing, error) { if err != nil { return nil, err } - if mms != nil && len(*mms) > 0 { - return &((*mms)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.mass_mailing not found", id) + return &((*mms)[0]), nil } // GetMailMassMailings gets mail.mass_mailing existing records. @@ -132,10 +125,7 @@ func (c *Client) FindMailMassMailing(criteria *Criteria) (*MailMassMailing, erro if err := c.SearchRead(MailMassMailingModel, criteria, NewOptions().Limit(1), mms); err != nil { return nil, err } - if mms != nil && len(*mms) > 0 { - return &((*mms)[0]), nil - } - return nil, fmt.Errorf("mail.mass_mailing was not found with criteria %v", criteria) + return &((*mms)[0]), nil } // FindMailMassMailings finds mail.mass_mailing records by querying it @@ -151,11 +141,7 @@ func (c *Client) FindMailMassMailings(criteria *Criteria, options *Options) (*Ma // FindMailMassMailingIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailMassMailingIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailMassMailingModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailMassMailingModel, criteria, options) } // FindMailMassMailingId finds record id by querying it with criteria. @@ -164,8 +150,5 @@ func (c *Client) FindMailMassMailingId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.mass_mailing was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_mass_mailing_campaign.go b/mail_mass_mailing_campaign.go index dad9224f..dc1660d5 100644 --- a/mail_mass_mailing_campaign.go +++ b/mail_mass_mailing_campaign.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailMassMailingCampaign represents mail.mass_mailing.campaign model. type MailMassMailingCampaign struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -68,7 +64,7 @@ func (c *Client) CreateMailMassMailingCampaigns(mmcs []*MailMassMailingCampaign) for _, v := range mmcs { vv = append(vv, v) } - return c.Create(MailMassMailingCampaignModel, vv) + return c.Create(MailMassMailingCampaignModel, vv, nil) } // UpdateMailMassMailingCampaign updates an existing mail.mass_mailing.campaign record. @@ -79,7 +75,7 @@ func (c *Client) UpdateMailMassMailingCampaign(mmc *MailMassMailingCampaign) err // UpdateMailMassMailingCampaigns updates existing mail.mass_mailing.campaign records. // All records (represented by ids) will be updated by mmc values. func (c *Client) UpdateMailMassMailingCampaigns(ids []int64, mmc *MailMassMailingCampaign) error { - return c.Update(MailMassMailingCampaignModel, ids, mmc) + return c.Update(MailMassMailingCampaignModel, ids, mmc, nil) } // DeleteMailMassMailingCampaign deletes an existing mail.mass_mailing.campaign record. @@ -98,10 +94,7 @@ func (c *Client) GetMailMassMailingCampaign(id int64) (*MailMassMailingCampaign, if err != nil { return nil, err } - if mmcs != nil && len(*mmcs) > 0 { - return &((*mmcs)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.mass_mailing.campaign not found", id) + return &((*mmcs)[0]), nil } // GetMailMassMailingCampaigns gets mail.mass_mailing.campaign existing records. @@ -119,10 +112,7 @@ func (c *Client) FindMailMassMailingCampaign(criteria *Criteria) (*MailMassMaili if err := c.SearchRead(MailMassMailingCampaignModel, criteria, NewOptions().Limit(1), mmcs); err != nil { return nil, err } - if mmcs != nil && len(*mmcs) > 0 { - return &((*mmcs)[0]), nil - } - return nil, fmt.Errorf("mail.mass_mailing.campaign was not found with criteria %v", criteria) + return &((*mmcs)[0]), nil } // FindMailMassMailingCampaigns finds mail.mass_mailing.campaign records by querying it @@ -138,11 +128,7 @@ func (c *Client) FindMailMassMailingCampaigns(criteria *Criteria, options *Optio // FindMailMassMailingCampaignIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailMassMailingCampaignIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailMassMailingCampaignModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailMassMailingCampaignModel, criteria, options) } // FindMailMassMailingCampaignId finds record id by querying it with criteria. @@ -151,8 +137,5 @@ func (c *Client) FindMailMassMailingCampaignId(criteria *Criteria, options *Opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.mass_mailing.campaign was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_mass_mailing_contact.go b/mail_mass_mailing_contact.go index 200a72fd..b982d500 100644 --- a/mail_mass_mailing_contact.go +++ b/mail_mass_mailing_contact.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailMassMailingContact represents mail.mass_mailing.contact model. type MailMassMailingContact struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -65,7 +61,7 @@ func (c *Client) CreateMailMassMailingContacts(mmcs []*MailMassMailingContact) ( for _, v := range mmcs { vv = append(vv, v) } - return c.Create(MailMassMailingContactModel, vv) + return c.Create(MailMassMailingContactModel, vv, nil) } // UpdateMailMassMailingContact updates an existing mail.mass_mailing.contact record. @@ -76,7 +72,7 @@ func (c *Client) UpdateMailMassMailingContact(mmc *MailMassMailingContact) error // UpdateMailMassMailingContacts updates existing mail.mass_mailing.contact records. // All records (represented by ids) will be updated by mmc values. func (c *Client) UpdateMailMassMailingContacts(ids []int64, mmc *MailMassMailingContact) error { - return c.Update(MailMassMailingContactModel, ids, mmc) + return c.Update(MailMassMailingContactModel, ids, mmc, nil) } // DeleteMailMassMailingContact deletes an existing mail.mass_mailing.contact record. @@ -95,10 +91,7 @@ func (c *Client) GetMailMassMailingContact(id int64) (*MailMassMailingContact, e if err != nil { return nil, err } - if mmcs != nil && len(*mmcs) > 0 { - return &((*mmcs)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.mass_mailing.contact not found", id) + return &((*mmcs)[0]), nil } // GetMailMassMailingContacts gets mail.mass_mailing.contact existing records. @@ -116,10 +109,7 @@ func (c *Client) FindMailMassMailingContact(criteria *Criteria) (*MailMassMailin if err := c.SearchRead(MailMassMailingContactModel, criteria, NewOptions().Limit(1), mmcs); err != nil { return nil, err } - if mmcs != nil && len(*mmcs) > 0 { - return &((*mmcs)[0]), nil - } - return nil, fmt.Errorf("mail.mass_mailing.contact was not found with criteria %v", criteria) + return &((*mmcs)[0]), nil } // FindMailMassMailingContacts finds mail.mass_mailing.contact records by querying it @@ -135,11 +125,7 @@ func (c *Client) FindMailMassMailingContacts(criteria *Criteria, options *Option // FindMailMassMailingContactIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailMassMailingContactIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailMassMailingContactModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailMassMailingContactModel, criteria, options) } // FindMailMassMailingContactId finds record id by querying it with criteria. @@ -148,8 +134,5 @@ func (c *Client) FindMailMassMailingContactId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.mass_mailing.contact was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_mass_mailing_list.go b/mail_mass_mailing_list.go index 927d1894..8ffb6871 100644 --- a/mail_mass_mailing_list.go +++ b/mail_mass_mailing_list.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailMassMailingList represents mail.mass_mailing.list model. type MailMassMailingList struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateMailMassMailingLists(mmls []*MailMassMailingList) ([]int6 for _, v := range mmls { vv = append(vv, v) } - return c.Create(MailMassMailingListModel, vv) + return c.Create(MailMassMailingListModel, vv, nil) } // UpdateMailMassMailingList updates an existing mail.mass_mailing.list record. @@ -58,7 +54,7 @@ func (c *Client) UpdateMailMassMailingList(mml *MailMassMailingList) error { // UpdateMailMassMailingLists updates existing mail.mass_mailing.list records. // All records (represented by ids) will be updated by mml values. func (c *Client) UpdateMailMassMailingLists(ids []int64, mml *MailMassMailingList) error { - return c.Update(MailMassMailingListModel, ids, mml) + return c.Update(MailMassMailingListModel, ids, mml, nil) } // DeleteMailMassMailingList deletes an existing mail.mass_mailing.list record. @@ -77,10 +73,7 @@ func (c *Client) GetMailMassMailingList(id int64) (*MailMassMailingList, error) if err != nil { return nil, err } - if mmls != nil && len(*mmls) > 0 { - return &((*mmls)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.mass_mailing.list not found", id) + return &((*mmls)[0]), nil } // GetMailMassMailingLists gets mail.mass_mailing.list existing records. @@ -98,10 +91,7 @@ func (c *Client) FindMailMassMailingList(criteria *Criteria) (*MailMassMailingLi if err := c.SearchRead(MailMassMailingListModel, criteria, NewOptions().Limit(1), mmls); err != nil { return nil, err } - if mmls != nil && len(*mmls) > 0 { - return &((*mmls)[0]), nil - } - return nil, fmt.Errorf("mail.mass_mailing.list was not found with criteria %v", criteria) + return &((*mmls)[0]), nil } // FindMailMassMailingLists finds mail.mass_mailing.list records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindMailMassMailingLists(criteria *Criteria, options *Options) // FindMailMassMailingListIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailMassMailingListIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailMassMailingListModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailMassMailingListModel, criteria, options) } // FindMailMassMailingListId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindMailMassMailingListId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.mass_mailing.list was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_mass_mailing_stage.go b/mail_mass_mailing_stage.go index 8475640c..1720c921 100644 --- a/mail_mass_mailing_stage.go +++ b/mail_mass_mailing_stage.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailMassMailingStage represents mail.mass_mailing.stage model. type MailMassMailingStage struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateMailMassMailingStages(mmss []*MailMassMailingStage) ([]in for _, v := range mmss { vv = append(vv, v) } - return c.Create(MailMassMailingStageModel, vv) + return c.Create(MailMassMailingStageModel, vv, nil) } // UpdateMailMassMailingStage updates an existing mail.mass_mailing.stage record. @@ -57,7 +53,7 @@ func (c *Client) UpdateMailMassMailingStage(mms *MailMassMailingStage) error { // UpdateMailMassMailingStages updates existing mail.mass_mailing.stage records. // All records (represented by ids) will be updated by mms values. func (c *Client) UpdateMailMassMailingStages(ids []int64, mms *MailMassMailingStage) error { - return c.Update(MailMassMailingStageModel, ids, mms) + return c.Update(MailMassMailingStageModel, ids, mms, nil) } // DeleteMailMassMailingStage deletes an existing mail.mass_mailing.stage record. @@ -76,10 +72,7 @@ func (c *Client) GetMailMassMailingStage(id int64) (*MailMassMailingStage, error if err != nil { return nil, err } - if mmss != nil && len(*mmss) > 0 { - return &((*mmss)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.mass_mailing.stage not found", id) + return &((*mmss)[0]), nil } // GetMailMassMailingStages gets mail.mass_mailing.stage existing records. @@ -97,10 +90,7 @@ func (c *Client) FindMailMassMailingStage(criteria *Criteria) (*MailMassMailingS if err := c.SearchRead(MailMassMailingStageModel, criteria, NewOptions().Limit(1), mmss); err != nil { return nil, err } - if mmss != nil && len(*mmss) > 0 { - return &((*mmss)[0]), nil - } - return nil, fmt.Errorf("mail.mass_mailing.stage was not found with criteria %v", criteria) + return &((*mmss)[0]), nil } // FindMailMassMailingStages finds mail.mass_mailing.stage records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindMailMassMailingStages(criteria *Criteria, options *Options) // FindMailMassMailingStageIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailMassMailingStageIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailMassMailingStageModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailMassMailingStageModel, criteria, options) } // FindMailMassMailingStageId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindMailMassMailingStageId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.mass_mailing.stage was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_mass_mailing_tag.go b/mail_mass_mailing_tag.go index 752151ec..622af322 100644 --- a/mail_mass_mailing_tag.go +++ b/mail_mass_mailing_tag.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailMassMailingTag represents mail.mass_mailing.tag model. type MailMassMailingTag struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateMailMassMailingTags(mmts []*MailMassMailingTag) ([]int64, for _, v := range mmts { vv = append(vv, v) } - return c.Create(MailMassMailingTagModel, vv) + return c.Create(MailMassMailingTagModel, vv, nil) } // UpdateMailMassMailingTag updates an existing mail.mass_mailing.tag record. @@ -57,7 +53,7 @@ func (c *Client) UpdateMailMassMailingTag(mmt *MailMassMailingTag) error { // UpdateMailMassMailingTags updates existing mail.mass_mailing.tag records. // All records (represented by ids) will be updated by mmt values. func (c *Client) UpdateMailMassMailingTags(ids []int64, mmt *MailMassMailingTag) error { - return c.Update(MailMassMailingTagModel, ids, mmt) + return c.Update(MailMassMailingTagModel, ids, mmt, nil) } // DeleteMailMassMailingTag deletes an existing mail.mass_mailing.tag record. @@ -76,10 +72,7 @@ func (c *Client) GetMailMassMailingTag(id int64) (*MailMassMailingTag, error) { if err != nil { return nil, err } - if mmts != nil && len(*mmts) > 0 { - return &((*mmts)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.mass_mailing.tag not found", id) + return &((*mmts)[0]), nil } // GetMailMassMailingTags gets mail.mass_mailing.tag existing records. @@ -97,10 +90,7 @@ func (c *Client) FindMailMassMailingTag(criteria *Criteria) (*MailMassMailingTag if err := c.SearchRead(MailMassMailingTagModel, criteria, NewOptions().Limit(1), mmts); err != nil { return nil, err } - if mmts != nil && len(*mmts) > 0 { - return &((*mmts)[0]), nil - } - return nil, fmt.Errorf("mail.mass_mailing.tag was not found with criteria %v", criteria) + return &((*mmts)[0]), nil } // FindMailMassMailingTags finds mail.mass_mailing.tag records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindMailMassMailingTags(criteria *Criteria, options *Options) ( // FindMailMassMailingTagIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailMassMailingTagIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailMassMailingTagModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailMassMailingTagModel, criteria, options) } // FindMailMassMailingTagId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindMailMassMailingTagId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.mass_mailing.tag was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_mass_mailing_test.go b/mail_mass_mailing_test.go index 17904ce0..ce82a49b 100644 --- a/mail_mass_mailing_test.go +++ b/mail_mass_mailing_test.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailMassMailingTest represents mail.mass_mailing.test model. type MailMassMailingTest struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateMailMassMailingTests(mmts []*MailMassMailingTest) ([]int6 for _, v := range mmts { vv = append(vv, v) } - return c.Create(MailMassMailingTestModel, vv) + return c.Create(MailMassMailingTestModel, vv, nil) } // UpdateMailMassMailingTest updates an existing mail.mass_mailing.test record. @@ -57,7 +53,7 @@ func (c *Client) UpdateMailMassMailingTest(mmt *MailMassMailingTest) error { // UpdateMailMassMailingTests updates existing mail.mass_mailing.test records. // All records (represented by ids) will be updated by mmt values. func (c *Client) UpdateMailMassMailingTests(ids []int64, mmt *MailMassMailingTest) error { - return c.Update(MailMassMailingTestModel, ids, mmt) + return c.Update(MailMassMailingTestModel, ids, mmt, nil) } // DeleteMailMassMailingTest deletes an existing mail.mass_mailing.test record. @@ -76,10 +72,7 @@ func (c *Client) GetMailMassMailingTest(id int64) (*MailMassMailingTest, error) if err != nil { return nil, err } - if mmts != nil && len(*mmts) > 0 { - return &((*mmts)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.mass_mailing.test not found", id) + return &((*mmts)[0]), nil } // GetMailMassMailingTests gets mail.mass_mailing.test existing records. @@ -97,10 +90,7 @@ func (c *Client) FindMailMassMailingTest(criteria *Criteria) (*MailMassMailingTe if err := c.SearchRead(MailMassMailingTestModel, criteria, NewOptions().Limit(1), mmts); err != nil { return nil, err } - if mmts != nil && len(*mmts) > 0 { - return &((*mmts)[0]), nil - } - return nil, fmt.Errorf("mail.mass_mailing.test was not found with criteria %v", criteria) + return &((*mmts)[0]), nil } // FindMailMassMailingTests finds mail.mass_mailing.test records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindMailMassMailingTests(criteria *Criteria, options *Options) // FindMailMassMailingTestIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailMassMailingTestIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailMassMailingTestModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailMassMailingTestModel, criteria, options) } // FindMailMassMailingTestId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindMailMassMailingTestId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.mass_mailing.test was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_message.go b/mail_message.go index 1bd22029..5de38dbf 100644 --- a/mail_message.go +++ b/mail_message.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailMessage represents mail.message model. type MailMessage struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -73,7 +69,7 @@ func (c *Client) CreateMailMessages(mms []*MailMessage) ([]int64, error) { for _, v := range mms { vv = append(vv, v) } - return c.Create(MailMessageModel, vv) + return c.Create(MailMessageModel, vv, nil) } // UpdateMailMessage updates an existing mail.message record. @@ -84,7 +80,7 @@ func (c *Client) UpdateMailMessage(mm *MailMessage) error { // UpdateMailMessages updates existing mail.message records. // All records (represented by ids) will be updated by mm values. func (c *Client) UpdateMailMessages(ids []int64, mm *MailMessage) error { - return c.Update(MailMessageModel, ids, mm) + return c.Update(MailMessageModel, ids, mm, nil) } // DeleteMailMessage deletes an existing mail.message record. @@ -103,10 +99,7 @@ func (c *Client) GetMailMessage(id int64) (*MailMessage, error) { if err != nil { return nil, err } - if mms != nil && len(*mms) > 0 { - return &((*mms)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.message not found", id) + return &((*mms)[0]), nil } // GetMailMessages gets mail.message existing records. @@ -124,10 +117,7 @@ func (c *Client) FindMailMessage(criteria *Criteria) (*MailMessage, error) { if err := c.SearchRead(MailMessageModel, criteria, NewOptions().Limit(1), mms); err != nil { return nil, err } - if mms != nil && len(*mms) > 0 { - return &((*mms)[0]), nil - } - return nil, fmt.Errorf("mail.message was not found with criteria %v", criteria) + return &((*mms)[0]), nil } // FindMailMessages finds mail.message records by querying it @@ -143,11 +133,7 @@ func (c *Client) FindMailMessages(criteria *Criteria, options *Options) (*MailMe // FindMailMessageIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailMessageIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailMessageModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailMessageModel, criteria, options) } // FindMailMessageId finds record id by querying it with criteria. @@ -156,8 +142,5 @@ func (c *Client) FindMailMessageId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.message was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_message_subtype.go b/mail_message_subtype.go index e374d31a..e4c202d7 100644 --- a/mail_message_subtype.go +++ b/mail_message_subtype.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailMessageSubtype represents mail.message.subtype model. type MailMessageSubtype struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -53,7 +49,7 @@ func (c *Client) CreateMailMessageSubtypes(mmss []*MailMessageSubtype) ([]int64, for _, v := range mmss { vv = append(vv, v) } - return c.Create(MailMessageSubtypeModel, vv) + return c.Create(MailMessageSubtypeModel, vv, nil) } // UpdateMailMessageSubtype updates an existing mail.message.subtype record. @@ -64,7 +60,7 @@ func (c *Client) UpdateMailMessageSubtype(mms *MailMessageSubtype) error { // UpdateMailMessageSubtypes updates existing mail.message.subtype records. // All records (represented by ids) will be updated by mms values. func (c *Client) UpdateMailMessageSubtypes(ids []int64, mms *MailMessageSubtype) error { - return c.Update(MailMessageSubtypeModel, ids, mms) + return c.Update(MailMessageSubtypeModel, ids, mms, nil) } // DeleteMailMessageSubtype deletes an existing mail.message.subtype record. @@ -83,10 +79,7 @@ func (c *Client) GetMailMessageSubtype(id int64) (*MailMessageSubtype, error) { if err != nil { return nil, err } - if mmss != nil && len(*mmss) > 0 { - return &((*mmss)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.message.subtype not found", id) + return &((*mmss)[0]), nil } // GetMailMessageSubtypes gets mail.message.subtype existing records. @@ -104,10 +97,7 @@ func (c *Client) FindMailMessageSubtype(criteria *Criteria) (*MailMessageSubtype if err := c.SearchRead(MailMessageSubtypeModel, criteria, NewOptions().Limit(1), mmss); err != nil { return nil, err } - if mmss != nil && len(*mmss) > 0 { - return &((*mmss)[0]), nil - } - return nil, fmt.Errorf("mail.message.subtype was not found with criteria %v", criteria) + return &((*mmss)[0]), nil } // FindMailMessageSubtypes finds mail.message.subtype records by querying it @@ -123,11 +113,7 @@ func (c *Client) FindMailMessageSubtypes(criteria *Criteria, options *Options) ( // FindMailMessageSubtypeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailMessageSubtypeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailMessageSubtypeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailMessageSubtypeModel, criteria, options) } // FindMailMessageSubtypeId finds record id by querying it with criteria. @@ -136,8 +122,5 @@ func (c *Client) FindMailMessageSubtypeId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.message.subtype was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_notification.go b/mail_notification.go index 999c3c2d..8c4024fa 100644 --- a/mail_notification.go +++ b/mail_notification.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailNotification represents mail.notification model. type MailNotification struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateMailNotifications(mns []*MailNotification) ([]int64, erro for _, v := range mns { vv = append(vv, v) } - return c.Create(MailNotificationModel, vv) + return c.Create(MailNotificationModel, vv, nil) } // UpdateMailNotification updates an existing mail.notification record. @@ -56,7 +52,7 @@ func (c *Client) UpdateMailNotification(mn *MailNotification) error { // UpdateMailNotifications updates existing mail.notification records. // All records (represented by ids) will be updated by mn values. func (c *Client) UpdateMailNotifications(ids []int64, mn *MailNotification) error { - return c.Update(MailNotificationModel, ids, mn) + return c.Update(MailNotificationModel, ids, mn, nil) } // DeleteMailNotification deletes an existing mail.notification record. @@ -75,10 +71,7 @@ func (c *Client) GetMailNotification(id int64) (*MailNotification, error) { if err != nil { return nil, err } - if mns != nil && len(*mns) > 0 { - return &((*mns)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.notification not found", id) + return &((*mns)[0]), nil } // GetMailNotifications gets mail.notification existing records. @@ -96,10 +89,7 @@ func (c *Client) FindMailNotification(criteria *Criteria) (*MailNotification, er if err := c.SearchRead(MailNotificationModel, criteria, NewOptions().Limit(1), mns); err != nil { return nil, err } - if mns != nil && len(*mns) > 0 { - return &((*mns)[0]), nil - } - return nil, fmt.Errorf("mail.notification was not found with criteria %v", criteria) + return &((*mns)[0]), nil } // FindMailNotifications finds mail.notification records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindMailNotifications(criteria *Criteria, options *Options) (*M // FindMailNotificationIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailNotificationIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailNotificationModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailNotificationModel, criteria, options) } // FindMailNotificationId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindMailNotificationId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.notification was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_shortcode.go b/mail_shortcode.go index 17786c19..9c66d02e 100644 --- a/mail_shortcode.go +++ b/mail_shortcode.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailShortcode represents mail.shortcode model. type MailShortcode struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateMailShortcodes(mss []*MailShortcode) ([]int64, error) { for _, v := range mss { vv = append(vv, v) } - return c.Create(MailShortcodeModel, vv) + return c.Create(MailShortcodeModel, vv, nil) } // UpdateMailShortcode updates an existing mail.shortcode record. @@ -60,7 +56,7 @@ func (c *Client) UpdateMailShortcode(ms *MailShortcode) error { // UpdateMailShortcodes updates existing mail.shortcode records. // All records (represented by ids) will be updated by ms values. func (c *Client) UpdateMailShortcodes(ids []int64, ms *MailShortcode) error { - return c.Update(MailShortcodeModel, ids, ms) + return c.Update(MailShortcodeModel, ids, ms, nil) } // DeleteMailShortcode deletes an existing mail.shortcode record. @@ -79,10 +75,7 @@ func (c *Client) GetMailShortcode(id int64) (*MailShortcode, error) { if err != nil { return nil, err } - if mss != nil && len(*mss) > 0 { - return &((*mss)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.shortcode not found", id) + return &((*mss)[0]), nil } // GetMailShortcodes gets mail.shortcode existing records. @@ -100,10 +93,7 @@ func (c *Client) FindMailShortcode(criteria *Criteria) (*MailShortcode, error) { if err := c.SearchRead(MailShortcodeModel, criteria, NewOptions().Limit(1), mss); err != nil { return nil, err } - if mss != nil && len(*mss) > 0 { - return &((*mss)[0]), nil - } - return nil, fmt.Errorf("mail.shortcode was not found with criteria %v", criteria) + return &((*mss)[0]), nil } // FindMailShortcodes finds mail.shortcode records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindMailShortcodes(criteria *Criteria, options *Options) (*Mail // FindMailShortcodeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailShortcodeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailShortcodeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailShortcodeModel, criteria, options) } // FindMailShortcodeId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindMailShortcodeId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.shortcode was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_statistics_report.go b/mail_statistics_report.go index b49cb375..8f1ac1b4 100644 --- a/mail_statistics_report.go +++ b/mail_statistics_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailStatisticsReport represents mail.statistics.report model. type MailStatisticsReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateMailStatisticsReports(msrs []*MailStatisticsReport) ([]in for _, v := range msrs { vv = append(vv, v) } - return c.Create(MailStatisticsReportModel, vv) + return c.Create(MailStatisticsReportModel, vv, nil) } // UpdateMailStatisticsReport updates an existing mail.statistics.report record. @@ -61,7 +57,7 @@ func (c *Client) UpdateMailStatisticsReport(msr *MailStatisticsReport) error { // UpdateMailStatisticsReports updates existing mail.statistics.report records. // All records (represented by ids) will be updated by msr values. func (c *Client) UpdateMailStatisticsReports(ids []int64, msr *MailStatisticsReport) error { - return c.Update(MailStatisticsReportModel, ids, msr) + return c.Update(MailStatisticsReportModel, ids, msr, nil) } // DeleteMailStatisticsReport deletes an existing mail.statistics.report record. @@ -80,10 +76,7 @@ func (c *Client) GetMailStatisticsReport(id int64) (*MailStatisticsReport, error if err != nil { return nil, err } - if msrs != nil && len(*msrs) > 0 { - return &((*msrs)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.statistics.report not found", id) + return &((*msrs)[0]), nil } // GetMailStatisticsReports gets mail.statistics.report existing records. @@ -101,10 +94,7 @@ func (c *Client) FindMailStatisticsReport(criteria *Criteria) (*MailStatisticsRe if err := c.SearchRead(MailStatisticsReportModel, criteria, NewOptions().Limit(1), msrs); err != nil { return nil, err } - if msrs != nil && len(*msrs) > 0 { - return &((*msrs)[0]), nil - } - return nil, fmt.Errorf("mail.statistics.report was not found with criteria %v", criteria) + return &((*msrs)[0]), nil } // FindMailStatisticsReports finds mail.statistics.report records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindMailStatisticsReports(criteria *Criteria, options *Options) // FindMailStatisticsReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailStatisticsReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailStatisticsReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailStatisticsReportModel, criteria, options) } // FindMailStatisticsReportId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindMailStatisticsReportId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.statistics.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_template.go b/mail_template.go index 00d7d7a1..0afb80c6 100644 --- a/mail_template.go +++ b/mail_template.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailTemplate represents mail.template model. type MailTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -69,7 +65,7 @@ func (c *Client) CreateMailTemplates(mts []*MailTemplate) ([]int64, error) { for _, v := range mts { vv = append(vv, v) } - return c.Create(MailTemplateModel, vv) + return c.Create(MailTemplateModel, vv, nil) } // UpdateMailTemplate updates an existing mail.template record. @@ -80,7 +76,7 @@ func (c *Client) UpdateMailTemplate(mt *MailTemplate) error { // UpdateMailTemplates updates existing mail.template records. // All records (represented by ids) will be updated by mt values. func (c *Client) UpdateMailTemplates(ids []int64, mt *MailTemplate) error { - return c.Update(MailTemplateModel, ids, mt) + return c.Update(MailTemplateModel, ids, mt, nil) } // DeleteMailTemplate deletes an existing mail.template record. @@ -99,10 +95,7 @@ func (c *Client) GetMailTemplate(id int64) (*MailTemplate, error) { if err != nil { return nil, err } - if mts != nil && len(*mts) > 0 { - return &((*mts)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.template not found", id) + return &((*mts)[0]), nil } // GetMailTemplates gets mail.template existing records. @@ -120,10 +113,7 @@ func (c *Client) FindMailTemplate(criteria *Criteria) (*MailTemplate, error) { if err := c.SearchRead(MailTemplateModel, criteria, NewOptions().Limit(1), mts); err != nil { return nil, err } - if mts != nil && len(*mts) > 0 { - return &((*mts)[0]), nil - } - return nil, fmt.Errorf("mail.template was not found with criteria %v", criteria) + return &((*mts)[0]), nil } // FindMailTemplates finds mail.template records by querying it @@ -139,11 +129,7 @@ func (c *Client) FindMailTemplates(criteria *Criteria, options *Options) (*MailT // FindMailTemplateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailTemplateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailTemplateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailTemplateModel, criteria, options) } // FindMailTemplateId finds record id by querying it with criteria. @@ -152,8 +138,5 @@ func (c *Client) FindMailTemplateId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.template was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_test.go b/mail_test.go index 0362793c..93f8967d 100644 --- a/mail_test.go +++ b/mail_test.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailTest represents mail.test model. type MailTest struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -67,7 +63,7 @@ func (c *Client) CreateMailTests(mts []*MailTest) ([]int64, error) { for _, v := range mts { vv = append(vv, v) } - return c.Create(MailTestModel, vv) + return c.Create(MailTestModel, vv, nil) } // UpdateMailTest updates an existing mail.test record. @@ -78,7 +74,7 @@ func (c *Client) UpdateMailTest(mt *MailTest) error { // UpdateMailTests updates existing mail.test records. // All records (represented by ids) will be updated by mt values. func (c *Client) UpdateMailTests(ids []int64, mt *MailTest) error { - return c.Update(MailTestModel, ids, mt) + return c.Update(MailTestModel, ids, mt, nil) } // DeleteMailTest deletes an existing mail.test record. @@ -97,10 +93,7 @@ func (c *Client) GetMailTest(id int64) (*MailTest, error) { if err != nil { return nil, err } - if mts != nil && len(*mts) > 0 { - return &((*mts)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.test not found", id) + return &((*mts)[0]), nil } // GetMailTests gets mail.test existing records. @@ -118,10 +111,7 @@ func (c *Client) FindMailTest(criteria *Criteria) (*MailTest, error) { if err := c.SearchRead(MailTestModel, criteria, NewOptions().Limit(1), mts); err != nil { return nil, err } - if mts != nil && len(*mts) > 0 { - return &((*mts)[0]), nil - } - return nil, fmt.Errorf("mail.test was not found with criteria %v", criteria) + return &((*mts)[0]), nil } // FindMailTests finds mail.test records by querying it @@ -137,11 +127,7 @@ func (c *Client) FindMailTests(criteria *Criteria, options *Options) (*MailTests // FindMailTestIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailTestIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailTestModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailTestModel, criteria, options) } // FindMailTestId finds record id by querying it with criteria. @@ -150,8 +136,5 @@ func (c *Client) FindMailTestId(criteria *Criteria, options *Options) (int64, er if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.test was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_test_simple.go b/mail_test_simple.go index e25db06d..ef885c71 100644 --- a/mail_test_simple.go +++ b/mail_test_simple.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailTestSimple represents mail.test.simple model. type MailTestSimple struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -58,7 +54,7 @@ func (c *Client) CreateMailTestSimples(mtss []*MailTestSimple) ([]int64, error) for _, v := range mtss { vv = append(vv, v) } - return c.Create(MailTestSimpleModel, vv) + return c.Create(MailTestSimpleModel, vv, nil) } // UpdateMailTestSimple updates an existing mail.test.simple record. @@ -69,7 +65,7 @@ func (c *Client) UpdateMailTestSimple(mts *MailTestSimple) error { // UpdateMailTestSimples updates existing mail.test.simple records. // All records (represented by ids) will be updated by mts values. func (c *Client) UpdateMailTestSimples(ids []int64, mts *MailTestSimple) error { - return c.Update(MailTestSimpleModel, ids, mts) + return c.Update(MailTestSimpleModel, ids, mts, nil) } // DeleteMailTestSimple deletes an existing mail.test.simple record. @@ -88,10 +84,7 @@ func (c *Client) GetMailTestSimple(id int64) (*MailTestSimple, error) { if err != nil { return nil, err } - if mtss != nil && len(*mtss) > 0 { - return &((*mtss)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.test.simple not found", id) + return &((*mtss)[0]), nil } // GetMailTestSimples gets mail.test.simple existing records. @@ -109,10 +102,7 @@ func (c *Client) FindMailTestSimple(criteria *Criteria) (*MailTestSimple, error) if err := c.SearchRead(MailTestSimpleModel, criteria, NewOptions().Limit(1), mtss); err != nil { return nil, err } - if mtss != nil && len(*mtss) > 0 { - return &((*mtss)[0]), nil - } - return nil, fmt.Errorf("mail.test.simple was not found with criteria %v", criteria) + return &((*mtss)[0]), nil } // FindMailTestSimples finds mail.test.simple records by querying it @@ -128,11 +118,7 @@ func (c *Client) FindMailTestSimples(criteria *Criteria, options *Options) (*Mai // FindMailTestSimpleIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailTestSimpleIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailTestSimpleModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailTestSimpleModel, criteria, options) } // FindMailTestSimpleId finds record id by querying it with criteria. @@ -141,8 +127,5 @@ func (c *Client) FindMailTestSimpleId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.test.simple was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_thread.go b/mail_thread.go index e0b26b6b..b4e6934d 100644 --- a/mail_thread.go +++ b/mail_thread.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailThread represents mail.thread model. type MailThread struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -51,7 +47,7 @@ func (c *Client) CreateMailThreads(mts []*MailThread) ([]int64, error) { for _, v := range mts { vv = append(vv, v) } - return c.Create(MailThreadModel, vv) + return c.Create(MailThreadModel, vv, nil) } // UpdateMailThread updates an existing mail.thread record. @@ -62,7 +58,7 @@ func (c *Client) UpdateMailThread(mt *MailThread) error { // UpdateMailThreads updates existing mail.thread records. // All records (represented by ids) will be updated by mt values. func (c *Client) UpdateMailThreads(ids []int64, mt *MailThread) error { - return c.Update(MailThreadModel, ids, mt) + return c.Update(MailThreadModel, ids, mt, nil) } // DeleteMailThread deletes an existing mail.thread record. @@ -81,10 +77,7 @@ func (c *Client) GetMailThread(id int64) (*MailThread, error) { if err != nil { return nil, err } - if mts != nil && len(*mts) > 0 { - return &((*mts)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.thread not found", id) + return &((*mts)[0]), nil } // GetMailThreads gets mail.thread existing records. @@ -102,10 +95,7 @@ func (c *Client) FindMailThread(criteria *Criteria) (*MailThread, error) { if err := c.SearchRead(MailThreadModel, criteria, NewOptions().Limit(1), mts); err != nil { return nil, err } - if mts != nil && len(*mts) > 0 { - return &((*mts)[0]), nil - } - return nil, fmt.Errorf("mail.thread was not found with criteria %v", criteria) + return &((*mts)[0]), nil } // FindMailThreads finds mail.thread records by querying it @@ -121,11 +111,7 @@ func (c *Client) FindMailThreads(criteria *Criteria, options *Options) (*MailThr // FindMailThreadIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailThreadIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailThreadModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailThreadModel, criteria, options) } // FindMailThreadId finds record id by querying it with criteria. @@ -134,8 +120,5 @@ func (c *Client) FindMailThreadId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.thread was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_tracking_value.go b/mail_tracking_value.go index 1b470b5c..44f66652 100644 --- a/mail_tracking_value.go +++ b/mail_tracking_value.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailTrackingValue represents mail.tracking.value model. type MailTrackingValue struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -60,7 +56,7 @@ func (c *Client) CreateMailTrackingValues(mtvs []*MailTrackingValue) ([]int64, e for _, v := range mtvs { vv = append(vv, v) } - return c.Create(MailTrackingValueModel, vv) + return c.Create(MailTrackingValueModel, vv, nil) } // UpdateMailTrackingValue updates an existing mail.tracking.value record. @@ -71,7 +67,7 @@ func (c *Client) UpdateMailTrackingValue(mtv *MailTrackingValue) error { // UpdateMailTrackingValues updates existing mail.tracking.value records. // All records (represented by ids) will be updated by mtv values. func (c *Client) UpdateMailTrackingValues(ids []int64, mtv *MailTrackingValue) error { - return c.Update(MailTrackingValueModel, ids, mtv) + return c.Update(MailTrackingValueModel, ids, mtv, nil) } // DeleteMailTrackingValue deletes an existing mail.tracking.value record. @@ -90,10 +86,7 @@ func (c *Client) GetMailTrackingValue(id int64) (*MailTrackingValue, error) { if err != nil { return nil, err } - if mtvs != nil && len(*mtvs) > 0 { - return &((*mtvs)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.tracking.value not found", id) + return &((*mtvs)[0]), nil } // GetMailTrackingValues gets mail.tracking.value existing records. @@ -111,10 +104,7 @@ func (c *Client) FindMailTrackingValue(criteria *Criteria) (*MailTrackingValue, if err := c.SearchRead(MailTrackingValueModel, criteria, NewOptions().Limit(1), mtvs); err != nil { return nil, err } - if mtvs != nil && len(*mtvs) > 0 { - return &((*mtvs)[0]), nil - } - return nil, fmt.Errorf("mail.tracking.value was not found with criteria %v", criteria) + return &((*mtvs)[0]), nil } // FindMailTrackingValues finds mail.tracking.value records by querying it @@ -130,11 +120,7 @@ func (c *Client) FindMailTrackingValues(criteria *Criteria, options *Options) (* // FindMailTrackingValueIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailTrackingValueIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailTrackingValueModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailTrackingValueModel, criteria, options) } // FindMailTrackingValueId finds record id by querying it with criteria. @@ -143,8 +129,5 @@ func (c *Client) FindMailTrackingValueId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.tracking.value was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/mail_wizard_invite.go b/mail_wizard_invite.go index 2ae48be7..2b2dc133 100644 --- a/mail_wizard_invite.go +++ b/mail_wizard_invite.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // MailWizardInvite represents mail.wizard.invite model. type MailWizardInvite struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateMailWizardInvites(mwis []*MailWizardInvite) ([]int64, err for _, v := range mwis { vv = append(vv, v) } - return c.Create(MailWizardInviteModel, vv) + return c.Create(MailWizardInviteModel, vv, nil) } // UpdateMailWizardInvite updates an existing mail.wizard.invite record. @@ -61,7 +57,7 @@ func (c *Client) UpdateMailWizardInvite(mwi *MailWizardInvite) error { // UpdateMailWizardInvites updates existing mail.wizard.invite records. // All records (represented by ids) will be updated by mwi values. func (c *Client) UpdateMailWizardInvites(ids []int64, mwi *MailWizardInvite) error { - return c.Update(MailWizardInviteModel, ids, mwi) + return c.Update(MailWizardInviteModel, ids, mwi, nil) } // DeleteMailWizardInvite deletes an existing mail.wizard.invite record. @@ -80,10 +76,7 @@ func (c *Client) GetMailWizardInvite(id int64) (*MailWizardInvite, error) { if err != nil { return nil, err } - if mwis != nil && len(*mwis) > 0 { - return &((*mwis)[0]), nil - } - return nil, fmt.Errorf("id %v of mail.wizard.invite not found", id) + return &((*mwis)[0]), nil } // GetMailWizardInvites gets mail.wizard.invite existing records. @@ -101,10 +94,7 @@ func (c *Client) FindMailWizardInvite(criteria *Criteria) (*MailWizardInvite, er if err := c.SearchRead(MailWizardInviteModel, criteria, NewOptions().Limit(1), mwis); err != nil { return nil, err } - if mwis != nil && len(*mwis) > 0 { - return &((*mwis)[0]), nil - } - return nil, fmt.Errorf("mail.wizard.invite was not found with criteria %v", criteria) + return &((*mwis)[0]), nil } // FindMailWizardInvites finds mail.wizard.invite records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindMailWizardInvites(criteria *Criteria, options *Options) (*M // FindMailWizardInviteIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindMailWizardInviteIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(MailWizardInviteModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(MailWizardInviteModel, criteria, options) } // FindMailWizardInviteId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindMailWizardInviteId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("mail.wizard.invite was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/odoo.go b/odoo.go index f09f6750..8e9e3a74 100644 --- a/odoo.go +++ b/odoo.go @@ -1,4 +1,5 @@ -//Package odoo contains client code of library +// Package odoo contains client code of library +// //go:generate ./generator/generator -u $ODOO_ADMIN -p $ODOO_PASSWORD -d $ODOO_DATABASE --url $ODOO_URL -o $ODOO_REPO_PATH --models $ODOO_MODELS -t generator/cmd/tmpl/model.tmpl package odoo @@ -226,7 +227,7 @@ func getValuesFromInterface(v interface{}) map[string]interface{} { // Create new model instances. // https://www.odoo.com/documentation/13.0/webservices/odoo.html#create-records -func (c *Client) Create(model string, values []interface{}) ([]int64, error) { +func (c *Client) Create(model string, values []interface{}, options *Options) ([]int64, error) { var args []interface{} if len(values) == 0 { return nil, nil @@ -239,7 +240,7 @@ func (c *Client) Create(model string, values []interface{}) ([]int64, error) { } args = []interface{}{vv} } - resp, err := c.ExecuteKw("create", model, args, nil) + resp, err := c.ExecuteKw("create", model, args, options) if err != nil { return nil, err } @@ -256,9 +257,9 @@ func (c *Client) Create(model string, values []interface{}) ([]int64, error) { // Update existing model row(s). // https://www.odoo.com/documentation/13.0/webservices/odoo.html#update-records -func (c *Client) Update(model string, ids []int64, values interface{}) error { +func (c *Client) Update(model string, ids []int64, values interface{}, options *Options) error { v := getValuesFromInterface(values) - _, err := c.ExecuteKw("write", model, []interface{}{ids, v}, nil) + _, err := c.ExecuteKw("write", model, []interface{}{ids, v}, options) if err != nil { return err } diff --git a/payment_acquirer.go b/payment_acquirer.go index 73f490ec..f7062f87 100644 --- a/payment_acquirer.go +++ b/payment_acquirer.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // PaymentAcquirer represents payment.acquirer model. type PaymentAcquirer struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -79,7 +75,7 @@ func (c *Client) CreatePaymentAcquirers(pas []*PaymentAcquirer) ([]int64, error) for _, v := range pas { vv = append(vv, v) } - return c.Create(PaymentAcquirerModel, vv) + return c.Create(PaymentAcquirerModel, vv, nil) } // UpdatePaymentAcquirer updates an existing payment.acquirer record. @@ -90,7 +86,7 @@ func (c *Client) UpdatePaymentAcquirer(pa *PaymentAcquirer) error { // UpdatePaymentAcquirers updates existing payment.acquirer records. // All records (represented by ids) will be updated by pa values. func (c *Client) UpdatePaymentAcquirers(ids []int64, pa *PaymentAcquirer) error { - return c.Update(PaymentAcquirerModel, ids, pa) + return c.Update(PaymentAcquirerModel, ids, pa, nil) } // DeletePaymentAcquirer deletes an existing payment.acquirer record. @@ -109,10 +105,7 @@ func (c *Client) GetPaymentAcquirer(id int64) (*PaymentAcquirer, error) { if err != nil { return nil, err } - if pas != nil && len(*pas) > 0 { - return &((*pas)[0]), nil - } - return nil, fmt.Errorf("id %v of payment.acquirer not found", id) + return &((*pas)[0]), nil } // GetPaymentAcquirers gets payment.acquirer existing records. @@ -130,10 +123,7 @@ func (c *Client) FindPaymentAcquirer(criteria *Criteria) (*PaymentAcquirer, erro if err := c.SearchRead(PaymentAcquirerModel, criteria, NewOptions().Limit(1), pas); err != nil { return nil, err } - if pas != nil && len(*pas) > 0 { - return &((*pas)[0]), nil - } - return nil, fmt.Errorf("payment.acquirer was not found with criteria %v", criteria) + return &((*pas)[0]), nil } // FindPaymentAcquirers finds payment.acquirer records by querying it @@ -149,11 +139,7 @@ func (c *Client) FindPaymentAcquirers(criteria *Criteria, options *Options) (*Pa // FindPaymentAcquirerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindPaymentAcquirerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(PaymentAcquirerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(PaymentAcquirerModel, criteria, options) } // FindPaymentAcquirerId finds record id by querying it with criteria. @@ -162,8 +148,5 @@ func (c *Client) FindPaymentAcquirerId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("payment.acquirer was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/payment_icon.go b/payment_icon.go index cfbe9d18..174f007c 100644 --- a/payment_icon.go +++ b/payment_icon.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // PaymentIcon represents payment.icon model. type PaymentIcon struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreatePaymentIcons(pis []*PaymentIcon) ([]int64, error) { for _, v := range pis { vv = append(vv, v) } - return c.Create(PaymentIconModel, vv) + return c.Create(PaymentIconModel, vv, nil) } // UpdatePaymentIcon updates an existing payment.icon record. @@ -59,7 +55,7 @@ func (c *Client) UpdatePaymentIcon(pi *PaymentIcon) error { // UpdatePaymentIcons updates existing payment.icon records. // All records (represented by ids) will be updated by pi values. func (c *Client) UpdatePaymentIcons(ids []int64, pi *PaymentIcon) error { - return c.Update(PaymentIconModel, ids, pi) + return c.Update(PaymentIconModel, ids, pi, nil) } // DeletePaymentIcon deletes an existing payment.icon record. @@ -78,10 +74,7 @@ func (c *Client) GetPaymentIcon(id int64) (*PaymentIcon, error) { if err != nil { return nil, err } - if pis != nil && len(*pis) > 0 { - return &((*pis)[0]), nil - } - return nil, fmt.Errorf("id %v of payment.icon not found", id) + return &((*pis)[0]), nil } // GetPaymentIcons gets payment.icon existing records. @@ -99,10 +92,7 @@ func (c *Client) FindPaymentIcon(criteria *Criteria) (*PaymentIcon, error) { if err := c.SearchRead(PaymentIconModel, criteria, NewOptions().Limit(1), pis); err != nil { return nil, err } - if pis != nil && len(*pis) > 0 { - return &((*pis)[0]), nil - } - return nil, fmt.Errorf("payment.icon was not found with criteria %v", criteria) + return &((*pis)[0]), nil } // FindPaymentIcons finds payment.icon records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindPaymentIcons(criteria *Criteria, options *Options) (*Paymen // FindPaymentIconIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindPaymentIconIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(PaymentIconModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(PaymentIconModel, criteria, options) } // FindPaymentIconId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindPaymentIconId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("payment.icon was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/payment_token.go b/payment_token.go index b3ad7661..90d7118a 100644 --- a/payment_token.go +++ b/payment_token.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // PaymentToken represents payment.token model. type PaymentToken struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -52,7 +48,7 @@ func (c *Client) CreatePaymentTokens(pts []*PaymentToken) ([]int64, error) { for _, v := range pts { vv = append(vv, v) } - return c.Create(PaymentTokenModel, vv) + return c.Create(PaymentTokenModel, vv, nil) } // UpdatePaymentToken updates an existing payment.token record. @@ -63,7 +59,7 @@ func (c *Client) UpdatePaymentToken(pt *PaymentToken) error { // UpdatePaymentTokens updates existing payment.token records. // All records (represented by ids) will be updated by pt values. func (c *Client) UpdatePaymentTokens(ids []int64, pt *PaymentToken) error { - return c.Update(PaymentTokenModel, ids, pt) + return c.Update(PaymentTokenModel, ids, pt, nil) } // DeletePaymentToken deletes an existing payment.token record. @@ -82,10 +78,7 @@ func (c *Client) GetPaymentToken(id int64) (*PaymentToken, error) { if err != nil { return nil, err } - if pts != nil && len(*pts) > 0 { - return &((*pts)[0]), nil - } - return nil, fmt.Errorf("id %v of payment.token not found", id) + return &((*pts)[0]), nil } // GetPaymentTokens gets payment.token existing records. @@ -103,10 +96,7 @@ func (c *Client) FindPaymentToken(criteria *Criteria) (*PaymentToken, error) { if err := c.SearchRead(PaymentTokenModel, criteria, NewOptions().Limit(1), pts); err != nil { return nil, err } - if pts != nil && len(*pts) > 0 { - return &((*pts)[0]), nil - } - return nil, fmt.Errorf("payment.token was not found with criteria %v", criteria) + return &((*pts)[0]), nil } // FindPaymentTokens finds payment.token records by querying it @@ -122,11 +112,7 @@ func (c *Client) FindPaymentTokens(criteria *Criteria, options *Options) (*Payme // FindPaymentTokenIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindPaymentTokenIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(PaymentTokenModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(PaymentTokenModel, criteria, options) } // FindPaymentTokenId finds record id by querying it with criteria. @@ -135,8 +121,5 @@ func (c *Client) FindPaymentTokenId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("payment.token was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/payment_transaction.go b/payment_transaction.go index decaa44c..f016260a 100644 --- a/payment_transaction.go +++ b/payment_transaction.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // PaymentTransaction represents payment.transaction model. type PaymentTransaction struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -70,7 +66,7 @@ func (c *Client) CreatePaymentTransactions(pts []*PaymentTransaction) ([]int64, for _, v := range pts { vv = append(vv, v) } - return c.Create(PaymentTransactionModel, vv) + return c.Create(PaymentTransactionModel, vv, nil) } // UpdatePaymentTransaction updates an existing payment.transaction record. @@ -81,7 +77,7 @@ func (c *Client) UpdatePaymentTransaction(pt *PaymentTransaction) error { // UpdatePaymentTransactions updates existing payment.transaction records. // All records (represented by ids) will be updated by pt values. func (c *Client) UpdatePaymentTransactions(ids []int64, pt *PaymentTransaction) error { - return c.Update(PaymentTransactionModel, ids, pt) + return c.Update(PaymentTransactionModel, ids, pt, nil) } // DeletePaymentTransaction deletes an existing payment.transaction record. @@ -100,10 +96,7 @@ func (c *Client) GetPaymentTransaction(id int64) (*PaymentTransaction, error) { if err != nil { return nil, err } - if pts != nil && len(*pts) > 0 { - return &((*pts)[0]), nil - } - return nil, fmt.Errorf("id %v of payment.transaction not found", id) + return &((*pts)[0]), nil } // GetPaymentTransactions gets payment.transaction existing records. @@ -121,10 +114,7 @@ func (c *Client) FindPaymentTransaction(criteria *Criteria) (*PaymentTransaction if err := c.SearchRead(PaymentTransactionModel, criteria, NewOptions().Limit(1), pts); err != nil { return nil, err } - if pts != nil && len(*pts) > 0 { - return &((*pts)[0]), nil - } - return nil, fmt.Errorf("payment.transaction was not found with criteria %v", criteria) + return &((*pts)[0]), nil } // FindPaymentTransactions finds payment.transaction records by querying it @@ -140,11 +130,7 @@ func (c *Client) FindPaymentTransactions(criteria *Criteria, options *Options) ( // FindPaymentTransactionIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindPaymentTransactionIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(PaymentTransactionModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(PaymentTransactionModel, criteria, options) } // FindPaymentTransactionId finds record id by querying it with criteria. @@ -153,8 +139,5 @@ func (c *Client) FindPaymentTransactionId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("payment.transaction was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/portal_mixin.go b/portal_mixin.go index 5a562986..7c742712 100644 --- a/portal_mixin.go +++ b/portal_mixin.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // PortalMixin represents portal.mixin model. type PortalMixin struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -41,7 +37,7 @@ func (c *Client) CreatePortalMixins(pms []*PortalMixin) ([]int64, error) { for _, v := range pms { vv = append(vv, v) } - return c.Create(PortalMixinModel, vv) + return c.Create(PortalMixinModel, vv, nil) } // UpdatePortalMixin updates an existing portal.mixin record. @@ -52,7 +48,7 @@ func (c *Client) UpdatePortalMixin(pm *PortalMixin) error { // UpdatePortalMixins updates existing portal.mixin records. // All records (represented by ids) will be updated by pm values. func (c *Client) UpdatePortalMixins(ids []int64, pm *PortalMixin) error { - return c.Update(PortalMixinModel, ids, pm) + return c.Update(PortalMixinModel, ids, pm, nil) } // DeletePortalMixin deletes an existing portal.mixin record. @@ -71,10 +67,7 @@ func (c *Client) GetPortalMixin(id int64) (*PortalMixin, error) { if err != nil { return nil, err } - if pms != nil && len(*pms) > 0 { - return &((*pms)[0]), nil - } - return nil, fmt.Errorf("id %v of portal.mixin not found", id) + return &((*pms)[0]), nil } // GetPortalMixins gets portal.mixin existing records. @@ -92,10 +85,7 @@ func (c *Client) FindPortalMixin(criteria *Criteria) (*PortalMixin, error) { if err := c.SearchRead(PortalMixinModel, criteria, NewOptions().Limit(1), pms); err != nil { return nil, err } - if pms != nil && len(*pms) > 0 { - return &((*pms)[0]), nil - } - return nil, fmt.Errorf("portal.mixin was not found with criteria %v", criteria) + return &((*pms)[0]), nil } // FindPortalMixins finds portal.mixin records by querying it @@ -111,11 +101,7 @@ func (c *Client) FindPortalMixins(criteria *Criteria, options *Options) (*Portal // FindPortalMixinIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindPortalMixinIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(PortalMixinModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(PortalMixinModel, criteria, options) } // FindPortalMixinId finds record id by querying it with criteria. @@ -124,8 +110,5 @@ func (c *Client) FindPortalMixinId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("portal.mixin was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/portal_wizard.go b/portal_wizard.go index 5d5f5d0e..2b045a82 100644 --- a/portal_wizard.go +++ b/portal_wizard.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // PortalWizard represents portal.wizard model. type PortalWizard struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreatePortalWizards(pws []*PortalWizard) ([]int64, error) { for _, v := range pws { vv = append(vv, v) } - return c.Create(PortalWizardModel, vv) + return c.Create(PortalWizardModel, vv, nil) } // UpdatePortalWizard updates an existing portal.wizard record. @@ -58,7 +54,7 @@ func (c *Client) UpdatePortalWizard(pw *PortalWizard) error { // UpdatePortalWizards updates existing portal.wizard records. // All records (represented by ids) will be updated by pw values. func (c *Client) UpdatePortalWizards(ids []int64, pw *PortalWizard) error { - return c.Update(PortalWizardModel, ids, pw) + return c.Update(PortalWizardModel, ids, pw, nil) } // DeletePortalWizard deletes an existing portal.wizard record. @@ -77,10 +73,7 @@ func (c *Client) GetPortalWizard(id int64) (*PortalWizard, error) { if err != nil { return nil, err } - if pws != nil && len(*pws) > 0 { - return &((*pws)[0]), nil - } - return nil, fmt.Errorf("id %v of portal.wizard not found", id) + return &((*pws)[0]), nil } // GetPortalWizards gets portal.wizard existing records. @@ -98,10 +91,7 @@ func (c *Client) FindPortalWizard(criteria *Criteria) (*PortalWizard, error) { if err := c.SearchRead(PortalWizardModel, criteria, NewOptions().Limit(1), pws); err != nil { return nil, err } - if pws != nil && len(*pws) > 0 { - return &((*pws)[0]), nil - } - return nil, fmt.Errorf("portal.wizard was not found with criteria %v", criteria) + return &((*pws)[0]), nil } // FindPortalWizards finds portal.wizard records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindPortalWizards(criteria *Criteria, options *Options) (*Porta // FindPortalWizardIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindPortalWizardIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(PortalWizardModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(PortalWizardModel, criteria, options) } // FindPortalWizardId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindPortalWizardId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("portal.wizard was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/portal_wizard_user.go b/portal_wizard_user.go index 035d35f4..a78eaec3 100644 --- a/portal_wizard_user.go +++ b/portal_wizard_user.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // PortalWizardUser represents portal.wizard.user model. type PortalWizardUser struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreatePortalWizardUsers(pwus []*PortalWizardUser) ([]int64, err for _, v := range pwus { vv = append(vv, v) } - return c.Create(PortalWizardUserModel, vv) + return c.Create(PortalWizardUserModel, vv, nil) } // UpdatePortalWizardUser updates an existing portal.wizard.user record. @@ -60,7 +56,7 @@ func (c *Client) UpdatePortalWizardUser(pwu *PortalWizardUser) error { // UpdatePortalWizardUsers updates existing portal.wizard.user records. // All records (represented by ids) will be updated by pwu values. func (c *Client) UpdatePortalWizardUsers(ids []int64, pwu *PortalWizardUser) error { - return c.Update(PortalWizardUserModel, ids, pwu) + return c.Update(PortalWizardUserModel, ids, pwu, nil) } // DeletePortalWizardUser deletes an existing portal.wizard.user record. @@ -79,10 +75,7 @@ func (c *Client) GetPortalWizardUser(id int64) (*PortalWizardUser, error) { if err != nil { return nil, err } - if pwus != nil && len(*pwus) > 0 { - return &((*pwus)[0]), nil - } - return nil, fmt.Errorf("id %v of portal.wizard.user not found", id) + return &((*pwus)[0]), nil } // GetPortalWizardUsers gets portal.wizard.user existing records. @@ -100,10 +93,7 @@ func (c *Client) FindPortalWizardUser(criteria *Criteria) (*PortalWizardUser, er if err := c.SearchRead(PortalWizardUserModel, criteria, NewOptions().Limit(1), pwus); err != nil { return nil, err } - if pwus != nil && len(*pwus) > 0 { - return &((*pwus)[0]), nil - } - return nil, fmt.Errorf("portal.wizard.user was not found with criteria %v", criteria) + return &((*pwus)[0]), nil } // FindPortalWizardUsers finds portal.wizard.user records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindPortalWizardUsers(criteria *Criteria, options *Options) (*P // FindPortalWizardUserIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindPortalWizardUserIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(PortalWizardUserModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(PortalWizardUserModel, criteria, options) } // FindPortalWizardUserId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindPortalWizardUserId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("portal.wizard.user was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/procurement_group.go b/procurement_group.go index 832b42a9..287b0bb8 100644 --- a/procurement_group.go +++ b/procurement_group.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProcurementGroup represents procurement.group model. type ProcurementGroup struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateProcurementGroups(pgs []*ProcurementGroup) ([]int64, erro for _, v := range pgs { vv = append(vv, v) } - return c.Create(ProcurementGroupModel, vv) + return c.Create(ProcurementGroupModel, vv, nil) } // UpdateProcurementGroup updates an existing procurement.group record. @@ -59,7 +55,7 @@ func (c *Client) UpdateProcurementGroup(pg *ProcurementGroup) error { // UpdateProcurementGroups updates existing procurement.group records. // All records (represented by ids) will be updated by pg values. func (c *Client) UpdateProcurementGroups(ids []int64, pg *ProcurementGroup) error { - return c.Update(ProcurementGroupModel, ids, pg) + return c.Update(ProcurementGroupModel, ids, pg, nil) } // DeleteProcurementGroup deletes an existing procurement.group record. @@ -78,10 +74,7 @@ func (c *Client) GetProcurementGroup(id int64) (*ProcurementGroup, error) { if err != nil { return nil, err } - if pgs != nil && len(*pgs) > 0 { - return &((*pgs)[0]), nil - } - return nil, fmt.Errorf("id %v of procurement.group not found", id) + return &((*pgs)[0]), nil } // GetProcurementGroups gets procurement.group existing records. @@ -99,10 +92,7 @@ func (c *Client) FindProcurementGroup(criteria *Criteria) (*ProcurementGroup, er if err := c.SearchRead(ProcurementGroupModel, criteria, NewOptions().Limit(1), pgs); err != nil { return nil, err } - if pgs != nil && len(*pgs) > 0 { - return &((*pgs)[0]), nil - } - return nil, fmt.Errorf("procurement.group was not found with criteria %v", criteria) + return &((*pgs)[0]), nil } // FindProcurementGroups finds procurement.group records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindProcurementGroups(criteria *Criteria, options *Options) (*P // FindProcurementGroupIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProcurementGroupIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProcurementGroupModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProcurementGroupModel, criteria, options) } // FindProcurementGroupId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindProcurementGroupId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("procurement.group was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/procurement_rule.go b/procurement_rule.go index 28ccb720..ca79520b 100644 --- a/procurement_rule.go +++ b/procurement_rule.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProcurementRule represents procurement.rule model. type ProcurementRule struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -62,7 +58,7 @@ func (c *Client) CreateProcurementRules(prs []*ProcurementRule) ([]int64, error) for _, v := range prs { vv = append(vv, v) } - return c.Create(ProcurementRuleModel, vv) + return c.Create(ProcurementRuleModel, vv, nil) } // UpdateProcurementRule updates an existing procurement.rule record. @@ -73,7 +69,7 @@ func (c *Client) UpdateProcurementRule(pr *ProcurementRule) error { // UpdateProcurementRules updates existing procurement.rule records. // All records (represented by ids) will be updated by pr values. func (c *Client) UpdateProcurementRules(ids []int64, pr *ProcurementRule) error { - return c.Update(ProcurementRuleModel, ids, pr) + return c.Update(ProcurementRuleModel, ids, pr, nil) } // DeleteProcurementRule deletes an existing procurement.rule record. @@ -92,10 +88,7 @@ func (c *Client) GetProcurementRule(id int64) (*ProcurementRule, error) { if err != nil { return nil, err } - if prs != nil && len(*prs) > 0 { - return &((*prs)[0]), nil - } - return nil, fmt.Errorf("id %v of procurement.rule not found", id) + return &((*prs)[0]), nil } // GetProcurementRules gets procurement.rule existing records. @@ -113,10 +106,7 @@ func (c *Client) FindProcurementRule(criteria *Criteria) (*ProcurementRule, erro if err := c.SearchRead(ProcurementRuleModel, criteria, NewOptions().Limit(1), prs); err != nil { return nil, err } - if prs != nil && len(*prs) > 0 { - return &((*prs)[0]), nil - } - return nil, fmt.Errorf("procurement.rule was not found with criteria %v", criteria) + return &((*prs)[0]), nil } // FindProcurementRules finds procurement.rule records by querying it @@ -132,11 +122,7 @@ func (c *Client) FindProcurementRules(criteria *Criteria, options *Options) (*Pr // FindProcurementRuleIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProcurementRuleIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProcurementRuleModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProcurementRuleModel, criteria, options) } // FindProcurementRuleId finds record id by querying it with criteria. @@ -145,8 +131,5 @@ func (c *Client) FindProcurementRuleId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("procurement.rule was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_attribute.go b/product_attribute.go index c74d56ef..b147e63d 100644 --- a/product_attribute.go +++ b/product_attribute.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductAttribute represents product.attribute model. type ProductAttribute struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateProductAttributes(pas []*ProductAttribute) ([]int64, erro for _, v := range pas { vv = append(vv, v) } - return c.Create(ProductAttributeModel, vv) + return c.Create(ProductAttributeModel, vv, nil) } // UpdateProductAttribute updates an existing product.attribute record. @@ -60,7 +56,7 @@ func (c *Client) UpdateProductAttribute(pa *ProductAttribute) error { // UpdateProductAttributes updates existing product.attribute records. // All records (represented by ids) will be updated by pa values. func (c *Client) UpdateProductAttributes(ids []int64, pa *ProductAttribute) error { - return c.Update(ProductAttributeModel, ids, pa) + return c.Update(ProductAttributeModel, ids, pa, nil) } // DeleteProductAttribute deletes an existing product.attribute record. @@ -79,10 +75,7 @@ func (c *Client) GetProductAttribute(id int64) (*ProductAttribute, error) { if err != nil { return nil, err } - if pas != nil && len(*pas) > 0 { - return &((*pas)[0]), nil - } - return nil, fmt.Errorf("id %v of product.attribute not found", id) + return &((*pas)[0]), nil } // GetProductAttributes gets product.attribute existing records. @@ -100,10 +93,7 @@ func (c *Client) FindProductAttribute(criteria *Criteria) (*ProductAttribute, er if err := c.SearchRead(ProductAttributeModel, criteria, NewOptions().Limit(1), pas); err != nil { return nil, err } - if pas != nil && len(*pas) > 0 { - return &((*pas)[0]), nil - } - return nil, fmt.Errorf("product.attribute was not found with criteria %v", criteria) + return &((*pas)[0]), nil } // FindProductAttributes finds product.attribute records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindProductAttributes(criteria *Criteria, options *Options) (*P // FindProductAttributeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductAttributeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductAttributeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductAttributeModel, criteria, options) } // FindProductAttributeId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindProductAttributeId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.attribute was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_attribute_line.go b/product_attribute_line.go index f3ddd3b0..f1d4bc60 100644 --- a/product_attribute_line.go +++ b/product_attribute_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductAttributeLine represents product.attribute.line model. type ProductAttributeLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateProductAttributeLines(pals []*ProductAttributeLine) ([]in for _, v := range pals { vv = append(vv, v) } - return c.Create(ProductAttributeLineModel, vv) + return c.Create(ProductAttributeLineModel, vv, nil) } // UpdateProductAttributeLine updates an existing product.attribute.line record. @@ -58,7 +54,7 @@ func (c *Client) UpdateProductAttributeLine(pal *ProductAttributeLine) error { // UpdateProductAttributeLines updates existing product.attribute.line records. // All records (represented by ids) will be updated by pal values. func (c *Client) UpdateProductAttributeLines(ids []int64, pal *ProductAttributeLine) error { - return c.Update(ProductAttributeLineModel, ids, pal) + return c.Update(ProductAttributeLineModel, ids, pal, nil) } // DeleteProductAttributeLine deletes an existing product.attribute.line record. @@ -77,10 +73,7 @@ func (c *Client) GetProductAttributeLine(id int64) (*ProductAttributeLine, error if err != nil { return nil, err } - if pals != nil && len(*pals) > 0 { - return &((*pals)[0]), nil - } - return nil, fmt.Errorf("id %v of product.attribute.line not found", id) + return &((*pals)[0]), nil } // GetProductAttributeLines gets product.attribute.line existing records. @@ -98,10 +91,7 @@ func (c *Client) FindProductAttributeLine(criteria *Criteria) (*ProductAttribute if err := c.SearchRead(ProductAttributeLineModel, criteria, NewOptions().Limit(1), pals); err != nil { return nil, err } - if pals != nil && len(*pals) > 0 { - return &((*pals)[0]), nil - } - return nil, fmt.Errorf("product.attribute.line was not found with criteria %v", criteria) + return &((*pals)[0]), nil } // FindProductAttributeLines finds product.attribute.line records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindProductAttributeLines(criteria *Criteria, options *Options) // FindProductAttributeLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductAttributeLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductAttributeLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductAttributeLineModel, criteria, options) } // FindProductAttributeLineId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindProductAttributeLineId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.attribute.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_attribute_price.go b/product_attribute_price.go index 8e896b27..add9318a 100644 --- a/product_attribute_price.go +++ b/product_attribute_price.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductAttributePrice represents product.attribute.price model. type ProductAttributePrice struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateProductAttributePrices(paps []*ProductAttributePrice) ([] for _, v := range paps { vv = append(vv, v) } - return c.Create(ProductAttributePriceModel, vv) + return c.Create(ProductAttributePriceModel, vv, nil) } // UpdateProductAttributePrice updates an existing product.attribute.price record. @@ -58,7 +54,7 @@ func (c *Client) UpdateProductAttributePrice(pap *ProductAttributePrice) error { // UpdateProductAttributePrices updates existing product.attribute.price records. // All records (represented by ids) will be updated by pap values. func (c *Client) UpdateProductAttributePrices(ids []int64, pap *ProductAttributePrice) error { - return c.Update(ProductAttributePriceModel, ids, pap) + return c.Update(ProductAttributePriceModel, ids, pap, nil) } // DeleteProductAttributePrice deletes an existing product.attribute.price record. @@ -77,10 +73,7 @@ func (c *Client) GetProductAttributePrice(id int64) (*ProductAttributePrice, err if err != nil { return nil, err } - if paps != nil && len(*paps) > 0 { - return &((*paps)[0]), nil - } - return nil, fmt.Errorf("id %v of product.attribute.price not found", id) + return &((*paps)[0]), nil } // GetProductAttributePrices gets product.attribute.price existing records. @@ -98,10 +91,7 @@ func (c *Client) FindProductAttributePrice(criteria *Criteria) (*ProductAttribut if err := c.SearchRead(ProductAttributePriceModel, criteria, NewOptions().Limit(1), paps); err != nil { return nil, err } - if paps != nil && len(*paps) > 0 { - return &((*paps)[0]), nil - } - return nil, fmt.Errorf("product.attribute.price was not found with criteria %v", criteria) + return &((*paps)[0]), nil } // FindProductAttributePrices finds product.attribute.price records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindProductAttributePrices(criteria *Criteria, options *Options // FindProductAttributePriceIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductAttributePriceIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductAttributePriceModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductAttributePriceModel, criteria, options) } // FindProductAttributePriceId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindProductAttributePriceId(criteria *Criteria, options *Option if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.attribute.price was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_attribute_value.go b/product_attribute_value.go index e5cb6e13..45dfa175 100644 --- a/product_attribute_value.go +++ b/product_attribute_value.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductAttributeValue represents product.attribute.value model. type ProductAttributeValue struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateProductAttributeValues(pavs []*ProductAttributeValue) ([] for _, v := range pavs { vv = append(vv, v) } - return c.Create(ProductAttributeValueModel, vv) + return c.Create(ProductAttributeValueModel, vv, nil) } // UpdateProductAttributeValue updates an existing product.attribute.value record. @@ -61,7 +57,7 @@ func (c *Client) UpdateProductAttributeValue(pav *ProductAttributeValue) error { // UpdateProductAttributeValues updates existing product.attribute.value records. // All records (represented by ids) will be updated by pav values. func (c *Client) UpdateProductAttributeValues(ids []int64, pav *ProductAttributeValue) error { - return c.Update(ProductAttributeValueModel, ids, pav) + return c.Update(ProductAttributeValueModel, ids, pav, nil) } // DeleteProductAttributeValue deletes an existing product.attribute.value record. @@ -80,10 +76,7 @@ func (c *Client) GetProductAttributeValue(id int64) (*ProductAttributeValue, err if err != nil { return nil, err } - if pavs != nil && len(*pavs) > 0 { - return &((*pavs)[0]), nil - } - return nil, fmt.Errorf("id %v of product.attribute.value not found", id) + return &((*pavs)[0]), nil } // GetProductAttributeValues gets product.attribute.value existing records. @@ -101,10 +94,7 @@ func (c *Client) FindProductAttributeValue(criteria *Criteria) (*ProductAttribut if err := c.SearchRead(ProductAttributeValueModel, criteria, NewOptions().Limit(1), pavs); err != nil { return nil, err } - if pavs != nil && len(*pavs) > 0 { - return &((*pavs)[0]), nil - } - return nil, fmt.Errorf("product.attribute.value was not found with criteria %v", criteria) + return &((*pavs)[0]), nil } // FindProductAttributeValues finds product.attribute.value records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindProductAttributeValues(criteria *Criteria, options *Options // FindProductAttributeValueIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductAttributeValueIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductAttributeValueModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductAttributeValueModel, criteria, options) } // FindProductAttributeValueId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindProductAttributeValueId(criteria *Criteria, options *Option if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.attribute.value was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_category.go b/product_category.go index 45f8775c..99df56dd 100644 --- a/product_category.go +++ b/product_category.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductCategory represents product.category model. type ProductCategory struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -63,7 +59,7 @@ func (c *Client) CreateProductCategorys(pcs []*ProductCategory) ([]int64, error) for _, v := range pcs { vv = append(vv, v) } - return c.Create(ProductCategoryModel, vv) + return c.Create(ProductCategoryModel, vv, nil) } // UpdateProductCategory updates an existing product.category record. @@ -74,7 +70,7 @@ func (c *Client) UpdateProductCategory(pc *ProductCategory) error { // UpdateProductCategorys updates existing product.category records. // All records (represented by ids) will be updated by pc values. func (c *Client) UpdateProductCategorys(ids []int64, pc *ProductCategory) error { - return c.Update(ProductCategoryModel, ids, pc) + return c.Update(ProductCategoryModel, ids, pc, nil) } // DeleteProductCategory deletes an existing product.category record. @@ -93,10 +89,7 @@ func (c *Client) GetProductCategory(id int64) (*ProductCategory, error) { if err != nil { return nil, err } - if pcs != nil && len(*pcs) > 0 { - return &((*pcs)[0]), nil - } - return nil, fmt.Errorf("id %v of product.category not found", id) + return &((*pcs)[0]), nil } // GetProductCategorys gets product.category existing records. @@ -114,10 +107,7 @@ func (c *Client) FindProductCategory(criteria *Criteria) (*ProductCategory, erro if err := c.SearchRead(ProductCategoryModel, criteria, NewOptions().Limit(1), pcs); err != nil { return nil, err } - if pcs != nil && len(*pcs) > 0 { - return &((*pcs)[0]), nil - } - return nil, fmt.Errorf("product.category was not found with criteria %v", criteria) + return &((*pcs)[0]), nil } // FindProductCategorys finds product.category records by querying it @@ -133,11 +123,7 @@ func (c *Client) FindProductCategorys(criteria *Criteria, options *Options) (*Pr // FindProductCategoryIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductCategoryIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductCategoryModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductCategoryModel, criteria, options) } // FindProductCategoryId finds record id by querying it with criteria. @@ -146,8 +132,5 @@ func (c *Client) FindProductCategoryId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.category was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_packaging.go b/product_packaging.go index 72c34727..2b85fea1 100644 --- a/product_packaging.go +++ b/product_packaging.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductPackaging represents product.packaging model. type ProductPackaging struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateProductPackagings(pps []*ProductPackaging) ([]int64, erro for _, v := range pps { vv = append(vv, v) } - return c.Create(ProductPackagingModel, vv) + return c.Create(ProductPackagingModel, vv, nil) } // UpdateProductPackaging updates an existing product.packaging record. @@ -60,7 +56,7 @@ func (c *Client) UpdateProductPackaging(pp *ProductPackaging) error { // UpdateProductPackagings updates existing product.packaging records. // All records (represented by ids) will be updated by pp values. func (c *Client) UpdateProductPackagings(ids []int64, pp *ProductPackaging) error { - return c.Update(ProductPackagingModel, ids, pp) + return c.Update(ProductPackagingModel, ids, pp, nil) } // DeleteProductPackaging deletes an existing product.packaging record. @@ -79,10 +75,7 @@ func (c *Client) GetProductPackaging(id int64) (*ProductPackaging, error) { if err != nil { return nil, err } - if pps != nil && len(*pps) > 0 { - return &((*pps)[0]), nil - } - return nil, fmt.Errorf("id %v of product.packaging not found", id) + return &((*pps)[0]), nil } // GetProductPackagings gets product.packaging existing records. @@ -100,10 +93,7 @@ func (c *Client) FindProductPackaging(criteria *Criteria) (*ProductPackaging, er if err := c.SearchRead(ProductPackagingModel, criteria, NewOptions().Limit(1), pps); err != nil { return nil, err } - if pps != nil && len(*pps) > 0 { - return &((*pps)[0]), nil - } - return nil, fmt.Errorf("product.packaging was not found with criteria %v", criteria) + return &((*pps)[0]), nil } // FindProductPackagings finds product.packaging records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindProductPackagings(criteria *Criteria, options *Options) (*P // FindProductPackagingIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductPackagingIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductPackagingModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductPackagingModel, criteria, options) } // FindProductPackagingId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindProductPackagingId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.packaging was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_price_history.go b/product_price_history.go index ccb42921..5e8ab0d5 100644 --- a/product_price_history.go +++ b/product_price_history.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductPriceHistory represents product.price.history model. type ProductPriceHistory struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateProductPriceHistorys(pphs []*ProductPriceHistory) ([]int6 for _, v := range pphs { vv = append(vv, v) } - return c.Create(ProductPriceHistoryModel, vv) + return c.Create(ProductPriceHistoryModel, vv, nil) } // UpdateProductPriceHistory updates an existing product.price.history record. @@ -59,7 +55,7 @@ func (c *Client) UpdateProductPriceHistory(pph *ProductPriceHistory) error { // UpdateProductPriceHistorys updates existing product.price.history records. // All records (represented by ids) will be updated by pph values. func (c *Client) UpdateProductPriceHistorys(ids []int64, pph *ProductPriceHistory) error { - return c.Update(ProductPriceHistoryModel, ids, pph) + return c.Update(ProductPriceHistoryModel, ids, pph, nil) } // DeleteProductPriceHistory deletes an existing product.price.history record. @@ -78,10 +74,7 @@ func (c *Client) GetProductPriceHistory(id int64) (*ProductPriceHistory, error) if err != nil { return nil, err } - if pphs != nil && len(*pphs) > 0 { - return &((*pphs)[0]), nil - } - return nil, fmt.Errorf("id %v of product.price.history not found", id) + return &((*pphs)[0]), nil } // GetProductPriceHistorys gets product.price.history existing records. @@ -99,10 +92,7 @@ func (c *Client) FindProductPriceHistory(criteria *Criteria) (*ProductPriceHisto if err := c.SearchRead(ProductPriceHistoryModel, criteria, NewOptions().Limit(1), pphs); err != nil { return nil, err } - if pphs != nil && len(*pphs) > 0 { - return &((*pphs)[0]), nil - } - return nil, fmt.Errorf("product.price.history was not found with criteria %v", criteria) + return &((*pphs)[0]), nil } // FindProductPriceHistorys finds product.price.history records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindProductPriceHistorys(criteria *Criteria, options *Options) // FindProductPriceHistoryIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductPriceHistoryIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductPriceHistoryModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductPriceHistoryModel, criteria, options) } // FindProductPriceHistoryId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindProductPriceHistoryId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.price.history was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_price_list.go b/product_price_list.go index be931336..f85f8256 100644 --- a/product_price_list.go +++ b/product_price_list.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductPriceList represents product.price_list model. type ProductPriceList struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateProductPriceLists(pps []*ProductPriceList) ([]int64, erro for _, v := range pps { vv = append(vv, v) } - return c.Create(ProductPriceListModel, vv) + return c.Create(ProductPriceListModel, vv, nil) } // UpdateProductPriceList updates an existing product.price_list record. @@ -61,7 +57,7 @@ func (c *Client) UpdateProductPriceList(pp *ProductPriceList) error { // UpdateProductPriceLists updates existing product.price_list records. // All records (represented by ids) will be updated by pp values. func (c *Client) UpdateProductPriceLists(ids []int64, pp *ProductPriceList) error { - return c.Update(ProductPriceListModel, ids, pp) + return c.Update(ProductPriceListModel, ids, pp, nil) } // DeleteProductPriceList deletes an existing product.price_list record. @@ -80,10 +76,7 @@ func (c *Client) GetProductPriceList(id int64) (*ProductPriceList, error) { if err != nil { return nil, err } - if pps != nil && len(*pps) > 0 { - return &((*pps)[0]), nil - } - return nil, fmt.Errorf("id %v of product.price_list not found", id) + return &((*pps)[0]), nil } // GetProductPriceLists gets product.price_list existing records. @@ -101,10 +94,7 @@ func (c *Client) FindProductPriceList(criteria *Criteria) (*ProductPriceList, er if err := c.SearchRead(ProductPriceListModel, criteria, NewOptions().Limit(1), pps); err != nil { return nil, err } - if pps != nil && len(*pps) > 0 { - return &((*pps)[0]), nil - } - return nil, fmt.Errorf("product.price_list was not found with criteria %v", criteria) + return &((*pps)[0]), nil } // FindProductPriceLists finds product.price_list records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindProductPriceLists(criteria *Criteria, options *Options) (*P // FindProductPriceListIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductPriceListIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductPriceListModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductPriceListModel, criteria, options) } // FindProductPriceListId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindProductPriceListId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.price_list was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_pricelist.go b/product_pricelist.go index 344d8781..2e00dee8 100644 --- a/product_pricelist.go +++ b/product_pricelist.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductPricelist represents product.pricelist model. type ProductPricelist struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -52,7 +48,7 @@ func (c *Client) CreateProductPricelists(pps []*ProductPricelist) ([]int64, erro for _, v := range pps { vv = append(vv, v) } - return c.Create(ProductPricelistModel, vv) + return c.Create(ProductPricelistModel, vv, nil) } // UpdateProductPricelist updates an existing product.pricelist record. @@ -63,7 +59,7 @@ func (c *Client) UpdateProductPricelist(pp *ProductPricelist) error { // UpdateProductPricelists updates existing product.pricelist records. // All records (represented by ids) will be updated by pp values. func (c *Client) UpdateProductPricelists(ids []int64, pp *ProductPricelist) error { - return c.Update(ProductPricelistModel, ids, pp) + return c.Update(ProductPricelistModel, ids, pp, nil) } // DeleteProductPricelist deletes an existing product.pricelist record. @@ -82,10 +78,7 @@ func (c *Client) GetProductPricelist(id int64) (*ProductPricelist, error) { if err != nil { return nil, err } - if pps != nil && len(*pps) > 0 { - return &((*pps)[0]), nil - } - return nil, fmt.Errorf("id %v of product.pricelist not found", id) + return &((*pps)[0]), nil } // GetProductPricelists gets product.pricelist existing records. @@ -103,10 +96,7 @@ func (c *Client) FindProductPricelist(criteria *Criteria) (*ProductPricelist, er if err := c.SearchRead(ProductPricelistModel, criteria, NewOptions().Limit(1), pps); err != nil { return nil, err } - if pps != nil && len(*pps) > 0 { - return &((*pps)[0]), nil - } - return nil, fmt.Errorf("product.pricelist was not found with criteria %v", criteria) + return &((*pps)[0]), nil } // FindProductPricelists finds product.pricelist records by querying it @@ -122,11 +112,7 @@ func (c *Client) FindProductPricelists(criteria *Criteria, options *Options) (*P // FindProductPricelistIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductPricelistIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductPricelistModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductPricelistModel, criteria, options) } // FindProductPricelistId finds record id by querying it with criteria. @@ -135,8 +121,5 @@ func (c *Client) FindProductPricelistId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.pricelist was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_pricelist_item.go b/product_pricelist_item.go index 43f82801..445f6cdf 100644 --- a/product_pricelist_item.go +++ b/product_pricelist_item.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductPricelistItem represents product.pricelist.item model. type ProductPricelistItem struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -66,7 +62,7 @@ func (c *Client) CreateProductPricelistItems(ppis []*ProductPricelistItem) ([]in for _, v := range ppis { vv = append(vv, v) } - return c.Create(ProductPricelistItemModel, vv) + return c.Create(ProductPricelistItemModel, vv, nil) } // UpdateProductPricelistItem updates an existing product.pricelist.item record. @@ -77,7 +73,7 @@ func (c *Client) UpdateProductPricelistItem(ppi *ProductPricelistItem) error { // UpdateProductPricelistItems updates existing product.pricelist.item records. // All records (represented by ids) will be updated by ppi values. func (c *Client) UpdateProductPricelistItems(ids []int64, ppi *ProductPricelistItem) error { - return c.Update(ProductPricelistItemModel, ids, ppi) + return c.Update(ProductPricelistItemModel, ids, ppi, nil) } // DeleteProductPricelistItem deletes an existing product.pricelist.item record. @@ -96,10 +92,7 @@ func (c *Client) GetProductPricelistItem(id int64) (*ProductPricelistItem, error if err != nil { return nil, err } - if ppis != nil && len(*ppis) > 0 { - return &((*ppis)[0]), nil - } - return nil, fmt.Errorf("id %v of product.pricelist.item not found", id) + return &((*ppis)[0]), nil } // GetProductPricelistItems gets product.pricelist.item existing records. @@ -117,10 +110,7 @@ func (c *Client) FindProductPricelistItem(criteria *Criteria) (*ProductPricelist if err := c.SearchRead(ProductPricelistItemModel, criteria, NewOptions().Limit(1), ppis); err != nil { return nil, err } - if ppis != nil && len(*ppis) > 0 { - return &((*ppis)[0]), nil - } - return nil, fmt.Errorf("product.pricelist.item was not found with criteria %v", criteria) + return &((*ppis)[0]), nil } // FindProductPricelistItems finds product.pricelist.item records by querying it @@ -136,11 +126,7 @@ func (c *Client) FindProductPricelistItems(criteria *Criteria, options *Options) // FindProductPricelistItemIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductPricelistItemIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductPricelistItemModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductPricelistItemModel, criteria, options) } // FindProductPricelistItemId finds record id by querying it with criteria. @@ -149,8 +135,5 @@ func (c *Client) FindProductPricelistItemId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.pricelist.item was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_product.go b/product_product.go index 71acd697..9fe899aa 100644 --- a/product_product.go +++ b/product_product.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductProduct represents product.product model. type ProductProduct struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -156,7 +152,7 @@ func (c *Client) CreateProductProducts(pps []*ProductProduct) ([]int64, error) { for _, v := range pps { vv = append(vv, v) } - return c.Create(ProductProductModel, vv) + return c.Create(ProductProductModel, vv, nil) } // UpdateProductProduct updates an existing product.product record. @@ -167,7 +163,7 @@ func (c *Client) UpdateProductProduct(pp *ProductProduct) error { // UpdateProductProducts updates existing product.product records. // All records (represented by ids) will be updated by pp values. func (c *Client) UpdateProductProducts(ids []int64, pp *ProductProduct) error { - return c.Update(ProductProductModel, ids, pp) + return c.Update(ProductProductModel, ids, pp, nil) } // DeleteProductProduct deletes an existing product.product record. @@ -186,10 +182,7 @@ func (c *Client) GetProductProduct(id int64) (*ProductProduct, error) { if err != nil { return nil, err } - if pps != nil && len(*pps) > 0 { - return &((*pps)[0]), nil - } - return nil, fmt.Errorf("id %v of product.product not found", id) + return &((*pps)[0]), nil } // GetProductProducts gets product.product existing records. @@ -207,10 +200,7 @@ func (c *Client) FindProductProduct(criteria *Criteria) (*ProductProduct, error) if err := c.SearchRead(ProductProductModel, criteria, NewOptions().Limit(1), pps); err != nil { return nil, err } - if pps != nil && len(*pps) > 0 { - return &((*pps)[0]), nil - } - return nil, fmt.Errorf("product.product was not found with criteria %v", criteria) + return &((*pps)[0]), nil } // FindProductProducts finds product.product records by querying it @@ -226,11 +216,7 @@ func (c *Client) FindProductProducts(criteria *Criteria, options *Options) (*Pro // FindProductProductIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductProductIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductProductModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductProductModel, criteria, options) } // FindProductProductId finds record id by querying it with criteria. @@ -239,8 +225,5 @@ func (c *Client) FindProductProductId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.product was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_putaway.go b/product_putaway.go index 903d8159..36df1c90 100644 --- a/product_putaway.go +++ b/product_putaway.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductPutaway represents product.putaway model. type ProductPutaway struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateProductPutaways(pps []*ProductPutaway) ([]int64, error) { for _, v := range pps { vv = append(vv, v) } - return c.Create(ProductPutawayModel, vv) + return c.Create(ProductPutawayModel, vv, nil) } // UpdateProductPutaway updates an existing product.putaway record. @@ -57,7 +53,7 @@ func (c *Client) UpdateProductPutaway(pp *ProductPutaway) error { // UpdateProductPutaways updates existing product.putaway records. // All records (represented by ids) will be updated by pp values. func (c *Client) UpdateProductPutaways(ids []int64, pp *ProductPutaway) error { - return c.Update(ProductPutawayModel, ids, pp) + return c.Update(ProductPutawayModel, ids, pp, nil) } // DeleteProductPutaway deletes an existing product.putaway record. @@ -76,10 +72,7 @@ func (c *Client) GetProductPutaway(id int64) (*ProductPutaway, error) { if err != nil { return nil, err } - if pps != nil && len(*pps) > 0 { - return &((*pps)[0]), nil - } - return nil, fmt.Errorf("id %v of product.putaway not found", id) + return &((*pps)[0]), nil } // GetProductPutaways gets product.putaway existing records. @@ -97,10 +90,7 @@ func (c *Client) FindProductPutaway(criteria *Criteria) (*ProductPutaway, error) if err := c.SearchRead(ProductPutawayModel, criteria, NewOptions().Limit(1), pps); err != nil { return nil, err } - if pps != nil && len(*pps) > 0 { - return &((*pps)[0]), nil - } - return nil, fmt.Errorf("product.putaway was not found with criteria %v", criteria) + return &((*pps)[0]), nil } // FindProductPutaways finds product.putaway records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindProductPutaways(criteria *Criteria, options *Options) (*Pro // FindProductPutawayIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductPutawayIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductPutawayModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductPutawayModel, criteria, options) } // FindProductPutawayId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindProductPutawayId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.putaway was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_removal.go b/product_removal.go index e5b94dd5..3f1ea54f 100644 --- a/product_removal.go +++ b/product_removal.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductRemoval represents product.removal model. type ProductRemoval struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateProductRemovals(prs []*ProductRemoval) ([]int64, error) { for _, v := range prs { vv = append(vv, v) } - return c.Create(ProductRemovalModel, vv) + return c.Create(ProductRemovalModel, vv, nil) } // UpdateProductRemoval updates an existing product.removal record. @@ -57,7 +53,7 @@ func (c *Client) UpdateProductRemoval(pr *ProductRemoval) error { // UpdateProductRemovals updates existing product.removal records. // All records (represented by ids) will be updated by pr values. func (c *Client) UpdateProductRemovals(ids []int64, pr *ProductRemoval) error { - return c.Update(ProductRemovalModel, ids, pr) + return c.Update(ProductRemovalModel, ids, pr, nil) } // DeleteProductRemoval deletes an existing product.removal record. @@ -76,10 +72,7 @@ func (c *Client) GetProductRemoval(id int64) (*ProductRemoval, error) { if err != nil { return nil, err } - if prs != nil && len(*prs) > 0 { - return &((*prs)[0]), nil - } - return nil, fmt.Errorf("id %v of product.removal not found", id) + return &((*prs)[0]), nil } // GetProductRemovals gets product.removal existing records. @@ -97,10 +90,7 @@ func (c *Client) FindProductRemoval(criteria *Criteria) (*ProductRemoval, error) if err := c.SearchRead(ProductRemovalModel, criteria, NewOptions().Limit(1), prs); err != nil { return nil, err } - if prs != nil && len(*prs) > 0 { - return &((*prs)[0]), nil - } - return nil, fmt.Errorf("product.removal was not found with criteria %v", criteria) + return &((*prs)[0]), nil } // FindProductRemovals finds product.removal records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindProductRemovals(criteria *Criteria, options *Options) (*Pro // FindProductRemovalIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductRemovalIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductRemovalModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductRemovalModel, criteria, options) } // FindProductRemovalId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindProductRemovalId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.removal was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_supplierinfo.go b/product_supplierinfo.go index 892e3d8c..1a4fa3e4 100644 --- a/product_supplierinfo.go +++ b/product_supplierinfo.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductSupplierinfo represents product.supplierinfo model. type ProductSupplierinfo struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -59,7 +55,7 @@ func (c *Client) CreateProductSupplierinfos(pss []*ProductSupplierinfo) ([]int64 for _, v := range pss { vv = append(vv, v) } - return c.Create(ProductSupplierinfoModel, vv) + return c.Create(ProductSupplierinfoModel, vv, nil) } // UpdateProductSupplierinfo updates an existing product.supplierinfo record. @@ -70,7 +66,7 @@ func (c *Client) UpdateProductSupplierinfo(ps *ProductSupplierinfo) error { // UpdateProductSupplierinfos updates existing product.supplierinfo records. // All records (represented by ids) will be updated by ps values. func (c *Client) UpdateProductSupplierinfos(ids []int64, ps *ProductSupplierinfo) error { - return c.Update(ProductSupplierinfoModel, ids, ps) + return c.Update(ProductSupplierinfoModel, ids, ps, nil) } // DeleteProductSupplierinfo deletes an existing product.supplierinfo record. @@ -89,10 +85,7 @@ func (c *Client) GetProductSupplierinfo(id int64) (*ProductSupplierinfo, error) if err != nil { return nil, err } - if pss != nil && len(*pss) > 0 { - return &((*pss)[0]), nil - } - return nil, fmt.Errorf("id %v of product.supplierinfo not found", id) + return &((*pss)[0]), nil } // GetProductSupplierinfos gets product.supplierinfo existing records. @@ -110,10 +103,7 @@ func (c *Client) FindProductSupplierinfo(criteria *Criteria) (*ProductSupplierin if err := c.SearchRead(ProductSupplierinfoModel, criteria, NewOptions().Limit(1), pss); err != nil { return nil, err } - if pss != nil && len(*pss) > 0 { - return &((*pss)[0]), nil - } - return nil, fmt.Errorf("product.supplierinfo was not found with criteria %v", criteria) + return &((*pss)[0]), nil } // FindProductSupplierinfos finds product.supplierinfo records by querying it @@ -129,11 +119,7 @@ func (c *Client) FindProductSupplierinfos(criteria *Criteria, options *Options) // FindProductSupplierinfoIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductSupplierinfoIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductSupplierinfoModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductSupplierinfoModel, criteria, options) } // FindProductSupplierinfoId finds record id by querying it with criteria. @@ -142,8 +128,5 @@ func (c *Client) FindProductSupplierinfoId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.supplierinfo was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_template.go b/product_template.go index 38c4d526..39466efc 100644 --- a/product_template.go +++ b/product_template.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductTemplate represents product.template model. type ProductTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -142,7 +138,7 @@ func (c *Client) CreateProductTemplates(pts []*ProductTemplate) ([]int64, error) for _, v := range pts { vv = append(vv, v) } - return c.Create(ProductTemplateModel, vv) + return c.Create(ProductTemplateModel, vv, nil) } // UpdateProductTemplate updates an existing product.template record. @@ -153,7 +149,7 @@ func (c *Client) UpdateProductTemplate(pt *ProductTemplate) error { // UpdateProductTemplates updates existing product.template records. // All records (represented by ids) will be updated by pt values. func (c *Client) UpdateProductTemplates(ids []int64, pt *ProductTemplate) error { - return c.Update(ProductTemplateModel, ids, pt) + return c.Update(ProductTemplateModel, ids, pt, nil) } // DeleteProductTemplate deletes an existing product.template record. @@ -172,10 +168,7 @@ func (c *Client) GetProductTemplate(id int64) (*ProductTemplate, error) { if err != nil { return nil, err } - if pts != nil && len(*pts) > 0 { - return &((*pts)[0]), nil - } - return nil, fmt.Errorf("id %v of product.template not found", id) + return &((*pts)[0]), nil } // GetProductTemplates gets product.template existing records. @@ -193,10 +186,7 @@ func (c *Client) FindProductTemplate(criteria *Criteria) (*ProductTemplate, erro if err := c.SearchRead(ProductTemplateModel, criteria, NewOptions().Limit(1), pts); err != nil { return nil, err } - if pts != nil && len(*pts) > 0 { - return &((*pts)[0]), nil - } - return nil, fmt.Errorf("product.template was not found with criteria %v", criteria) + return &((*pts)[0]), nil } // FindProductTemplates finds product.template records by querying it @@ -212,11 +202,7 @@ func (c *Client) FindProductTemplates(criteria *Criteria, options *Options) (*Pr // FindProductTemplateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductTemplateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductTemplateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductTemplateModel, criteria, options) } // FindProductTemplateId finds record id by querying it with criteria. @@ -225,8 +211,5 @@ func (c *Client) FindProductTemplateId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.template was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_uom.go b/product_uom.go index b5d5abfe..8ddbed4d 100644 --- a/product_uom.go +++ b/product_uom.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductUom represents product.uom model. type ProductUom struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -51,7 +47,7 @@ func (c *Client) CreateProductUoms(pus []*ProductUom) ([]int64, error) { for _, v := range pus { vv = append(vv, v) } - return c.Create(ProductUomModel, vv) + return c.Create(ProductUomModel, vv, nil) } // UpdateProductUom updates an existing product.uom record. @@ -62,7 +58,7 @@ func (c *Client) UpdateProductUom(pu *ProductUom) error { // UpdateProductUoms updates existing product.uom records. // All records (represented by ids) will be updated by pu values. func (c *Client) UpdateProductUoms(ids []int64, pu *ProductUom) error { - return c.Update(ProductUomModel, ids, pu) + return c.Update(ProductUomModel, ids, pu, nil) } // DeleteProductUom deletes an existing product.uom record. @@ -81,10 +77,7 @@ func (c *Client) GetProductUom(id int64) (*ProductUom, error) { if err != nil { return nil, err } - if pus != nil && len(*pus) > 0 { - return &((*pus)[0]), nil - } - return nil, fmt.Errorf("id %v of product.uom not found", id) + return &((*pus)[0]), nil } // GetProductUoms gets product.uom existing records. @@ -102,10 +95,7 @@ func (c *Client) FindProductUom(criteria *Criteria) (*ProductUom, error) { if err := c.SearchRead(ProductUomModel, criteria, NewOptions().Limit(1), pus); err != nil { return nil, err } - if pus != nil && len(*pus) > 0 { - return &((*pus)[0]), nil - } - return nil, fmt.Errorf("product.uom was not found with criteria %v", criteria) + return &((*pus)[0]), nil } // FindProductUoms finds product.uom records by querying it @@ -121,11 +111,7 @@ func (c *Client) FindProductUoms(criteria *Criteria, options *Options) (*Product // FindProductUomIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductUomIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductUomModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductUomModel, criteria, options) } // FindProductUomId finds record id by querying it with criteria. @@ -134,8 +120,5 @@ func (c *Client) FindProductUomId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.uom was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/product_uom_categ.go b/product_uom_categ.go index 711e8a35..61d04e85 100644 --- a/product_uom_categ.go +++ b/product_uom_categ.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProductUomCateg represents product.uom.categ model. type ProductUomCateg struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateProductUomCategs(pucs []*ProductUomCateg) ([]int64, error for _, v := range pucs { vv = append(vv, v) } - return c.Create(ProductUomCategModel, vv) + return c.Create(ProductUomCategModel, vv, nil) } // UpdateProductUomCateg updates an existing product.uom.categ record. @@ -56,7 +52,7 @@ func (c *Client) UpdateProductUomCateg(puc *ProductUomCateg) error { // UpdateProductUomCategs updates existing product.uom.categ records. // All records (represented by ids) will be updated by puc values. func (c *Client) UpdateProductUomCategs(ids []int64, puc *ProductUomCateg) error { - return c.Update(ProductUomCategModel, ids, puc) + return c.Update(ProductUomCategModel, ids, puc, nil) } // DeleteProductUomCateg deletes an existing product.uom.categ record. @@ -75,10 +71,7 @@ func (c *Client) GetProductUomCateg(id int64) (*ProductUomCateg, error) { if err != nil { return nil, err } - if pucs != nil && len(*pucs) > 0 { - return &((*pucs)[0]), nil - } - return nil, fmt.Errorf("id %v of product.uom.categ not found", id) + return &((*pucs)[0]), nil } // GetProductUomCategs gets product.uom.categ existing records. @@ -96,10 +89,7 @@ func (c *Client) FindProductUomCateg(criteria *Criteria) (*ProductUomCateg, erro if err := c.SearchRead(ProductUomCategModel, criteria, NewOptions().Limit(1), pucs); err != nil { return nil, err } - if pucs != nil && len(*pucs) > 0 { - return &((*pucs)[0]), nil - } - return nil, fmt.Errorf("product.uom.categ was not found with criteria %v", criteria) + return &((*pucs)[0]), nil } // FindProductUomCategs finds product.uom.categ records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindProductUomCategs(criteria *Criteria, options *Options) (*Pr // FindProductUomCategIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProductUomCategIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProductUomCategModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProductUomCategModel, criteria, options) } // FindProductUomCategId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindProductUomCategId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("product.uom.categ was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/project_project.go b/project_project.go index 19c4d244..e9491bf1 100644 --- a/project_project.go +++ b/project_project.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProjectProject represents project.project model. type ProjectProject struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,6 +36,7 @@ type ProjectProject struct { LabelTasks *String `xmlrpc:"label_tasks,omptempty"` LineIds *Relation `xmlrpc:"line_ids,omptempty"` MachineInitiativeName *String `xmlrpc:"machine_initiative_name,omptempty"` + MachineProjectName *String `xmlrpc:"machine_project_name,omptempty"` MessageChannelIds *Relation `xmlrpc:"message_channel_ids,omptempty"` MessageFollowerIds *Relation `xmlrpc:"message_follower_ids,omptempty"` MessageIds *Relation `xmlrpc:"message_ids,omptempty"` @@ -55,6 +52,7 @@ type ProjectProject struct { PortalUrl *String `xmlrpc:"portal_url,omptempty"` PrivacyVisibility *Selection `xmlrpc:"privacy_visibility,omptempty"` ProjectCount *Int `xmlrpc:"project_count,omptempty"` + ProjectCreated *Bool `xmlrpc:"project_created,omptempty"` ProjectIds *Relation `xmlrpc:"project_ids,omptempty"` ResourceCalendarId *Many2One `xmlrpc:"resource_calendar_id,omptempty"` SaleLineId *Many2One `xmlrpc:"sale_line_id,omptempty"` @@ -101,7 +99,7 @@ func (c *Client) CreateProjectProjects(pps []*ProjectProject) ([]int64, error) { for _, v := range pps { vv = append(vv, v) } - return c.Create(ProjectProjectModel, vv) + return c.Create(ProjectProjectModel, vv, nil) } // UpdateProjectProject updates an existing project.project record. @@ -112,7 +110,7 @@ func (c *Client) UpdateProjectProject(pp *ProjectProject) error { // UpdateProjectProjects updates existing project.project records. // All records (represented by ids) will be updated by pp values. func (c *Client) UpdateProjectProjects(ids []int64, pp *ProjectProject) error { - return c.Update(ProjectProjectModel, ids, pp) + return c.Update(ProjectProjectModel, ids, pp, nil) } // DeleteProjectProject deletes an existing project.project record. @@ -131,10 +129,7 @@ func (c *Client) GetProjectProject(id int64) (*ProjectProject, error) { if err != nil { return nil, err } - if pps != nil && len(*pps) > 0 { - return &((*pps)[0]), nil - } - return nil, fmt.Errorf("id %v of project.project not found", id) + return &((*pps)[0]), nil } // GetProjectProjects gets project.project existing records. @@ -152,10 +147,7 @@ func (c *Client) FindProjectProject(criteria *Criteria) (*ProjectProject, error) if err := c.SearchRead(ProjectProjectModel, criteria, NewOptions().Limit(1), pps); err != nil { return nil, err } - if pps != nil && len(*pps) > 0 { - return &((*pps)[0]), nil - } - return nil, fmt.Errorf("project.project was not found with criteria %v", criteria) + return &((*pps)[0]), nil } // FindProjectProjects finds project.project records by querying it @@ -171,11 +163,7 @@ func (c *Client) FindProjectProjects(criteria *Criteria, options *Options) (*Pro // FindProjectProjectIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProjectProjectIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProjectProjectModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProjectProjectModel, criteria, options) } // FindProjectProjectId finds record id by querying it with criteria. @@ -184,8 +172,5 @@ func (c *Client) FindProjectProjectId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("project.project was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/project_tags.go b/project_tags.go index b5125bd7..222629bc 100644 --- a/project_tags.go +++ b/project_tags.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProjectTags represents project.tags model. type ProjectTags struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateProjectTagss(pts []*ProjectTags) ([]int64, error) { for _, v := range pts { vv = append(vv, v) } - return c.Create(ProjectTagsModel, vv) + return c.Create(ProjectTagsModel, vv, nil) } // UpdateProjectTags updates an existing project.tags record. @@ -57,7 +53,7 @@ func (c *Client) UpdateProjectTags(pt *ProjectTags) error { // UpdateProjectTagss updates existing project.tags records. // All records (represented by ids) will be updated by pt values. func (c *Client) UpdateProjectTagss(ids []int64, pt *ProjectTags) error { - return c.Update(ProjectTagsModel, ids, pt) + return c.Update(ProjectTagsModel, ids, pt, nil) } // DeleteProjectTags deletes an existing project.tags record. @@ -76,10 +72,7 @@ func (c *Client) GetProjectTags(id int64) (*ProjectTags, error) { if err != nil { return nil, err } - if pts != nil && len(*pts) > 0 { - return &((*pts)[0]), nil - } - return nil, fmt.Errorf("id %v of project.tags not found", id) + return &((*pts)[0]), nil } // GetProjectTagss gets project.tags existing records. @@ -97,10 +90,7 @@ func (c *Client) FindProjectTags(criteria *Criteria) (*ProjectTags, error) { if err := c.SearchRead(ProjectTagsModel, criteria, NewOptions().Limit(1), pts); err != nil { return nil, err } - if pts != nil && len(*pts) > 0 { - return &((*pts)[0]), nil - } - return nil, fmt.Errorf("project.tags was not found with criteria %v", criteria) + return &((*pts)[0]), nil } // FindProjectTagss finds project.tags records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindProjectTagss(criteria *Criteria, options *Options) (*Projec // FindProjectTagsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProjectTagsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProjectTagsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProjectTagsModel, criteria, options) } // FindProjectTagsId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindProjectTagsId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("project.tags was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/project_task.go b/project_task.go index 57d8f935..7315aaff 100644 --- a/project_task.go +++ b/project_task.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProjectTask represents project.task model. type ProjectTask struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -109,7 +105,7 @@ func (c *Client) CreateProjectTasks(pts []*ProjectTask) ([]int64, error) { for _, v := range pts { vv = append(vv, v) } - return c.Create(ProjectTaskModel, vv) + return c.Create(ProjectTaskModel, vv, nil) } // UpdateProjectTask updates an existing project.task record. @@ -120,7 +116,7 @@ func (c *Client) UpdateProjectTask(pt *ProjectTask) error { // UpdateProjectTasks updates existing project.task records. // All records (represented by ids) will be updated by pt values. func (c *Client) UpdateProjectTasks(ids []int64, pt *ProjectTask) error { - return c.Update(ProjectTaskModel, ids, pt) + return c.Update(ProjectTaskModel, ids, pt, nil) } // DeleteProjectTask deletes an existing project.task record. @@ -139,10 +135,7 @@ func (c *Client) GetProjectTask(id int64) (*ProjectTask, error) { if err != nil { return nil, err } - if pts != nil && len(*pts) > 0 { - return &((*pts)[0]), nil - } - return nil, fmt.Errorf("id %v of project.task not found", id) + return &((*pts)[0]), nil } // GetProjectTasks gets project.task existing records. @@ -160,10 +153,7 @@ func (c *Client) FindProjectTask(criteria *Criteria) (*ProjectTask, error) { if err := c.SearchRead(ProjectTaskModel, criteria, NewOptions().Limit(1), pts); err != nil { return nil, err } - if pts != nil && len(*pts) > 0 { - return &((*pts)[0]), nil - } - return nil, fmt.Errorf("project.task was not found with criteria %v", criteria) + return &((*pts)[0]), nil } // FindProjectTasks finds project.task records by querying it @@ -179,11 +169,7 @@ func (c *Client) FindProjectTasks(criteria *Criteria, options *Options) (*Projec // FindProjectTaskIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProjectTaskIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProjectTaskModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProjectTaskModel, criteria, options) } // FindProjectTaskId finds record id by querying it with criteria. @@ -192,8 +178,5 @@ func (c *Client) FindProjectTaskId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("project.task was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/project_task_merge_wizard.go b/project_task_merge_wizard.go index 8b85f394..f701d649 100644 --- a/project_task_merge_wizard.go +++ b/project_task_merge_wizard.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProjectTaskMergeWizard represents project.task.merge.wizard model. type ProjectTaskMergeWizard struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateProjectTaskMergeWizards(ptmws []*ProjectTaskMergeWizard) for _, v := range ptmws { vv = append(vv, v) } - return c.Create(ProjectTaskMergeWizardModel, vv) + return c.Create(ProjectTaskMergeWizardModel, vv, nil) } // UpdateProjectTaskMergeWizard updates an existing project.task.merge.wizard record. @@ -61,7 +57,7 @@ func (c *Client) UpdateProjectTaskMergeWizard(ptmw *ProjectTaskMergeWizard) erro // UpdateProjectTaskMergeWizards updates existing project.task.merge.wizard records. // All records (represented by ids) will be updated by ptmw values. func (c *Client) UpdateProjectTaskMergeWizards(ids []int64, ptmw *ProjectTaskMergeWizard) error { - return c.Update(ProjectTaskMergeWizardModel, ids, ptmw) + return c.Update(ProjectTaskMergeWizardModel, ids, ptmw, nil) } // DeleteProjectTaskMergeWizard deletes an existing project.task.merge.wizard record. @@ -80,10 +76,7 @@ func (c *Client) GetProjectTaskMergeWizard(id int64) (*ProjectTaskMergeWizard, e if err != nil { return nil, err } - if ptmws != nil && len(*ptmws) > 0 { - return &((*ptmws)[0]), nil - } - return nil, fmt.Errorf("id %v of project.task.merge.wizard not found", id) + return &((*ptmws)[0]), nil } // GetProjectTaskMergeWizards gets project.task.merge.wizard existing records. @@ -101,10 +94,7 @@ func (c *Client) FindProjectTaskMergeWizard(criteria *Criteria) (*ProjectTaskMer if err := c.SearchRead(ProjectTaskMergeWizardModel, criteria, NewOptions().Limit(1), ptmws); err != nil { return nil, err } - if ptmws != nil && len(*ptmws) > 0 { - return &((*ptmws)[0]), nil - } - return nil, fmt.Errorf("project.task.merge.wizard was not found with criteria %v", criteria) + return &((*ptmws)[0]), nil } // FindProjectTaskMergeWizards finds project.task.merge.wizard records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindProjectTaskMergeWizards(criteria *Criteria, options *Option // FindProjectTaskMergeWizardIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProjectTaskMergeWizardIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProjectTaskMergeWizardModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProjectTaskMergeWizardModel, criteria, options) } // FindProjectTaskMergeWizardId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindProjectTaskMergeWizardId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("project.task.merge.wizard was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/project_task_type.go b/project_task_type.go index f9831ffc..bfd5bfc5 100644 --- a/project_task_type.go +++ b/project_task_type.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ProjectTaskType represents project.task.type model. type ProjectTaskType struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -54,7 +50,7 @@ func (c *Client) CreateProjectTaskTypes(ptts []*ProjectTaskType) ([]int64, error for _, v := range ptts { vv = append(vv, v) } - return c.Create(ProjectTaskTypeModel, vv) + return c.Create(ProjectTaskTypeModel, vv, nil) } // UpdateProjectTaskType updates an existing project.task.type record. @@ -65,7 +61,7 @@ func (c *Client) UpdateProjectTaskType(ptt *ProjectTaskType) error { // UpdateProjectTaskTypes updates existing project.task.type records. // All records (represented by ids) will be updated by ptt values. func (c *Client) UpdateProjectTaskTypes(ids []int64, ptt *ProjectTaskType) error { - return c.Update(ProjectTaskTypeModel, ids, ptt) + return c.Update(ProjectTaskTypeModel, ids, ptt, nil) } // DeleteProjectTaskType deletes an existing project.task.type record. @@ -84,10 +80,7 @@ func (c *Client) GetProjectTaskType(id int64) (*ProjectTaskType, error) { if err != nil { return nil, err } - if ptts != nil && len(*ptts) > 0 { - return &((*ptts)[0]), nil - } - return nil, fmt.Errorf("id %v of project.task.type not found", id) + return &((*ptts)[0]), nil } // GetProjectTaskTypes gets project.task.type existing records. @@ -105,10 +98,7 @@ func (c *Client) FindProjectTaskType(criteria *Criteria) (*ProjectTaskType, erro if err := c.SearchRead(ProjectTaskTypeModel, criteria, NewOptions().Limit(1), ptts); err != nil { return nil, err } - if ptts != nil && len(*ptts) > 0 { - return &((*ptts)[0]), nil - } - return nil, fmt.Errorf("project.task.type was not found with criteria %v", criteria) + return &((*ptts)[0]), nil } // FindProjectTaskTypes finds project.task.type records by querying it @@ -124,11 +114,7 @@ func (c *Client) FindProjectTaskTypes(criteria *Criteria, options *Options) (*Pr // FindProjectTaskTypeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindProjectTaskTypeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ProjectTaskTypeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ProjectTaskTypeModel, criteria, options) } // FindProjectTaskTypeId finds record id by querying it with criteria. @@ -137,8 +123,5 @@ func (c *Client) FindProjectTaskTypeId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("project.task.type was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/publisher_warranty_contract.go b/publisher_warranty_contract.go index 4b36aa5e..24a7e0a8 100644 --- a/publisher_warranty_contract.go +++ b/publisher_warranty_contract.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // PublisherWarrantyContract represents publisher_warranty.contract model. type PublisherWarrantyContract struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreatePublisherWarrantyContracts(pcs []*PublisherWarrantyContra for _, v := range pcs { vv = append(vv, v) } - return c.Create(PublisherWarrantyContractModel, vv) + return c.Create(PublisherWarrantyContractModel, vv, nil) } // UpdatePublisherWarrantyContract updates an existing publisher_warranty.contract record. @@ -51,7 +47,7 @@ func (c *Client) UpdatePublisherWarrantyContract(pc *PublisherWarrantyContract) // UpdatePublisherWarrantyContracts updates existing publisher_warranty.contract records. // All records (represented by ids) will be updated by pc values. func (c *Client) UpdatePublisherWarrantyContracts(ids []int64, pc *PublisherWarrantyContract) error { - return c.Update(PublisherWarrantyContractModel, ids, pc) + return c.Update(PublisherWarrantyContractModel, ids, pc, nil) } // DeletePublisherWarrantyContract deletes an existing publisher_warranty.contract record. @@ -70,10 +66,7 @@ func (c *Client) GetPublisherWarrantyContract(id int64) (*PublisherWarrantyContr if err != nil { return nil, err } - if pcs != nil && len(*pcs) > 0 { - return &((*pcs)[0]), nil - } - return nil, fmt.Errorf("id %v of publisher_warranty.contract not found", id) + return &((*pcs)[0]), nil } // GetPublisherWarrantyContracts gets publisher_warranty.contract existing records. @@ -91,10 +84,7 @@ func (c *Client) FindPublisherWarrantyContract(criteria *Criteria) (*PublisherWa if err := c.SearchRead(PublisherWarrantyContractModel, criteria, NewOptions().Limit(1), pcs); err != nil { return nil, err } - if pcs != nil && len(*pcs) > 0 { - return &((*pcs)[0]), nil - } - return nil, fmt.Errorf("publisher_warranty.contract was not found with criteria %v", criteria) + return &((*pcs)[0]), nil } // FindPublisherWarrantyContracts finds publisher_warranty.contract records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindPublisherWarrantyContracts(criteria *Criteria, options *Opt // FindPublisherWarrantyContractIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindPublisherWarrantyContractIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(PublisherWarrantyContractModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(PublisherWarrantyContractModel, criteria, options) } // FindPublisherWarrantyContractId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindPublisherWarrantyContractId(criteria *Criteria, options *Op if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("publisher_warranty.contract was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/purchase_order.go b/purchase_order.go index 8cde5abd..c462c76b 100644 --- a/purchase_order.go +++ b/purchase_order.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // PurchaseOrder represents purchase.order model. type PurchaseOrder struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -91,7 +87,7 @@ func (c *Client) CreatePurchaseOrders(pos []*PurchaseOrder) ([]int64, error) { for _, v := range pos { vv = append(vv, v) } - return c.Create(PurchaseOrderModel, vv) + return c.Create(PurchaseOrderModel, vv, nil) } // UpdatePurchaseOrder updates an existing purchase.order record. @@ -102,7 +98,7 @@ func (c *Client) UpdatePurchaseOrder(po *PurchaseOrder) error { // UpdatePurchaseOrders updates existing purchase.order records. // All records (represented by ids) will be updated by po values. func (c *Client) UpdatePurchaseOrders(ids []int64, po *PurchaseOrder) error { - return c.Update(PurchaseOrderModel, ids, po) + return c.Update(PurchaseOrderModel, ids, po, nil) } // DeletePurchaseOrder deletes an existing purchase.order record. @@ -121,10 +117,7 @@ func (c *Client) GetPurchaseOrder(id int64) (*PurchaseOrder, error) { if err != nil { return nil, err } - if pos != nil && len(*pos) > 0 { - return &((*pos)[0]), nil - } - return nil, fmt.Errorf("id %v of purchase.order not found", id) + return &((*pos)[0]), nil } // GetPurchaseOrders gets purchase.order existing records. @@ -142,10 +135,7 @@ func (c *Client) FindPurchaseOrder(criteria *Criteria) (*PurchaseOrder, error) { if err := c.SearchRead(PurchaseOrderModel, criteria, NewOptions().Limit(1), pos); err != nil { return nil, err } - if pos != nil && len(*pos) > 0 { - return &((*pos)[0]), nil - } - return nil, fmt.Errorf("purchase.order was not found with criteria %v", criteria) + return &((*pos)[0]), nil } // FindPurchaseOrders finds purchase.order records by querying it @@ -161,11 +151,7 @@ func (c *Client) FindPurchaseOrders(criteria *Criteria, options *Options) (*Purc // FindPurchaseOrderIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindPurchaseOrderIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(PurchaseOrderModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(PurchaseOrderModel, criteria, options) } // FindPurchaseOrderId finds record id by querying it with criteria. @@ -174,8 +160,5 @@ func (c *Client) FindPurchaseOrderId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("purchase.order was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/purchase_order_line.go b/purchase_order_line.go index 7fc9ab1b..0ebece9c 100644 --- a/purchase_order_line.go +++ b/purchase_order_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // PurchaseOrderLine represents purchase.order.line model. type PurchaseOrderLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -70,7 +66,7 @@ func (c *Client) CreatePurchaseOrderLines(pols []*PurchaseOrderLine) ([]int64, e for _, v := range pols { vv = append(vv, v) } - return c.Create(PurchaseOrderLineModel, vv) + return c.Create(PurchaseOrderLineModel, vv, nil) } // UpdatePurchaseOrderLine updates an existing purchase.order.line record. @@ -81,7 +77,7 @@ func (c *Client) UpdatePurchaseOrderLine(pol *PurchaseOrderLine) error { // UpdatePurchaseOrderLines updates existing purchase.order.line records. // All records (represented by ids) will be updated by pol values. func (c *Client) UpdatePurchaseOrderLines(ids []int64, pol *PurchaseOrderLine) error { - return c.Update(PurchaseOrderLineModel, ids, pol) + return c.Update(PurchaseOrderLineModel, ids, pol, nil) } // DeletePurchaseOrderLine deletes an existing purchase.order.line record. @@ -100,10 +96,7 @@ func (c *Client) GetPurchaseOrderLine(id int64) (*PurchaseOrderLine, error) { if err != nil { return nil, err } - if pols != nil && len(*pols) > 0 { - return &((*pols)[0]), nil - } - return nil, fmt.Errorf("id %v of purchase.order.line not found", id) + return &((*pols)[0]), nil } // GetPurchaseOrderLines gets purchase.order.line existing records. @@ -121,10 +114,7 @@ func (c *Client) FindPurchaseOrderLine(criteria *Criteria) (*PurchaseOrderLine, if err := c.SearchRead(PurchaseOrderLineModel, criteria, NewOptions().Limit(1), pols); err != nil { return nil, err } - if pols != nil && len(*pols) > 0 { - return &((*pols)[0]), nil - } - return nil, fmt.Errorf("purchase.order.line was not found with criteria %v", criteria) + return &((*pols)[0]), nil } // FindPurchaseOrderLines finds purchase.order.line records by querying it @@ -140,11 +130,7 @@ func (c *Client) FindPurchaseOrderLines(criteria *Criteria, options *Options) (* // FindPurchaseOrderLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindPurchaseOrderLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(PurchaseOrderLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(PurchaseOrderLineModel, criteria, options) } // FindPurchaseOrderLineId finds record id by querying it with criteria. @@ -153,8 +139,5 @@ func (c *Client) FindPurchaseOrderLineId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("purchase.order.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/purchase_report.go b/purchase_report.go index 88d6296f..19eb5c42 100644 --- a/purchase_report.go +++ b/purchase_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // PurchaseReport represents purchase.report model. type PurchaseReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -66,7 +62,7 @@ func (c *Client) CreatePurchaseReports(prs []*PurchaseReport) ([]int64, error) { for _, v := range prs { vv = append(vv, v) } - return c.Create(PurchaseReportModel, vv) + return c.Create(PurchaseReportModel, vv, nil) } // UpdatePurchaseReport updates an existing purchase.report record. @@ -77,7 +73,7 @@ func (c *Client) UpdatePurchaseReport(pr *PurchaseReport) error { // UpdatePurchaseReports updates existing purchase.report records. // All records (represented by ids) will be updated by pr values. func (c *Client) UpdatePurchaseReports(ids []int64, pr *PurchaseReport) error { - return c.Update(PurchaseReportModel, ids, pr) + return c.Update(PurchaseReportModel, ids, pr, nil) } // DeletePurchaseReport deletes an existing purchase.report record. @@ -96,10 +92,7 @@ func (c *Client) GetPurchaseReport(id int64) (*PurchaseReport, error) { if err != nil { return nil, err } - if prs != nil && len(*prs) > 0 { - return &((*prs)[0]), nil - } - return nil, fmt.Errorf("id %v of purchase.report not found", id) + return &((*prs)[0]), nil } // GetPurchaseReports gets purchase.report existing records. @@ -117,10 +110,7 @@ func (c *Client) FindPurchaseReport(criteria *Criteria) (*PurchaseReport, error) if err := c.SearchRead(PurchaseReportModel, criteria, NewOptions().Limit(1), prs); err != nil { return nil, err } - if prs != nil && len(*prs) > 0 { - return &((*prs)[0]), nil - } - return nil, fmt.Errorf("purchase.report was not found with criteria %v", criteria) + return &((*prs)[0]), nil } // FindPurchaseReports finds purchase.report records by querying it @@ -136,11 +126,7 @@ func (c *Client) FindPurchaseReports(criteria *Criteria, options *Options) (*Pur // FindPurchaseReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindPurchaseReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(PurchaseReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(PurchaseReportModel, criteria, options) } // FindPurchaseReportId finds record id by querying it with criteria. @@ -149,8 +135,5 @@ func (c *Client) FindPurchaseReportId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("purchase.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/rating_mixin.go b/rating_mixin.go index 7a51d8e4..81dd0688 100644 --- a/rating_mixin.go +++ b/rating_mixin.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // RatingMixin represents rating.mixin model. type RatingMixin struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateRatingMixins(rms []*RatingMixin) ([]int64, error) { for _, v := range rms { vv = append(vv, v) } - return c.Create(RatingMixinModel, vv) + return c.Create(RatingMixinModel, vv, nil) } // UpdateRatingMixin updates an existing rating.mixin record. @@ -56,7 +52,7 @@ func (c *Client) UpdateRatingMixin(rm *RatingMixin) error { // UpdateRatingMixins updates existing rating.mixin records. // All records (represented by ids) will be updated by rm values. func (c *Client) UpdateRatingMixins(ids []int64, rm *RatingMixin) error { - return c.Update(RatingMixinModel, ids, rm) + return c.Update(RatingMixinModel, ids, rm, nil) } // DeleteRatingMixin deletes an existing rating.mixin record. @@ -75,10 +71,7 @@ func (c *Client) GetRatingMixin(id int64) (*RatingMixin, error) { if err != nil { return nil, err } - if rms != nil && len(*rms) > 0 { - return &((*rms)[0]), nil - } - return nil, fmt.Errorf("id %v of rating.mixin not found", id) + return &((*rms)[0]), nil } // GetRatingMixins gets rating.mixin existing records. @@ -96,10 +89,7 @@ func (c *Client) FindRatingMixin(criteria *Criteria) (*RatingMixin, error) { if err := c.SearchRead(RatingMixinModel, criteria, NewOptions().Limit(1), rms); err != nil { return nil, err } - if rms != nil && len(*rms) > 0 { - return &((*rms)[0]), nil - } - return nil, fmt.Errorf("rating.mixin was not found with criteria %v", criteria) + return &((*rms)[0]), nil } // FindRatingMixins finds rating.mixin records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindRatingMixins(criteria *Criteria, options *Options) (*Rating // FindRatingMixinIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindRatingMixinIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(RatingMixinModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(RatingMixinModel, criteria, options) } // FindRatingMixinId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindRatingMixinId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("rating.mixin was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/rating_rating.go b/rating_rating.go index 64e0c523..644a96d3 100644 --- a/rating_rating.go +++ b/rating_rating.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // RatingRating represents rating.rating model. type RatingRating struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -61,7 +57,7 @@ func (c *Client) CreateRatingRatings(rrs []*RatingRating) ([]int64, error) { for _, v := range rrs { vv = append(vv, v) } - return c.Create(RatingRatingModel, vv) + return c.Create(RatingRatingModel, vv, nil) } // UpdateRatingRating updates an existing rating.rating record. @@ -72,7 +68,7 @@ func (c *Client) UpdateRatingRating(rr *RatingRating) error { // UpdateRatingRatings updates existing rating.rating records. // All records (represented by ids) will be updated by rr values. func (c *Client) UpdateRatingRatings(ids []int64, rr *RatingRating) error { - return c.Update(RatingRatingModel, ids, rr) + return c.Update(RatingRatingModel, ids, rr, nil) } // DeleteRatingRating deletes an existing rating.rating record. @@ -91,10 +87,7 @@ func (c *Client) GetRatingRating(id int64) (*RatingRating, error) { if err != nil { return nil, err } - if rrs != nil && len(*rrs) > 0 { - return &((*rrs)[0]), nil - } - return nil, fmt.Errorf("id %v of rating.rating not found", id) + return &((*rrs)[0]), nil } // GetRatingRatings gets rating.rating existing records. @@ -112,10 +105,7 @@ func (c *Client) FindRatingRating(criteria *Criteria) (*RatingRating, error) { if err := c.SearchRead(RatingRatingModel, criteria, NewOptions().Limit(1), rrs); err != nil { return nil, err } - if rrs != nil && len(*rrs) > 0 { - return &((*rrs)[0]), nil - } - return nil, fmt.Errorf("rating.rating was not found with criteria %v", criteria) + return &((*rrs)[0]), nil } // FindRatingRatings finds rating.rating records by querying it @@ -131,11 +121,7 @@ func (c *Client) FindRatingRatings(criteria *Criteria, options *Options) (*Ratin // FindRatingRatingIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindRatingRatingIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(RatingRatingModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(RatingRatingModel, criteria, options) } // FindRatingRatingId finds record id by querying it with criteria. @@ -144,8 +130,5 @@ func (c *Client) FindRatingRatingId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("rating.rating was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_account_report_agedpartnerbalance.go b/report_account_report_agedpartnerbalance.go index 2f2146e5..cd2baac3 100644 --- a/report_account_report_agedpartnerbalance.go +++ b/report_account_report_agedpartnerbalance.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportAccountReportAgedpartnerbalance represents report.account.report_agedpartnerbalance model. type ReportAccountReportAgedpartnerbalance struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateReportAccountReportAgedpartnerbalances(rars []*ReportAcco for _, v := range rars { vv = append(vv, v) } - return c.Create(ReportAccountReportAgedpartnerbalanceModel, vv) + return c.Create(ReportAccountReportAgedpartnerbalanceModel, vv, nil) } // UpdateReportAccountReportAgedpartnerbalance updates an existing report.account.report_agedpartnerbalance record. @@ -51,7 +47,7 @@ func (c *Client) UpdateReportAccountReportAgedpartnerbalance(rar *ReportAccountR // UpdateReportAccountReportAgedpartnerbalances updates existing report.account.report_agedpartnerbalance records. // All records (represented by ids) will be updated by rar values. func (c *Client) UpdateReportAccountReportAgedpartnerbalances(ids []int64, rar *ReportAccountReportAgedpartnerbalance) error { - return c.Update(ReportAccountReportAgedpartnerbalanceModel, ids, rar) + return c.Update(ReportAccountReportAgedpartnerbalanceModel, ids, rar, nil) } // DeleteReportAccountReportAgedpartnerbalance deletes an existing report.account.report_agedpartnerbalance record. @@ -70,10 +66,7 @@ func (c *Client) GetReportAccountReportAgedpartnerbalance(id int64) (*ReportAcco if err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("id %v of report.account.report_agedpartnerbalance not found", id) + return &((*rars)[0]), nil } // GetReportAccountReportAgedpartnerbalances gets report.account.report_agedpartnerbalance existing records. @@ -91,10 +84,7 @@ func (c *Client) FindReportAccountReportAgedpartnerbalance(criteria *Criteria) ( if err := c.SearchRead(ReportAccountReportAgedpartnerbalanceModel, criteria, NewOptions().Limit(1), rars); err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("report.account.report_agedpartnerbalance was not found with criteria %v", criteria) + return &((*rars)[0]), nil } // FindReportAccountReportAgedpartnerbalances finds report.account.report_agedpartnerbalance records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindReportAccountReportAgedpartnerbalances(criteria *Criteria, // FindReportAccountReportAgedpartnerbalanceIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportAccountReportAgedpartnerbalanceIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportAccountReportAgedpartnerbalanceModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportAccountReportAgedpartnerbalanceModel, criteria, options) } // FindReportAccountReportAgedpartnerbalanceId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindReportAccountReportAgedpartnerbalanceId(criteria *Criteria, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.account.report_agedpartnerbalance was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_account_report_financial.go b/report_account_report_financial.go index cb04b95f..739dff8a 100644 --- a/report_account_report_financial.go +++ b/report_account_report_financial.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportAccountReportFinancial represents report.account.report_financial model. type ReportAccountReportFinancial struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateReportAccountReportFinancials(rars []*ReportAccountReport for _, v := range rars { vv = append(vv, v) } - return c.Create(ReportAccountReportFinancialModel, vv) + return c.Create(ReportAccountReportFinancialModel, vv, nil) } // UpdateReportAccountReportFinancial updates an existing report.account.report_financial record. @@ -51,7 +47,7 @@ func (c *Client) UpdateReportAccountReportFinancial(rar *ReportAccountReportFina // UpdateReportAccountReportFinancials updates existing report.account.report_financial records. // All records (represented by ids) will be updated by rar values. func (c *Client) UpdateReportAccountReportFinancials(ids []int64, rar *ReportAccountReportFinancial) error { - return c.Update(ReportAccountReportFinancialModel, ids, rar) + return c.Update(ReportAccountReportFinancialModel, ids, rar, nil) } // DeleteReportAccountReportFinancial deletes an existing report.account.report_financial record. @@ -70,10 +66,7 @@ func (c *Client) GetReportAccountReportFinancial(id int64) (*ReportAccountReport if err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("id %v of report.account.report_financial not found", id) + return &((*rars)[0]), nil } // GetReportAccountReportFinancials gets report.account.report_financial existing records. @@ -91,10 +84,7 @@ func (c *Client) FindReportAccountReportFinancial(criteria *Criteria) (*ReportAc if err := c.SearchRead(ReportAccountReportFinancialModel, criteria, NewOptions().Limit(1), rars); err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("report.account.report_financial was not found with criteria %v", criteria) + return &((*rars)[0]), nil } // FindReportAccountReportFinancials finds report.account.report_financial records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindReportAccountReportFinancials(criteria *Criteria, options * // FindReportAccountReportFinancialIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportAccountReportFinancialIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportAccountReportFinancialModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportAccountReportFinancialModel, criteria, options) } // FindReportAccountReportFinancialId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindReportAccountReportFinancialId(criteria *Criteria, options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.account.report_financial was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_account_report_generalledger.go b/report_account_report_generalledger.go index 0d84781c..61f3be76 100644 --- a/report_account_report_generalledger.go +++ b/report_account_report_generalledger.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportAccountReportGeneralledger represents report.account.report_generalledger model. type ReportAccountReportGeneralledger struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateReportAccountReportGeneralledgers(rars []*ReportAccountRe for _, v := range rars { vv = append(vv, v) } - return c.Create(ReportAccountReportGeneralledgerModel, vv) + return c.Create(ReportAccountReportGeneralledgerModel, vv, nil) } // UpdateReportAccountReportGeneralledger updates an existing report.account.report_generalledger record. @@ -51,7 +47,7 @@ func (c *Client) UpdateReportAccountReportGeneralledger(rar *ReportAccountReport // UpdateReportAccountReportGeneralledgers updates existing report.account.report_generalledger records. // All records (represented by ids) will be updated by rar values. func (c *Client) UpdateReportAccountReportGeneralledgers(ids []int64, rar *ReportAccountReportGeneralledger) error { - return c.Update(ReportAccountReportGeneralledgerModel, ids, rar) + return c.Update(ReportAccountReportGeneralledgerModel, ids, rar, nil) } // DeleteReportAccountReportGeneralledger deletes an existing report.account.report_generalledger record. @@ -70,10 +66,7 @@ func (c *Client) GetReportAccountReportGeneralledger(id int64) (*ReportAccountRe if err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("id %v of report.account.report_generalledger not found", id) + return &((*rars)[0]), nil } // GetReportAccountReportGeneralledgers gets report.account.report_generalledger existing records. @@ -91,10 +84,7 @@ func (c *Client) FindReportAccountReportGeneralledger(criteria *Criteria) (*Repo if err := c.SearchRead(ReportAccountReportGeneralledgerModel, criteria, NewOptions().Limit(1), rars); err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("report.account.report_generalledger was not found with criteria %v", criteria) + return &((*rars)[0]), nil } // FindReportAccountReportGeneralledgers finds report.account.report_generalledger records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindReportAccountReportGeneralledgers(criteria *Criteria, optio // FindReportAccountReportGeneralledgerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportAccountReportGeneralledgerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportAccountReportGeneralledgerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportAccountReportGeneralledgerModel, criteria, options) } // FindReportAccountReportGeneralledgerId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindReportAccountReportGeneralledgerId(criteria *Criteria, opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.account.report_generalledger was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_account_report_journal.go b/report_account_report_journal.go index f38fd8e5..7e0716f6 100644 --- a/report_account_report_journal.go +++ b/report_account_report_journal.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportAccountReportJournal represents report.account.report_journal model. type ReportAccountReportJournal struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateReportAccountReportJournals(rars []*ReportAccountReportJo for _, v := range rars { vv = append(vv, v) } - return c.Create(ReportAccountReportJournalModel, vv) + return c.Create(ReportAccountReportJournalModel, vv, nil) } // UpdateReportAccountReportJournal updates an existing report.account.report_journal record. @@ -51,7 +47,7 @@ func (c *Client) UpdateReportAccountReportJournal(rar *ReportAccountReportJourna // UpdateReportAccountReportJournals updates existing report.account.report_journal records. // All records (represented by ids) will be updated by rar values. func (c *Client) UpdateReportAccountReportJournals(ids []int64, rar *ReportAccountReportJournal) error { - return c.Update(ReportAccountReportJournalModel, ids, rar) + return c.Update(ReportAccountReportJournalModel, ids, rar, nil) } // DeleteReportAccountReportJournal deletes an existing report.account.report_journal record. @@ -70,10 +66,7 @@ func (c *Client) GetReportAccountReportJournal(id int64) (*ReportAccountReportJo if err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("id %v of report.account.report_journal not found", id) + return &((*rars)[0]), nil } // GetReportAccountReportJournals gets report.account.report_journal existing records. @@ -91,10 +84,7 @@ func (c *Client) FindReportAccountReportJournal(criteria *Criteria) (*ReportAcco if err := c.SearchRead(ReportAccountReportJournalModel, criteria, NewOptions().Limit(1), rars); err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("report.account.report_journal was not found with criteria %v", criteria) + return &((*rars)[0]), nil } // FindReportAccountReportJournals finds report.account.report_journal records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindReportAccountReportJournals(criteria *Criteria, options *Op // FindReportAccountReportJournalIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportAccountReportJournalIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportAccountReportJournalModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportAccountReportJournalModel, criteria, options) } // FindReportAccountReportJournalId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindReportAccountReportJournalId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.account.report_journal was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_account_report_overdue.go b/report_account_report_overdue.go index 9003e858..aa8c41da 100644 --- a/report_account_report_overdue.go +++ b/report_account_report_overdue.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportAccountReportOverdue represents report.account.report_overdue model. type ReportAccountReportOverdue struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateReportAccountReportOverdues(rars []*ReportAccountReportOv for _, v := range rars { vv = append(vv, v) } - return c.Create(ReportAccountReportOverdueModel, vv) + return c.Create(ReportAccountReportOverdueModel, vv, nil) } // UpdateReportAccountReportOverdue updates an existing report.account.report_overdue record. @@ -51,7 +47,7 @@ func (c *Client) UpdateReportAccountReportOverdue(rar *ReportAccountReportOverdu // UpdateReportAccountReportOverdues updates existing report.account.report_overdue records. // All records (represented by ids) will be updated by rar values. func (c *Client) UpdateReportAccountReportOverdues(ids []int64, rar *ReportAccountReportOverdue) error { - return c.Update(ReportAccountReportOverdueModel, ids, rar) + return c.Update(ReportAccountReportOverdueModel, ids, rar, nil) } // DeleteReportAccountReportOverdue deletes an existing report.account.report_overdue record. @@ -70,10 +66,7 @@ func (c *Client) GetReportAccountReportOverdue(id int64) (*ReportAccountReportOv if err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("id %v of report.account.report_overdue not found", id) + return &((*rars)[0]), nil } // GetReportAccountReportOverdues gets report.account.report_overdue existing records. @@ -91,10 +84,7 @@ func (c *Client) FindReportAccountReportOverdue(criteria *Criteria) (*ReportAcco if err := c.SearchRead(ReportAccountReportOverdueModel, criteria, NewOptions().Limit(1), rars); err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("report.account.report_overdue was not found with criteria %v", criteria) + return &((*rars)[0]), nil } // FindReportAccountReportOverdues finds report.account.report_overdue records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindReportAccountReportOverdues(criteria *Criteria, options *Op // FindReportAccountReportOverdueIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportAccountReportOverdueIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportAccountReportOverdueModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportAccountReportOverdueModel, criteria, options) } // FindReportAccountReportOverdueId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindReportAccountReportOverdueId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.account.report_overdue was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_account_report_partnerledger.go b/report_account_report_partnerledger.go index f67fa1b3..219b4851 100644 --- a/report_account_report_partnerledger.go +++ b/report_account_report_partnerledger.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportAccountReportPartnerledger represents report.account.report_partnerledger model. type ReportAccountReportPartnerledger struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateReportAccountReportPartnerledgers(rars []*ReportAccountRe for _, v := range rars { vv = append(vv, v) } - return c.Create(ReportAccountReportPartnerledgerModel, vv) + return c.Create(ReportAccountReportPartnerledgerModel, vv, nil) } // UpdateReportAccountReportPartnerledger updates an existing report.account.report_partnerledger record. @@ -51,7 +47,7 @@ func (c *Client) UpdateReportAccountReportPartnerledger(rar *ReportAccountReport // UpdateReportAccountReportPartnerledgers updates existing report.account.report_partnerledger records. // All records (represented by ids) will be updated by rar values. func (c *Client) UpdateReportAccountReportPartnerledgers(ids []int64, rar *ReportAccountReportPartnerledger) error { - return c.Update(ReportAccountReportPartnerledgerModel, ids, rar) + return c.Update(ReportAccountReportPartnerledgerModel, ids, rar, nil) } // DeleteReportAccountReportPartnerledger deletes an existing report.account.report_partnerledger record. @@ -70,10 +66,7 @@ func (c *Client) GetReportAccountReportPartnerledger(id int64) (*ReportAccountRe if err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("id %v of report.account.report_partnerledger not found", id) + return &((*rars)[0]), nil } // GetReportAccountReportPartnerledgers gets report.account.report_partnerledger existing records. @@ -91,10 +84,7 @@ func (c *Client) FindReportAccountReportPartnerledger(criteria *Criteria) (*Repo if err := c.SearchRead(ReportAccountReportPartnerledgerModel, criteria, NewOptions().Limit(1), rars); err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("report.account.report_partnerledger was not found with criteria %v", criteria) + return &((*rars)[0]), nil } // FindReportAccountReportPartnerledgers finds report.account.report_partnerledger records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindReportAccountReportPartnerledgers(criteria *Criteria, optio // FindReportAccountReportPartnerledgerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportAccountReportPartnerledgerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportAccountReportPartnerledgerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportAccountReportPartnerledgerModel, criteria, options) } // FindReportAccountReportPartnerledgerId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindReportAccountReportPartnerledgerId(criteria *Criteria, opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.account.report_partnerledger was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_account_report_tax.go b/report_account_report_tax.go index 5943239b..0e09c962 100644 --- a/report_account_report_tax.go +++ b/report_account_report_tax.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportAccountReportTax represents report.account.report_tax model. type ReportAccountReportTax struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateReportAccountReportTaxs(rars []*ReportAccountReportTax) ( for _, v := range rars { vv = append(vv, v) } - return c.Create(ReportAccountReportTaxModel, vv) + return c.Create(ReportAccountReportTaxModel, vv, nil) } // UpdateReportAccountReportTax updates an existing report.account.report_tax record. @@ -51,7 +47,7 @@ func (c *Client) UpdateReportAccountReportTax(rar *ReportAccountReportTax) error // UpdateReportAccountReportTaxs updates existing report.account.report_tax records. // All records (represented by ids) will be updated by rar values. func (c *Client) UpdateReportAccountReportTaxs(ids []int64, rar *ReportAccountReportTax) error { - return c.Update(ReportAccountReportTaxModel, ids, rar) + return c.Update(ReportAccountReportTaxModel, ids, rar, nil) } // DeleteReportAccountReportTax deletes an existing report.account.report_tax record. @@ -70,10 +66,7 @@ func (c *Client) GetReportAccountReportTax(id int64) (*ReportAccountReportTax, e if err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("id %v of report.account.report_tax not found", id) + return &((*rars)[0]), nil } // GetReportAccountReportTaxs gets report.account.report_tax existing records. @@ -91,10 +84,7 @@ func (c *Client) FindReportAccountReportTax(criteria *Criteria) (*ReportAccountR if err := c.SearchRead(ReportAccountReportTaxModel, criteria, NewOptions().Limit(1), rars); err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("report.account.report_tax was not found with criteria %v", criteria) + return &((*rars)[0]), nil } // FindReportAccountReportTaxs finds report.account.report_tax records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindReportAccountReportTaxs(criteria *Criteria, options *Option // FindReportAccountReportTaxIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportAccountReportTaxIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportAccountReportTaxModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportAccountReportTaxModel, criteria, options) } // FindReportAccountReportTaxId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindReportAccountReportTaxId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.account.report_tax was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_account_report_trialbalance.go b/report_account_report_trialbalance.go index 5e75a597..ba9bd57a 100644 --- a/report_account_report_trialbalance.go +++ b/report_account_report_trialbalance.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportAccountReportTrialbalance represents report.account.report_trialbalance model. type ReportAccountReportTrialbalance struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateReportAccountReportTrialbalances(rars []*ReportAccountRep for _, v := range rars { vv = append(vv, v) } - return c.Create(ReportAccountReportTrialbalanceModel, vv) + return c.Create(ReportAccountReportTrialbalanceModel, vv, nil) } // UpdateReportAccountReportTrialbalance updates an existing report.account.report_trialbalance record. @@ -51,7 +47,7 @@ func (c *Client) UpdateReportAccountReportTrialbalance(rar *ReportAccountReportT // UpdateReportAccountReportTrialbalances updates existing report.account.report_trialbalance records. // All records (represented by ids) will be updated by rar values. func (c *Client) UpdateReportAccountReportTrialbalances(ids []int64, rar *ReportAccountReportTrialbalance) error { - return c.Update(ReportAccountReportTrialbalanceModel, ids, rar) + return c.Update(ReportAccountReportTrialbalanceModel, ids, rar, nil) } // DeleteReportAccountReportTrialbalance deletes an existing report.account.report_trialbalance record. @@ -70,10 +66,7 @@ func (c *Client) GetReportAccountReportTrialbalance(id int64) (*ReportAccountRep if err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("id %v of report.account.report_trialbalance not found", id) + return &((*rars)[0]), nil } // GetReportAccountReportTrialbalances gets report.account.report_trialbalance existing records. @@ -91,10 +84,7 @@ func (c *Client) FindReportAccountReportTrialbalance(criteria *Criteria) (*Repor if err := c.SearchRead(ReportAccountReportTrialbalanceModel, criteria, NewOptions().Limit(1), rars); err != nil { return nil, err } - if rars != nil && len(*rars) > 0 { - return &((*rars)[0]), nil - } - return nil, fmt.Errorf("report.account.report_trialbalance was not found with criteria %v", criteria) + return &((*rars)[0]), nil } // FindReportAccountReportTrialbalances finds report.account.report_trialbalance records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindReportAccountReportTrialbalances(criteria *Criteria, option // FindReportAccountReportTrialbalanceIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportAccountReportTrialbalanceIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportAccountReportTrialbalanceModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportAccountReportTrialbalanceModel, criteria, options) } // FindReportAccountReportTrialbalanceId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindReportAccountReportTrialbalanceId(criteria *Criteria, optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.account.report_trialbalance was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_all_channels_sales.go b/report_all_channels_sales.go index 85cb98cb..5503a1a3 100644 --- a/report_all_channels_sales.go +++ b/report_all_channels_sales.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportAllChannelsSales represents report.all.channels.sales model. type ReportAllChannelsSales struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -55,7 +51,7 @@ func (c *Client) CreateReportAllChannelsSaless(racss []*ReportAllChannelsSales) for _, v := range racss { vv = append(vv, v) } - return c.Create(ReportAllChannelsSalesModel, vv) + return c.Create(ReportAllChannelsSalesModel, vv, nil) } // UpdateReportAllChannelsSales updates an existing report.all.channels.sales record. @@ -66,7 +62,7 @@ func (c *Client) UpdateReportAllChannelsSales(racs *ReportAllChannelsSales) erro // UpdateReportAllChannelsSaless updates existing report.all.channels.sales records. // All records (represented by ids) will be updated by racs values. func (c *Client) UpdateReportAllChannelsSaless(ids []int64, racs *ReportAllChannelsSales) error { - return c.Update(ReportAllChannelsSalesModel, ids, racs) + return c.Update(ReportAllChannelsSalesModel, ids, racs, nil) } // DeleteReportAllChannelsSales deletes an existing report.all.channels.sales record. @@ -85,10 +81,7 @@ func (c *Client) GetReportAllChannelsSales(id int64) (*ReportAllChannelsSales, e if err != nil { return nil, err } - if racss != nil && len(*racss) > 0 { - return &((*racss)[0]), nil - } - return nil, fmt.Errorf("id %v of report.all.channels.sales not found", id) + return &((*racss)[0]), nil } // GetReportAllChannelsSaless gets report.all.channels.sales existing records. @@ -106,10 +99,7 @@ func (c *Client) FindReportAllChannelsSales(criteria *Criteria) (*ReportAllChann if err := c.SearchRead(ReportAllChannelsSalesModel, criteria, NewOptions().Limit(1), racss); err != nil { return nil, err } - if racss != nil && len(*racss) > 0 { - return &((*racss)[0]), nil - } - return nil, fmt.Errorf("report.all.channels.sales was not found with criteria %v", criteria) + return &((*racss)[0]), nil } // FindReportAllChannelsSaless finds report.all.channels.sales records by querying it @@ -125,11 +115,7 @@ func (c *Client) FindReportAllChannelsSaless(criteria *Criteria, options *Option // FindReportAllChannelsSalesIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportAllChannelsSalesIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportAllChannelsSalesModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportAllChannelsSalesModel, criteria, options) } // FindReportAllChannelsSalesId finds record id by querying it with criteria. @@ -138,8 +124,5 @@ func (c *Client) FindReportAllChannelsSalesId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.all.channels.sales was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_base_report_irmodulereference.go b/report_base_report_irmodulereference.go index 520d6907..9c0017cc 100644 --- a/report_base_report_irmodulereference.go +++ b/report_base_report_irmodulereference.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportBaseReportIrmodulereference represents report.base.report_irmodulereference model. type ReportBaseReportIrmodulereference struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateReportBaseReportIrmodulereferences(rbrs []*ReportBaseRepo for _, v := range rbrs { vv = append(vv, v) } - return c.Create(ReportBaseReportIrmodulereferenceModel, vv) + return c.Create(ReportBaseReportIrmodulereferenceModel, vv, nil) } // UpdateReportBaseReportIrmodulereference updates an existing report.base.report_irmodulereference record. @@ -51,7 +47,7 @@ func (c *Client) UpdateReportBaseReportIrmodulereference(rbr *ReportBaseReportIr // UpdateReportBaseReportIrmodulereferences updates existing report.base.report_irmodulereference records. // All records (represented by ids) will be updated by rbr values. func (c *Client) UpdateReportBaseReportIrmodulereferences(ids []int64, rbr *ReportBaseReportIrmodulereference) error { - return c.Update(ReportBaseReportIrmodulereferenceModel, ids, rbr) + return c.Update(ReportBaseReportIrmodulereferenceModel, ids, rbr, nil) } // DeleteReportBaseReportIrmodulereference deletes an existing report.base.report_irmodulereference record. @@ -70,10 +66,7 @@ func (c *Client) GetReportBaseReportIrmodulereference(id int64) (*ReportBaseRepo if err != nil { return nil, err } - if rbrs != nil && len(*rbrs) > 0 { - return &((*rbrs)[0]), nil - } - return nil, fmt.Errorf("id %v of report.base.report_irmodulereference not found", id) + return &((*rbrs)[0]), nil } // GetReportBaseReportIrmodulereferences gets report.base.report_irmodulereference existing records. @@ -91,10 +84,7 @@ func (c *Client) FindReportBaseReportIrmodulereference(criteria *Criteria) (*Rep if err := c.SearchRead(ReportBaseReportIrmodulereferenceModel, criteria, NewOptions().Limit(1), rbrs); err != nil { return nil, err } - if rbrs != nil && len(*rbrs) > 0 { - return &((*rbrs)[0]), nil - } - return nil, fmt.Errorf("report.base.report_irmodulereference was not found with criteria %v", criteria) + return &((*rbrs)[0]), nil } // FindReportBaseReportIrmodulereferences finds report.base.report_irmodulereference records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindReportBaseReportIrmodulereferences(criteria *Criteria, opti // FindReportBaseReportIrmodulereferenceIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportBaseReportIrmodulereferenceIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportBaseReportIrmodulereferenceModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportBaseReportIrmodulereferenceModel, criteria, options) } // FindReportBaseReportIrmodulereferenceId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindReportBaseReportIrmodulereferenceId(criteria *Criteria, opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.base.report_irmodulereference was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_hr_holidays_report_holidayssummary.go b/report_hr_holidays_report_holidayssummary.go index 4f9695d5..5f9120d6 100644 --- a/report_hr_holidays_report_holidayssummary.go +++ b/report_hr_holidays_report_holidayssummary.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportHrHolidaysReportHolidayssummary represents report.hr_holidays.report_holidayssummary model. type ReportHrHolidaysReportHolidayssummary struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateReportHrHolidaysReportHolidayssummarys(rhrs []*ReportHrHo for _, v := range rhrs { vv = append(vv, v) } - return c.Create(ReportHrHolidaysReportHolidayssummaryModel, vv) + return c.Create(ReportHrHolidaysReportHolidayssummaryModel, vv, nil) } // UpdateReportHrHolidaysReportHolidayssummary updates an existing report.hr_holidays.report_holidayssummary record. @@ -51,7 +47,7 @@ func (c *Client) UpdateReportHrHolidaysReportHolidayssummary(rhr *ReportHrHolida // UpdateReportHrHolidaysReportHolidayssummarys updates existing report.hr_holidays.report_holidayssummary records. // All records (represented by ids) will be updated by rhr values. func (c *Client) UpdateReportHrHolidaysReportHolidayssummarys(ids []int64, rhr *ReportHrHolidaysReportHolidayssummary) error { - return c.Update(ReportHrHolidaysReportHolidayssummaryModel, ids, rhr) + return c.Update(ReportHrHolidaysReportHolidayssummaryModel, ids, rhr, nil) } // DeleteReportHrHolidaysReportHolidayssummary deletes an existing report.hr_holidays.report_holidayssummary record. @@ -70,10 +66,7 @@ func (c *Client) GetReportHrHolidaysReportHolidayssummary(id int64) (*ReportHrHo if err != nil { return nil, err } - if rhrs != nil && len(*rhrs) > 0 { - return &((*rhrs)[0]), nil - } - return nil, fmt.Errorf("id %v of report.hr_holidays.report_holidayssummary not found", id) + return &((*rhrs)[0]), nil } // GetReportHrHolidaysReportHolidayssummarys gets report.hr_holidays.report_holidayssummary existing records. @@ -91,10 +84,7 @@ func (c *Client) FindReportHrHolidaysReportHolidayssummary(criteria *Criteria) ( if err := c.SearchRead(ReportHrHolidaysReportHolidayssummaryModel, criteria, NewOptions().Limit(1), rhrs); err != nil { return nil, err } - if rhrs != nil && len(*rhrs) > 0 { - return &((*rhrs)[0]), nil - } - return nil, fmt.Errorf("report.hr_holidays.report_holidayssummary was not found with criteria %v", criteria) + return &((*rhrs)[0]), nil } // FindReportHrHolidaysReportHolidayssummarys finds report.hr_holidays.report_holidayssummary records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindReportHrHolidaysReportHolidayssummarys(criteria *Criteria, // FindReportHrHolidaysReportHolidayssummaryIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportHrHolidaysReportHolidayssummaryIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportHrHolidaysReportHolidayssummaryModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportHrHolidaysReportHolidayssummaryModel, criteria, options) } // FindReportHrHolidaysReportHolidayssummaryId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindReportHrHolidaysReportHolidayssummaryId(criteria *Criteria, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.hr_holidays.report_holidayssummary was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_paperformat.go b/report_paperformat.go index 4b8d5172..c70dbbf9 100644 --- a/report_paperformat.go +++ b/report_paperformat.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportPaperformat represents report.paperformat model. type ReportPaperformat struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -58,7 +54,7 @@ func (c *Client) CreateReportPaperformats(rps []*ReportPaperformat) ([]int64, er for _, v := range rps { vv = append(vv, v) } - return c.Create(ReportPaperformatModel, vv) + return c.Create(ReportPaperformatModel, vv, nil) } // UpdateReportPaperformat updates an existing report.paperformat record. @@ -69,7 +65,7 @@ func (c *Client) UpdateReportPaperformat(rp *ReportPaperformat) error { // UpdateReportPaperformats updates existing report.paperformat records. // All records (represented by ids) will be updated by rp values. func (c *Client) UpdateReportPaperformats(ids []int64, rp *ReportPaperformat) error { - return c.Update(ReportPaperformatModel, ids, rp) + return c.Update(ReportPaperformatModel, ids, rp, nil) } // DeleteReportPaperformat deletes an existing report.paperformat record. @@ -88,10 +84,7 @@ func (c *Client) GetReportPaperformat(id int64) (*ReportPaperformat, error) { if err != nil { return nil, err } - if rps != nil && len(*rps) > 0 { - return &((*rps)[0]), nil - } - return nil, fmt.Errorf("id %v of report.paperformat not found", id) + return &((*rps)[0]), nil } // GetReportPaperformats gets report.paperformat existing records. @@ -109,10 +102,7 @@ func (c *Client) FindReportPaperformat(criteria *Criteria) (*ReportPaperformat, if err := c.SearchRead(ReportPaperformatModel, criteria, NewOptions().Limit(1), rps); err != nil { return nil, err } - if rps != nil && len(*rps) > 0 { - return &((*rps)[0]), nil - } - return nil, fmt.Errorf("report.paperformat was not found with criteria %v", criteria) + return &((*rps)[0]), nil } // FindReportPaperformats finds report.paperformat records by querying it @@ -128,11 +118,7 @@ func (c *Client) FindReportPaperformats(criteria *Criteria, options *Options) (* // FindReportPaperformatIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportPaperformatIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportPaperformatModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportPaperformatModel, criteria, options) } // FindReportPaperformatId finds record id by querying it with criteria. @@ -141,8 +127,5 @@ func (c *Client) FindReportPaperformatId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.paperformat was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_product_report_pricelist.go b/report_product_report_pricelist.go index a6c02219..b5245177 100644 --- a/report_product_report_pricelist.go +++ b/report_product_report_pricelist.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportProductReportPricelist represents report.product.report_pricelist model. type ReportProductReportPricelist struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateReportProductReportPricelists(rprs []*ReportProductReport for _, v := range rprs { vv = append(vv, v) } - return c.Create(ReportProductReportPricelistModel, vv) + return c.Create(ReportProductReportPricelistModel, vv, nil) } // UpdateReportProductReportPricelist updates an existing report.product.report_pricelist record. @@ -51,7 +47,7 @@ func (c *Client) UpdateReportProductReportPricelist(rpr *ReportProductReportPric // UpdateReportProductReportPricelists updates existing report.product.report_pricelist records. // All records (represented by ids) will be updated by rpr values. func (c *Client) UpdateReportProductReportPricelists(ids []int64, rpr *ReportProductReportPricelist) error { - return c.Update(ReportProductReportPricelistModel, ids, rpr) + return c.Update(ReportProductReportPricelistModel, ids, rpr, nil) } // DeleteReportProductReportPricelist deletes an existing report.product.report_pricelist record. @@ -70,10 +66,7 @@ func (c *Client) GetReportProductReportPricelist(id int64) (*ReportProductReport if err != nil { return nil, err } - if rprs != nil && len(*rprs) > 0 { - return &((*rprs)[0]), nil - } - return nil, fmt.Errorf("id %v of report.product.report_pricelist not found", id) + return &((*rprs)[0]), nil } // GetReportProductReportPricelists gets report.product.report_pricelist existing records. @@ -91,10 +84,7 @@ func (c *Client) FindReportProductReportPricelist(criteria *Criteria) (*ReportPr if err := c.SearchRead(ReportProductReportPricelistModel, criteria, NewOptions().Limit(1), rprs); err != nil { return nil, err } - if rprs != nil && len(*rprs) > 0 { - return &((*rprs)[0]), nil - } - return nil, fmt.Errorf("report.product.report_pricelist was not found with criteria %v", criteria) + return &((*rprs)[0]), nil } // FindReportProductReportPricelists finds report.product.report_pricelist records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindReportProductReportPricelists(criteria *Criteria, options * // FindReportProductReportPricelistIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportProductReportPricelistIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportProductReportPricelistModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportProductReportPricelistModel, criteria, options) } // FindReportProductReportPricelistId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindReportProductReportPricelistId(criteria *Criteria, options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.product.report_pricelist was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_project_task_user.go b/report_project_task_user.go index 2cc9f5b3..5dcd6821 100644 --- a/report_project_task_user.go +++ b/report_project_task_user.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportProjectTaskUser represents report.project.task.user model. type ReportProjectTaskUser struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -62,7 +58,7 @@ func (c *Client) CreateReportProjectTaskUsers(rptus []*ReportProjectTaskUser) ([ for _, v := range rptus { vv = append(vv, v) } - return c.Create(ReportProjectTaskUserModel, vv) + return c.Create(ReportProjectTaskUserModel, vv, nil) } // UpdateReportProjectTaskUser updates an existing report.project.task.user record. @@ -73,7 +69,7 @@ func (c *Client) UpdateReportProjectTaskUser(rptu *ReportProjectTaskUser) error // UpdateReportProjectTaskUsers updates existing report.project.task.user records. // All records (represented by ids) will be updated by rptu values. func (c *Client) UpdateReportProjectTaskUsers(ids []int64, rptu *ReportProjectTaskUser) error { - return c.Update(ReportProjectTaskUserModel, ids, rptu) + return c.Update(ReportProjectTaskUserModel, ids, rptu, nil) } // DeleteReportProjectTaskUser deletes an existing report.project.task.user record. @@ -92,10 +88,7 @@ func (c *Client) GetReportProjectTaskUser(id int64) (*ReportProjectTaskUser, err if err != nil { return nil, err } - if rptus != nil && len(*rptus) > 0 { - return &((*rptus)[0]), nil - } - return nil, fmt.Errorf("id %v of report.project.task.user not found", id) + return &((*rptus)[0]), nil } // GetReportProjectTaskUsers gets report.project.task.user existing records. @@ -113,10 +106,7 @@ func (c *Client) FindReportProjectTaskUser(criteria *Criteria) (*ReportProjectTa if err := c.SearchRead(ReportProjectTaskUserModel, criteria, NewOptions().Limit(1), rptus); err != nil { return nil, err } - if rptus != nil && len(*rptus) > 0 { - return &((*rptus)[0]), nil - } - return nil, fmt.Errorf("report.project.task.user was not found with criteria %v", criteria) + return &((*rptus)[0]), nil } // FindReportProjectTaskUsers finds report.project.task.user records by querying it @@ -132,11 +122,7 @@ func (c *Client) FindReportProjectTaskUsers(criteria *Criteria, options *Options // FindReportProjectTaskUserIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportProjectTaskUserIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportProjectTaskUserModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportProjectTaskUserModel, criteria, options) } // FindReportProjectTaskUserId finds record id by querying it with criteria. @@ -145,8 +131,5 @@ func (c *Client) FindReportProjectTaskUserId(criteria *Criteria, options *Option if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.project.task.user was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_sale_report_saleproforma.go b/report_sale_report_saleproforma.go index fb30888b..d0145c45 100644 --- a/report_sale_report_saleproforma.go +++ b/report_sale_report_saleproforma.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportSaleReportSaleproforma represents report.sale.report_saleproforma model. type ReportSaleReportSaleproforma struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateReportSaleReportSaleproformas(rsrs []*ReportSaleReportSal for _, v := range rsrs { vv = append(vv, v) } - return c.Create(ReportSaleReportSaleproformaModel, vv) + return c.Create(ReportSaleReportSaleproformaModel, vv, nil) } // UpdateReportSaleReportSaleproforma updates an existing report.sale.report_saleproforma record. @@ -51,7 +47,7 @@ func (c *Client) UpdateReportSaleReportSaleproforma(rsr *ReportSaleReportSalepro // UpdateReportSaleReportSaleproformas updates existing report.sale.report_saleproforma records. // All records (represented by ids) will be updated by rsr values. func (c *Client) UpdateReportSaleReportSaleproformas(ids []int64, rsr *ReportSaleReportSaleproforma) error { - return c.Update(ReportSaleReportSaleproformaModel, ids, rsr) + return c.Update(ReportSaleReportSaleproformaModel, ids, rsr, nil) } // DeleteReportSaleReportSaleproforma deletes an existing report.sale.report_saleproforma record. @@ -70,10 +66,7 @@ func (c *Client) GetReportSaleReportSaleproforma(id int64) (*ReportSaleReportSal if err != nil { return nil, err } - if rsrs != nil && len(*rsrs) > 0 { - return &((*rsrs)[0]), nil - } - return nil, fmt.Errorf("id %v of report.sale.report_saleproforma not found", id) + return &((*rsrs)[0]), nil } // GetReportSaleReportSaleproformas gets report.sale.report_saleproforma existing records. @@ -91,10 +84,7 @@ func (c *Client) FindReportSaleReportSaleproforma(criteria *Criteria) (*ReportSa if err := c.SearchRead(ReportSaleReportSaleproformaModel, criteria, NewOptions().Limit(1), rsrs); err != nil { return nil, err } - if rsrs != nil && len(*rsrs) > 0 { - return &((*rsrs)[0]), nil - } - return nil, fmt.Errorf("report.sale.report_saleproforma was not found with criteria %v", criteria) + return &((*rsrs)[0]), nil } // FindReportSaleReportSaleproformas finds report.sale.report_saleproforma records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindReportSaleReportSaleproformas(criteria *Criteria, options * // FindReportSaleReportSaleproformaIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportSaleReportSaleproformaIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportSaleReportSaleproformaModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportSaleReportSaleproformaModel, criteria, options) } // FindReportSaleReportSaleproformaId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindReportSaleReportSaleproformaId(criteria *Criteria, options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.sale.report_saleproforma was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/report_stock_forecast.go b/report_stock_forecast.go index 08e45097..71286c27 100644 --- a/report_stock_forecast.go +++ b/report_stock_forecast.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ReportStockForecast represents report.stock.forecast model. type ReportStockForecast struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateReportStockForecasts(rsfs []*ReportStockForecast) ([]int6 for _, v := range rsfs { vv = append(vv, v) } - return c.Create(ReportStockForecastModel, vv) + return c.Create(ReportStockForecastModel, vv, nil) } // UpdateReportStockForecast updates an existing report.stock.forecast record. @@ -56,7 +52,7 @@ func (c *Client) UpdateReportStockForecast(rsf *ReportStockForecast) error { // UpdateReportStockForecasts updates existing report.stock.forecast records. // All records (represented by ids) will be updated by rsf values. func (c *Client) UpdateReportStockForecasts(ids []int64, rsf *ReportStockForecast) error { - return c.Update(ReportStockForecastModel, ids, rsf) + return c.Update(ReportStockForecastModel, ids, rsf, nil) } // DeleteReportStockForecast deletes an existing report.stock.forecast record. @@ -75,10 +71,7 @@ func (c *Client) GetReportStockForecast(id int64) (*ReportStockForecast, error) if err != nil { return nil, err } - if rsfs != nil && len(*rsfs) > 0 { - return &((*rsfs)[0]), nil - } - return nil, fmt.Errorf("id %v of report.stock.forecast not found", id) + return &((*rsfs)[0]), nil } // GetReportStockForecasts gets report.stock.forecast existing records. @@ -96,10 +89,7 @@ func (c *Client) FindReportStockForecast(criteria *Criteria) (*ReportStockForeca if err := c.SearchRead(ReportStockForecastModel, criteria, NewOptions().Limit(1), rsfs); err != nil { return nil, err } - if rsfs != nil && len(*rsfs) > 0 { - return &((*rsfs)[0]), nil - } - return nil, fmt.Errorf("report.stock.forecast was not found with criteria %v", criteria) + return &((*rsfs)[0]), nil } // FindReportStockForecasts finds report.stock.forecast records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindReportStockForecasts(criteria *Criteria, options *Options) // FindReportStockForecastIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindReportStockForecastIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ReportStockForecastModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ReportStockForecastModel, criteria, options) } // FindReportStockForecastId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindReportStockForecastId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("report.stock.forecast was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_bank.go b/res_bank.go index 133bf10c..eca86095 100644 --- a/res_bank.go +++ b/res_bank.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResBank represents res.bank model. type ResBank struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -55,7 +51,7 @@ func (c *Client) CreateResBanks(rbs []*ResBank) ([]int64, error) { for _, v := range rbs { vv = append(vv, v) } - return c.Create(ResBankModel, vv) + return c.Create(ResBankModel, vv, nil) } // UpdateResBank updates an existing res.bank record. @@ -66,7 +62,7 @@ func (c *Client) UpdateResBank(rb *ResBank) error { // UpdateResBanks updates existing res.bank records. // All records (represented by ids) will be updated by rb values. func (c *Client) UpdateResBanks(ids []int64, rb *ResBank) error { - return c.Update(ResBankModel, ids, rb) + return c.Update(ResBankModel, ids, rb, nil) } // DeleteResBank deletes an existing res.bank record. @@ -85,10 +81,7 @@ func (c *Client) GetResBank(id int64) (*ResBank, error) { if err != nil { return nil, err } - if rbs != nil && len(*rbs) > 0 { - return &((*rbs)[0]), nil - } - return nil, fmt.Errorf("id %v of res.bank not found", id) + return &((*rbs)[0]), nil } // GetResBanks gets res.bank existing records. @@ -106,10 +99,7 @@ func (c *Client) FindResBank(criteria *Criteria) (*ResBank, error) { if err := c.SearchRead(ResBankModel, criteria, NewOptions().Limit(1), rbs); err != nil { return nil, err } - if rbs != nil && len(*rbs) > 0 { - return &((*rbs)[0]), nil - } - return nil, fmt.Errorf("res.bank was not found with criteria %v", criteria) + return &((*rbs)[0]), nil } // FindResBanks finds res.bank records by querying it @@ -125,11 +115,7 @@ func (c *Client) FindResBanks(criteria *Criteria, options *Options) (*ResBanks, // FindResBankIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResBankIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResBankModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResBankModel, criteria, options) } // FindResBankId finds record id by querying it with criteria. @@ -138,8 +124,5 @@ func (c *Client) FindResBankId(criteria *Criteria, options *Options) (int64, err if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.bank was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_company.go b/res_company.go index 98383b8c..869ae0e5 100644 --- a/res_company.go +++ b/res_company.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResCompany represents res.company model. type ResCompany struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -43,6 +39,7 @@ type ResCompany struct { Id *Int `xmlrpc:"id,omptempty"` IncomeCurrencyExchangeAccountId *Many2One `xmlrpc:"income_currency_exchange_account_id,omptempty"` InternalTransitLocationId *Many2One `xmlrpc:"internal_transit_location_id,omptempty"` + Ldaps *Relation `xmlrpc:"ldaps,omptempty"` LeaveTimesheetProjectId *Many2One `xmlrpc:"leave_timesheet_project_id,omptempty"` LeaveTimesheetTaskId *Many2One `xmlrpc:"leave_timesheet_task_id,omptempty"` Logo *String `xmlrpc:"logo,omptempty"` @@ -122,7 +119,7 @@ func (c *Client) CreateResCompanys(rcs []*ResCompany) ([]int64, error) { for _, v := range rcs { vv = append(vv, v) } - return c.Create(ResCompanyModel, vv) + return c.Create(ResCompanyModel, vv, nil) } // UpdateResCompany updates an existing res.company record. @@ -133,7 +130,7 @@ func (c *Client) UpdateResCompany(rc *ResCompany) error { // UpdateResCompanys updates existing res.company records. // All records (represented by ids) will be updated by rc values. func (c *Client) UpdateResCompanys(ids []int64, rc *ResCompany) error { - return c.Update(ResCompanyModel, ids, rc) + return c.Update(ResCompanyModel, ids, rc, nil) } // DeleteResCompany deletes an existing res.company record. @@ -152,10 +149,7 @@ func (c *Client) GetResCompany(id int64) (*ResCompany, error) { if err != nil { return nil, err } - if rcs != nil && len(*rcs) > 0 { - return &((*rcs)[0]), nil - } - return nil, fmt.Errorf("id %v of res.company not found", id) + return &((*rcs)[0]), nil } // GetResCompanys gets res.company existing records. @@ -173,10 +167,7 @@ func (c *Client) FindResCompany(criteria *Criteria) (*ResCompany, error) { if err := c.SearchRead(ResCompanyModel, criteria, NewOptions().Limit(1), rcs); err != nil { return nil, err } - if rcs != nil && len(*rcs) > 0 { - return &((*rcs)[0]), nil - } - return nil, fmt.Errorf("res.company was not found with criteria %v", criteria) + return &((*rcs)[0]), nil } // FindResCompanys finds res.company records by querying it @@ -192,11 +183,7 @@ func (c *Client) FindResCompanys(criteria *Criteria, options *Options) (*ResComp // FindResCompanyIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResCompanyIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResCompanyModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResCompanyModel, criteria, options) } // FindResCompanyId finds record id by querying it with criteria. @@ -205,8 +192,5 @@ func (c *Client) FindResCompanyId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.company was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_config.go b/res_config.go index 5132e0a0..11074c60 100644 --- a/res_config.go +++ b/res_config.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResConfig represents res.config model. type ResConfig struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -44,7 +40,7 @@ func (c *Client) CreateResConfigs(rcs []*ResConfig) ([]int64, error) { for _, v := range rcs { vv = append(vv, v) } - return c.Create(ResConfigModel, vv) + return c.Create(ResConfigModel, vv, nil) } // UpdateResConfig updates an existing res.config record. @@ -55,7 +51,7 @@ func (c *Client) UpdateResConfig(rc *ResConfig) error { // UpdateResConfigs updates existing res.config records. // All records (represented by ids) will be updated by rc values. func (c *Client) UpdateResConfigs(ids []int64, rc *ResConfig) error { - return c.Update(ResConfigModel, ids, rc) + return c.Update(ResConfigModel, ids, rc, nil) } // DeleteResConfig deletes an existing res.config record. @@ -74,10 +70,7 @@ func (c *Client) GetResConfig(id int64) (*ResConfig, error) { if err != nil { return nil, err } - if rcs != nil && len(*rcs) > 0 { - return &((*rcs)[0]), nil - } - return nil, fmt.Errorf("id %v of res.config not found", id) + return &((*rcs)[0]), nil } // GetResConfigs gets res.config existing records. @@ -95,10 +88,7 @@ func (c *Client) FindResConfig(criteria *Criteria) (*ResConfig, error) { if err := c.SearchRead(ResConfigModel, criteria, NewOptions().Limit(1), rcs); err != nil { return nil, err } - if rcs != nil && len(*rcs) > 0 { - return &((*rcs)[0]), nil - } - return nil, fmt.Errorf("res.config was not found with criteria %v", criteria) + return &((*rcs)[0]), nil } // FindResConfigs finds res.config records by querying it @@ -114,11 +104,7 @@ func (c *Client) FindResConfigs(criteria *Criteria, options *Options) (*ResConfi // FindResConfigIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResConfigIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResConfigModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResConfigModel, criteria, options) } // FindResConfigId finds record id by querying it with criteria. @@ -127,8 +113,5 @@ func (c *Client) FindResConfigId(criteria *Criteria, options *Options) (int64, e if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.config was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_config_installer.go b/res_config_installer.go index b5e7cb79..c31417ab 100644 --- a/res_config_installer.go +++ b/res_config_installer.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResConfigInstaller represents res.config.installer model. type ResConfigInstaller struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -44,7 +40,7 @@ func (c *Client) CreateResConfigInstallers(rcis []*ResConfigInstaller) ([]int64, for _, v := range rcis { vv = append(vv, v) } - return c.Create(ResConfigInstallerModel, vv) + return c.Create(ResConfigInstallerModel, vv, nil) } // UpdateResConfigInstaller updates an existing res.config.installer record. @@ -55,7 +51,7 @@ func (c *Client) UpdateResConfigInstaller(rci *ResConfigInstaller) error { // UpdateResConfigInstallers updates existing res.config.installer records. // All records (represented by ids) will be updated by rci values. func (c *Client) UpdateResConfigInstallers(ids []int64, rci *ResConfigInstaller) error { - return c.Update(ResConfigInstallerModel, ids, rci) + return c.Update(ResConfigInstallerModel, ids, rci, nil) } // DeleteResConfigInstaller deletes an existing res.config.installer record. @@ -74,10 +70,7 @@ func (c *Client) GetResConfigInstaller(id int64) (*ResConfigInstaller, error) { if err != nil { return nil, err } - if rcis != nil && len(*rcis) > 0 { - return &((*rcis)[0]), nil - } - return nil, fmt.Errorf("id %v of res.config.installer not found", id) + return &((*rcis)[0]), nil } // GetResConfigInstallers gets res.config.installer existing records. @@ -95,10 +88,7 @@ func (c *Client) FindResConfigInstaller(criteria *Criteria) (*ResConfigInstaller if err := c.SearchRead(ResConfigInstallerModel, criteria, NewOptions().Limit(1), rcis); err != nil { return nil, err } - if rcis != nil && len(*rcis) > 0 { - return &((*rcis)[0]), nil - } - return nil, fmt.Errorf("res.config.installer was not found with criteria %v", criteria) + return &((*rcis)[0]), nil } // FindResConfigInstallers finds res.config.installer records by querying it @@ -114,11 +104,7 @@ func (c *Client) FindResConfigInstallers(criteria *Criteria, options *Options) ( // FindResConfigInstallerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResConfigInstallerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResConfigInstallerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResConfigInstallerModel, criteria, options) } // FindResConfigInstallerId finds record id by querying it with criteria. @@ -127,8 +113,5 @@ func (c *Client) FindResConfigInstallerId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.config.installer was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_config_settings.go b/res_config_settings.go index 41c98568..b6fe20c0 100644 --- a/res_config_settings.go +++ b/res_config_settings.go @@ -1,16 +1,10 @@ package odoo -import ( - "fmt" -) - // ResConfigSettings represents res.config.settings model. type ResConfigSettings struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` AccountHideSetupBar *Bool `xmlrpc:"account_hide_setup_bar,omptempty"` AliasDomain *String `xmlrpc:"alias_domain,omptempty"` - AuthSignupResetPassword *Bool `xmlrpc:"auth_signup_reset_password,omptempty"` - AuthSignupTemplateUserId *Many2One `xmlrpc:"auth_signup_template_user_id,omptempty"` AuthSignupUninvited *Selection `xmlrpc:"auth_signup_uninvited,omptempty"` AutoDoneSetting *Bool `xmlrpc:"auto_done_setting,omptempty"` ChartTemplateId *Many2One `xmlrpc:"chart_template_id,omptempty"` @@ -74,6 +68,7 @@ type ResConfigSettings struct { HasChartOfAccounts *Bool `xmlrpc:"has_chart_of_accounts,omptempty"` Id *Int `xmlrpc:"id,omptempty"` IsInstalledSale *Bool `xmlrpc:"is_installed_sale,omptempty"` + Ldaps *Relation `xmlrpc:"ldaps,omptempty"` LeaveTimesheetProjectId *Many2One `xmlrpc:"leave_timesheet_project_id,omptempty"` LeaveTimesheetTaskId *Many2One `xmlrpc:"leave_timesheet_task_id,omptempty"` LockConfirmedPo *Bool `xmlrpc:"lock_confirmed_po,omptempty"` @@ -198,7 +193,7 @@ func (c *Client) CreateResConfigSettingss(rcss []*ResConfigSettings) ([]int64, e for _, v := range rcss { vv = append(vv, v) } - return c.Create(ResConfigSettingsModel, vv) + return c.Create(ResConfigSettingsModel, vv, nil) } // UpdateResConfigSettings updates an existing res.config.settings record. @@ -209,7 +204,7 @@ func (c *Client) UpdateResConfigSettings(rcs *ResConfigSettings) error { // UpdateResConfigSettingss updates existing res.config.settings records. // All records (represented by ids) will be updated by rcs values. func (c *Client) UpdateResConfigSettingss(ids []int64, rcs *ResConfigSettings) error { - return c.Update(ResConfigSettingsModel, ids, rcs) + return c.Update(ResConfigSettingsModel, ids, rcs, nil) } // DeleteResConfigSettings deletes an existing res.config.settings record. @@ -228,10 +223,7 @@ func (c *Client) GetResConfigSettings(id int64) (*ResConfigSettings, error) { if err != nil { return nil, err } - if rcss != nil && len(*rcss) > 0 { - return &((*rcss)[0]), nil - } - return nil, fmt.Errorf("id %v of res.config.settings not found", id) + return &((*rcss)[0]), nil } // GetResConfigSettingss gets res.config.settings existing records. @@ -249,10 +241,7 @@ func (c *Client) FindResConfigSettings(criteria *Criteria) (*ResConfigSettings, if err := c.SearchRead(ResConfigSettingsModel, criteria, NewOptions().Limit(1), rcss); err != nil { return nil, err } - if rcss != nil && len(*rcss) > 0 { - return &((*rcss)[0]), nil - } - return nil, fmt.Errorf("res.config.settings was not found with criteria %v", criteria) + return &((*rcss)[0]), nil } // FindResConfigSettingss finds res.config.settings records by querying it @@ -268,11 +257,7 @@ func (c *Client) FindResConfigSettingss(criteria *Criteria, options *Options) (* // FindResConfigSettingsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResConfigSettingsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResConfigSettingsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResConfigSettingsModel, criteria, options) } // FindResConfigSettingsId finds record id by querying it with criteria. @@ -281,8 +266,5 @@ func (c *Client) FindResConfigSettingsId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.config.settings was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_country.go b/res_country.go index 02b3da2f..1290e82c 100644 --- a/res_country.go +++ b/res_country.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResCountry represents res.country model. type ResCountry struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -55,7 +51,7 @@ func (c *Client) CreateResCountrys(rcs []*ResCountry) ([]int64, error) { for _, v := range rcs { vv = append(vv, v) } - return c.Create(ResCountryModel, vv) + return c.Create(ResCountryModel, vv, nil) } // UpdateResCountry updates an existing res.country record. @@ -66,7 +62,7 @@ func (c *Client) UpdateResCountry(rc *ResCountry) error { // UpdateResCountrys updates existing res.country records. // All records (represented by ids) will be updated by rc values. func (c *Client) UpdateResCountrys(ids []int64, rc *ResCountry) error { - return c.Update(ResCountryModel, ids, rc) + return c.Update(ResCountryModel, ids, rc, nil) } // DeleteResCountry deletes an existing res.country record. @@ -85,10 +81,7 @@ func (c *Client) GetResCountry(id int64) (*ResCountry, error) { if err != nil { return nil, err } - if rcs != nil && len(*rcs) > 0 { - return &((*rcs)[0]), nil - } - return nil, fmt.Errorf("id %v of res.country not found", id) + return &((*rcs)[0]), nil } // GetResCountrys gets res.country existing records. @@ -106,10 +99,7 @@ func (c *Client) FindResCountry(criteria *Criteria) (*ResCountry, error) { if err := c.SearchRead(ResCountryModel, criteria, NewOptions().Limit(1), rcs); err != nil { return nil, err } - if rcs != nil && len(*rcs) > 0 { - return &((*rcs)[0]), nil - } - return nil, fmt.Errorf("res.country was not found with criteria %v", criteria) + return &((*rcs)[0]), nil } // FindResCountrys finds res.country records by querying it @@ -125,11 +115,7 @@ func (c *Client) FindResCountrys(criteria *Criteria, options *Options) (*ResCoun // FindResCountryIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResCountryIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResCountryModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResCountryModel, criteria, options) } // FindResCountryId finds record id by querying it with criteria. @@ -138,8 +124,5 @@ func (c *Client) FindResCountryId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.country was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_country_group.go b/res_country_group.go index 42ba8249..da6588bf 100644 --- a/res_country_group.go +++ b/res_country_group.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResCountryGroup represents res.country.group model. type ResCountryGroup struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateResCountryGroups(rcgs []*ResCountryGroup) ([]int64, error for _, v := range rcgs { vv = append(vv, v) } - return c.Create(ResCountryGroupModel, vv) + return c.Create(ResCountryGroupModel, vv, nil) } // UpdateResCountryGroup updates an existing res.country.group record. @@ -58,7 +54,7 @@ func (c *Client) UpdateResCountryGroup(rcg *ResCountryGroup) error { // UpdateResCountryGroups updates existing res.country.group records. // All records (represented by ids) will be updated by rcg values. func (c *Client) UpdateResCountryGroups(ids []int64, rcg *ResCountryGroup) error { - return c.Update(ResCountryGroupModel, ids, rcg) + return c.Update(ResCountryGroupModel, ids, rcg, nil) } // DeleteResCountryGroup deletes an existing res.country.group record. @@ -77,10 +73,7 @@ func (c *Client) GetResCountryGroup(id int64) (*ResCountryGroup, error) { if err != nil { return nil, err } - if rcgs != nil && len(*rcgs) > 0 { - return &((*rcgs)[0]), nil - } - return nil, fmt.Errorf("id %v of res.country.group not found", id) + return &((*rcgs)[0]), nil } // GetResCountryGroups gets res.country.group existing records. @@ -98,10 +91,7 @@ func (c *Client) FindResCountryGroup(criteria *Criteria) (*ResCountryGroup, erro if err := c.SearchRead(ResCountryGroupModel, criteria, NewOptions().Limit(1), rcgs); err != nil { return nil, err } - if rcgs != nil && len(*rcgs) > 0 { - return &((*rcgs)[0]), nil - } - return nil, fmt.Errorf("res.country.group was not found with criteria %v", criteria) + return &((*rcgs)[0]), nil } // FindResCountryGroups finds res.country.group records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindResCountryGroups(criteria *Criteria, options *Options) (*Re // FindResCountryGroupIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResCountryGroupIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResCountryGroupModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResCountryGroupModel, criteria, options) } // FindResCountryGroupId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindResCountryGroupId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.country.group was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_country_state.go b/res_country_state.go index 1598eb46..ff07b447 100644 --- a/res_country_state.go +++ b/res_country_state.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResCountryState represents res.country.state model. type ResCountryState struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateResCountryStates(rcss []*ResCountryState) ([]int64, error for _, v := range rcss { vv = append(vv, v) } - return c.Create(ResCountryStateModel, vv) + return c.Create(ResCountryStateModel, vv, nil) } // UpdateResCountryState updates an existing res.country.state record. @@ -58,7 +54,7 @@ func (c *Client) UpdateResCountryState(rcs *ResCountryState) error { // UpdateResCountryStates updates existing res.country.state records. // All records (represented by ids) will be updated by rcs values. func (c *Client) UpdateResCountryStates(ids []int64, rcs *ResCountryState) error { - return c.Update(ResCountryStateModel, ids, rcs) + return c.Update(ResCountryStateModel, ids, rcs, nil) } // DeleteResCountryState deletes an existing res.country.state record. @@ -77,10 +73,7 @@ func (c *Client) GetResCountryState(id int64) (*ResCountryState, error) { if err != nil { return nil, err } - if rcss != nil && len(*rcss) > 0 { - return &((*rcss)[0]), nil - } - return nil, fmt.Errorf("id %v of res.country.state not found", id) + return &((*rcss)[0]), nil } // GetResCountryStates gets res.country.state existing records. @@ -98,10 +91,7 @@ func (c *Client) FindResCountryState(criteria *Criteria) (*ResCountryState, erro if err := c.SearchRead(ResCountryStateModel, criteria, NewOptions().Limit(1), rcss); err != nil { return nil, err } - if rcss != nil && len(*rcss) > 0 { - return &((*rcss)[0]), nil - } - return nil, fmt.Errorf("res.country.state was not found with criteria %v", criteria) + return &((*rcss)[0]), nil } // FindResCountryStates finds res.country.state records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindResCountryStates(criteria *Criteria, options *Options) (*Re // FindResCountryStateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResCountryStateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResCountryStateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResCountryStateModel, criteria, options) } // FindResCountryStateId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindResCountryStateId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.country.state was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_currency.go b/res_currency.go index 0fd49385..7ad3825b 100644 --- a/res_currency.go +++ b/res_currency.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResCurrency represents res.currency model. type ResCurrency struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -55,7 +51,7 @@ func (c *Client) CreateResCurrencys(rcs []*ResCurrency) ([]int64, error) { for _, v := range rcs { vv = append(vv, v) } - return c.Create(ResCurrencyModel, vv) + return c.Create(ResCurrencyModel, vv, nil) } // UpdateResCurrency updates an existing res.currency record. @@ -66,7 +62,7 @@ func (c *Client) UpdateResCurrency(rc *ResCurrency) error { // UpdateResCurrencys updates existing res.currency records. // All records (represented by ids) will be updated by rc values. func (c *Client) UpdateResCurrencys(ids []int64, rc *ResCurrency) error { - return c.Update(ResCurrencyModel, ids, rc) + return c.Update(ResCurrencyModel, ids, rc, nil) } // DeleteResCurrency deletes an existing res.currency record. @@ -85,10 +81,7 @@ func (c *Client) GetResCurrency(id int64) (*ResCurrency, error) { if err != nil { return nil, err } - if rcs != nil && len(*rcs) > 0 { - return &((*rcs)[0]), nil - } - return nil, fmt.Errorf("id %v of res.currency not found", id) + return &((*rcs)[0]), nil } // GetResCurrencys gets res.currency existing records. @@ -106,10 +99,7 @@ func (c *Client) FindResCurrency(criteria *Criteria) (*ResCurrency, error) { if err := c.SearchRead(ResCurrencyModel, criteria, NewOptions().Limit(1), rcs); err != nil { return nil, err } - if rcs != nil && len(*rcs) > 0 { - return &((*rcs)[0]), nil - } - return nil, fmt.Errorf("res.currency was not found with criteria %v", criteria) + return &((*rcs)[0]), nil } // FindResCurrencys finds res.currency records by querying it @@ -125,11 +115,7 @@ func (c *Client) FindResCurrencys(criteria *Criteria, options *Options) (*ResCur // FindResCurrencyIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResCurrencyIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResCurrencyModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResCurrencyModel, criteria, options) } // FindResCurrencyId finds record id by querying it with criteria. @@ -138,8 +124,5 @@ func (c *Client) FindResCurrencyId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.currency was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_currency_rate.go b/res_currency_rate.go index d3126510..52a92f31 100644 --- a/res_currency_rate.go +++ b/res_currency_rate.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResCurrencyRate represents res.currency.rate model. type ResCurrencyRate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateResCurrencyRates(rcrs []*ResCurrencyRate) ([]int64, error for _, v := range rcrs { vv = append(vv, v) } - return c.Create(ResCurrencyRateModel, vv) + return c.Create(ResCurrencyRateModel, vv, nil) } // UpdateResCurrencyRate updates an existing res.currency.rate record. @@ -59,7 +55,7 @@ func (c *Client) UpdateResCurrencyRate(rcr *ResCurrencyRate) error { // UpdateResCurrencyRates updates existing res.currency.rate records. // All records (represented by ids) will be updated by rcr values. func (c *Client) UpdateResCurrencyRates(ids []int64, rcr *ResCurrencyRate) error { - return c.Update(ResCurrencyRateModel, ids, rcr) + return c.Update(ResCurrencyRateModel, ids, rcr, nil) } // DeleteResCurrencyRate deletes an existing res.currency.rate record. @@ -78,10 +74,7 @@ func (c *Client) GetResCurrencyRate(id int64) (*ResCurrencyRate, error) { if err != nil { return nil, err } - if rcrs != nil && len(*rcrs) > 0 { - return &((*rcrs)[0]), nil - } - return nil, fmt.Errorf("id %v of res.currency.rate not found", id) + return &((*rcrs)[0]), nil } // GetResCurrencyRates gets res.currency.rate existing records. @@ -99,10 +92,7 @@ func (c *Client) FindResCurrencyRate(criteria *Criteria) (*ResCurrencyRate, erro if err := c.SearchRead(ResCurrencyRateModel, criteria, NewOptions().Limit(1), rcrs); err != nil { return nil, err } - if rcrs != nil && len(*rcrs) > 0 { - return &((*rcrs)[0]), nil - } - return nil, fmt.Errorf("res.currency.rate was not found with criteria %v", criteria) + return &((*rcrs)[0]), nil } // FindResCurrencyRates finds res.currency.rate records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindResCurrencyRates(criteria *Criteria, options *Options) (*Re // FindResCurrencyRateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResCurrencyRateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResCurrencyRateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResCurrencyRateModel, criteria, options) } // FindResCurrencyRateId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindResCurrencyRateId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.currency.rate was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_groups.go b/res_groups.go index 0df635c6..e11d7637 100644 --- a/res_groups.go +++ b/res_groups.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResGroups represents res.groups model. type ResGroups struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -58,7 +54,7 @@ func (c *Client) CreateResGroupss(rgs []*ResGroups) ([]int64, error) { for _, v := range rgs { vv = append(vv, v) } - return c.Create(ResGroupsModel, vv) + return c.Create(ResGroupsModel, vv, nil) } // UpdateResGroups updates an existing res.groups record. @@ -69,7 +65,7 @@ func (c *Client) UpdateResGroups(rg *ResGroups) error { // UpdateResGroupss updates existing res.groups records. // All records (represented by ids) will be updated by rg values. func (c *Client) UpdateResGroupss(ids []int64, rg *ResGroups) error { - return c.Update(ResGroupsModel, ids, rg) + return c.Update(ResGroupsModel, ids, rg, nil) } // DeleteResGroups deletes an existing res.groups record. @@ -88,10 +84,7 @@ func (c *Client) GetResGroups(id int64) (*ResGroups, error) { if err != nil { return nil, err } - if rgs != nil && len(*rgs) > 0 { - return &((*rgs)[0]), nil - } - return nil, fmt.Errorf("id %v of res.groups not found", id) + return &((*rgs)[0]), nil } // GetResGroupss gets res.groups existing records. @@ -109,10 +102,7 @@ func (c *Client) FindResGroups(criteria *Criteria) (*ResGroups, error) { if err := c.SearchRead(ResGroupsModel, criteria, NewOptions().Limit(1), rgs); err != nil { return nil, err } - if rgs != nil && len(*rgs) > 0 { - return &((*rgs)[0]), nil - } - return nil, fmt.Errorf("res.groups was not found with criteria %v", criteria) + return &((*rgs)[0]), nil } // FindResGroupss finds res.groups records by querying it @@ -128,11 +118,7 @@ func (c *Client) FindResGroupss(criteria *Criteria, options *Options) (*ResGroup // FindResGroupsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResGroupsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResGroupsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResGroupsModel, criteria, options) } // FindResGroupsId finds record id by querying it with criteria. @@ -141,8 +127,5 @@ func (c *Client) FindResGroupsId(criteria *Criteria, options *Options) (int64, e if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.groups was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_lang.go b/res_lang.go index 499a9ebb..fc460b90 100644 --- a/res_lang.go +++ b/res_lang.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResLang represents res.lang model. type ResLang struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -55,7 +51,7 @@ func (c *Client) CreateResLangs(rls []*ResLang) ([]int64, error) { for _, v := range rls { vv = append(vv, v) } - return c.Create(ResLangModel, vv) + return c.Create(ResLangModel, vv, nil) } // UpdateResLang updates an existing res.lang record. @@ -66,7 +62,7 @@ func (c *Client) UpdateResLang(rl *ResLang) error { // UpdateResLangs updates existing res.lang records. // All records (represented by ids) will be updated by rl values. func (c *Client) UpdateResLangs(ids []int64, rl *ResLang) error { - return c.Update(ResLangModel, ids, rl) + return c.Update(ResLangModel, ids, rl, nil) } // DeleteResLang deletes an existing res.lang record. @@ -85,10 +81,7 @@ func (c *Client) GetResLang(id int64) (*ResLang, error) { if err != nil { return nil, err } - if rls != nil && len(*rls) > 0 { - return &((*rls)[0]), nil - } - return nil, fmt.Errorf("id %v of res.lang not found", id) + return &((*rls)[0]), nil } // GetResLangs gets res.lang existing records. @@ -106,10 +99,7 @@ func (c *Client) FindResLang(criteria *Criteria) (*ResLang, error) { if err := c.SearchRead(ResLangModel, criteria, NewOptions().Limit(1), rls); err != nil { return nil, err } - if rls != nil && len(*rls) > 0 { - return &((*rls)[0]), nil - } - return nil, fmt.Errorf("res.lang was not found with criteria %v", criteria) + return &((*rls)[0]), nil } // FindResLangs finds res.lang records by querying it @@ -125,11 +115,7 @@ func (c *Client) FindResLangs(criteria *Criteria, options *Options) (*ResLangs, // FindResLangIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResLangIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResLangModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResLangModel, criteria, options) } // FindResLangId finds record id by querying it with criteria. @@ -138,8 +124,5 @@ func (c *Client) FindResLangId(criteria *Criteria, options *Options) (int64, err if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.lang was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_partner.go b/res_partner.go index ae6288b2..2002ba4a 100644 --- a/res_partner.go +++ b/res_partner.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResPartner represents res.partner model. type ResPartner struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -62,6 +58,7 @@ type ResPartner struct { JournalItemCount *Int `xmlrpc:"journal_item_count,omptempty"` Lang *Selection `xmlrpc:"lang,omptempty"` LastTimeEntriesChecked *Time `xmlrpc:"last_time_entries_checked,omptempty"` + MachineCompanyName *String `xmlrpc:"machine_company_name,omptempty"` MachineOrganizationName *String `xmlrpc:"machine_organization_name,omptempty"` MeetingCount *Int `xmlrpc:"meeting_count,omptempty"` MeetingIds *Relation `xmlrpc:"meeting_ids,omptempty"` @@ -109,11 +106,6 @@ type ResPartner struct { SaleWarn *Selection `xmlrpc:"sale_warn,omptempty"` SaleWarnMsg *String `xmlrpc:"sale_warn_msg,omptempty"` Self *Many2One `xmlrpc:"self,omptempty"` - SignupExpiration *Time `xmlrpc:"signup_expiration,omptempty"` - SignupToken *String `xmlrpc:"signup_token,omptempty"` - SignupType *String `xmlrpc:"signup_type,omptempty"` - SignupUrl *String `xmlrpc:"signup_url,omptempty"` - SignupValid *Bool `xmlrpc:"signup_valid,omptempty"` Siret *String `xmlrpc:"siret,omptempty"` StateId *Many2One `xmlrpc:"state_id,omptempty"` Street *String `xmlrpc:"street,omptempty"` @@ -168,7 +160,7 @@ func (c *Client) CreateResPartners(rps []*ResPartner) ([]int64, error) { for _, v := range rps { vv = append(vv, v) } - return c.Create(ResPartnerModel, vv) + return c.Create(ResPartnerModel, vv, nil) } // UpdateResPartner updates an existing res.partner record. @@ -179,7 +171,7 @@ func (c *Client) UpdateResPartner(rp *ResPartner) error { // UpdateResPartners updates existing res.partner records. // All records (represented by ids) will be updated by rp values. func (c *Client) UpdateResPartners(ids []int64, rp *ResPartner) error { - return c.Update(ResPartnerModel, ids, rp) + return c.Update(ResPartnerModel, ids, rp, nil) } // DeleteResPartner deletes an existing res.partner record. @@ -198,10 +190,7 @@ func (c *Client) GetResPartner(id int64) (*ResPartner, error) { if err != nil { return nil, err } - if rps != nil && len(*rps) > 0 { - return &((*rps)[0]), nil - } - return nil, fmt.Errorf("id %v of res.partner not found", id) + return &((*rps)[0]), nil } // GetResPartners gets res.partner existing records. @@ -219,10 +208,7 @@ func (c *Client) FindResPartner(criteria *Criteria) (*ResPartner, error) { if err := c.SearchRead(ResPartnerModel, criteria, NewOptions().Limit(1), rps); err != nil { return nil, err } - if rps != nil && len(*rps) > 0 { - return &((*rps)[0]), nil - } - return nil, fmt.Errorf("res.partner was not found with criteria %v", criteria) + return &((*rps)[0]), nil } // FindResPartners finds res.partner records by querying it @@ -238,11 +224,7 @@ func (c *Client) FindResPartners(criteria *Criteria, options *Options) (*ResPart // FindResPartnerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResPartnerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResPartnerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResPartnerModel, criteria, options) } // FindResPartnerId finds record id by querying it with criteria. @@ -251,8 +233,5 @@ func (c *Client) FindResPartnerId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.partner was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_partner_bank.go b/res_partner_bank.go index 5972ec9d..5db7a100 100644 --- a/res_partner_bank.go +++ b/res_partner_bank.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResPartnerBank represents res.partner.bank model. type ResPartnerBank struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -55,7 +51,7 @@ func (c *Client) CreateResPartnerBanks(rpbs []*ResPartnerBank) ([]int64, error) for _, v := range rpbs { vv = append(vv, v) } - return c.Create(ResPartnerBankModel, vv) + return c.Create(ResPartnerBankModel, vv, nil) } // UpdateResPartnerBank updates an existing res.partner.bank record. @@ -66,7 +62,7 @@ func (c *Client) UpdateResPartnerBank(rpb *ResPartnerBank) error { // UpdateResPartnerBanks updates existing res.partner.bank records. // All records (represented by ids) will be updated by rpb values. func (c *Client) UpdateResPartnerBanks(ids []int64, rpb *ResPartnerBank) error { - return c.Update(ResPartnerBankModel, ids, rpb) + return c.Update(ResPartnerBankModel, ids, rpb, nil) } // DeleteResPartnerBank deletes an existing res.partner.bank record. @@ -85,10 +81,7 @@ func (c *Client) GetResPartnerBank(id int64) (*ResPartnerBank, error) { if err != nil { return nil, err } - if rpbs != nil && len(*rpbs) > 0 { - return &((*rpbs)[0]), nil - } - return nil, fmt.Errorf("id %v of res.partner.bank not found", id) + return &((*rpbs)[0]), nil } // GetResPartnerBanks gets res.partner.bank existing records. @@ -106,10 +99,7 @@ func (c *Client) FindResPartnerBank(criteria *Criteria) (*ResPartnerBank, error) if err := c.SearchRead(ResPartnerBankModel, criteria, NewOptions().Limit(1), rpbs); err != nil { return nil, err } - if rpbs != nil && len(*rpbs) > 0 { - return &((*rpbs)[0]), nil - } - return nil, fmt.Errorf("res.partner.bank was not found with criteria %v", criteria) + return &((*rpbs)[0]), nil } // FindResPartnerBanks finds res.partner.bank records by querying it @@ -125,11 +115,7 @@ func (c *Client) FindResPartnerBanks(criteria *Criteria, options *Options) (*Res // FindResPartnerBankIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResPartnerBankIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResPartnerBankModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResPartnerBankModel, criteria, options) } // FindResPartnerBankId finds record id by querying it with criteria. @@ -138,8 +124,5 @@ func (c *Client) FindResPartnerBankId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.partner.bank was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_partner_category.go b/res_partner_category.go index 0588e2fd..a9b16195 100644 --- a/res_partner_category.go +++ b/res_partner_category.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResPartnerCategory represents res.partner.category model. type ResPartnerCategory struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -52,7 +48,7 @@ func (c *Client) CreateResPartnerCategorys(rpcs []*ResPartnerCategory) ([]int64, for _, v := range rpcs { vv = append(vv, v) } - return c.Create(ResPartnerCategoryModel, vv) + return c.Create(ResPartnerCategoryModel, vv, nil) } // UpdateResPartnerCategory updates an existing res.partner.category record. @@ -63,7 +59,7 @@ func (c *Client) UpdateResPartnerCategory(rpc *ResPartnerCategory) error { // UpdateResPartnerCategorys updates existing res.partner.category records. // All records (represented by ids) will be updated by rpc values. func (c *Client) UpdateResPartnerCategorys(ids []int64, rpc *ResPartnerCategory) error { - return c.Update(ResPartnerCategoryModel, ids, rpc) + return c.Update(ResPartnerCategoryModel, ids, rpc, nil) } // DeleteResPartnerCategory deletes an existing res.partner.category record. @@ -82,10 +78,7 @@ func (c *Client) GetResPartnerCategory(id int64) (*ResPartnerCategory, error) { if err != nil { return nil, err } - if rpcs != nil && len(*rpcs) > 0 { - return &((*rpcs)[0]), nil - } - return nil, fmt.Errorf("id %v of res.partner.category not found", id) + return &((*rpcs)[0]), nil } // GetResPartnerCategorys gets res.partner.category existing records. @@ -103,10 +96,7 @@ func (c *Client) FindResPartnerCategory(criteria *Criteria) (*ResPartnerCategory if err := c.SearchRead(ResPartnerCategoryModel, criteria, NewOptions().Limit(1), rpcs); err != nil { return nil, err } - if rpcs != nil && len(*rpcs) > 0 { - return &((*rpcs)[0]), nil - } - return nil, fmt.Errorf("res.partner.category was not found with criteria %v", criteria) + return &((*rpcs)[0]), nil } // FindResPartnerCategorys finds res.partner.category records by querying it @@ -122,11 +112,7 @@ func (c *Client) FindResPartnerCategorys(criteria *Criteria, options *Options) ( // FindResPartnerCategoryIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResPartnerCategoryIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResPartnerCategoryModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResPartnerCategoryModel, criteria, options) } // FindResPartnerCategoryId finds record id by querying it with criteria. @@ -135,8 +121,5 @@ func (c *Client) FindResPartnerCategoryId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.partner.category was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_partner_industry.go b/res_partner_industry.go index 708b281c..c1f1af52 100644 --- a/res_partner_industry.go +++ b/res_partner_industry.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResPartnerIndustry represents res.partner.industry model. type ResPartnerIndustry struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateResPartnerIndustrys(rpis []*ResPartnerIndustry) ([]int64, for _, v := range rpis { vv = append(vv, v) } - return c.Create(ResPartnerIndustryModel, vv) + return c.Create(ResPartnerIndustryModel, vv, nil) } // UpdateResPartnerIndustry updates an existing res.partner.industry record. @@ -58,7 +54,7 @@ func (c *Client) UpdateResPartnerIndustry(rpi *ResPartnerIndustry) error { // UpdateResPartnerIndustrys updates existing res.partner.industry records. // All records (represented by ids) will be updated by rpi values. func (c *Client) UpdateResPartnerIndustrys(ids []int64, rpi *ResPartnerIndustry) error { - return c.Update(ResPartnerIndustryModel, ids, rpi) + return c.Update(ResPartnerIndustryModel, ids, rpi, nil) } // DeleteResPartnerIndustry deletes an existing res.partner.industry record. @@ -77,10 +73,7 @@ func (c *Client) GetResPartnerIndustry(id int64) (*ResPartnerIndustry, error) { if err != nil { return nil, err } - if rpis != nil && len(*rpis) > 0 { - return &((*rpis)[0]), nil - } - return nil, fmt.Errorf("id %v of res.partner.industry not found", id) + return &((*rpis)[0]), nil } // GetResPartnerIndustrys gets res.partner.industry existing records. @@ -98,10 +91,7 @@ func (c *Client) FindResPartnerIndustry(criteria *Criteria) (*ResPartnerIndustry if err := c.SearchRead(ResPartnerIndustryModel, criteria, NewOptions().Limit(1), rpis); err != nil { return nil, err } - if rpis != nil && len(*rpis) > 0 { - return &((*rpis)[0]), nil - } - return nil, fmt.Errorf("res.partner.industry was not found with criteria %v", criteria) + return &((*rpis)[0]), nil } // FindResPartnerIndustrys finds res.partner.industry records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindResPartnerIndustrys(criteria *Criteria, options *Options) ( // FindResPartnerIndustryIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResPartnerIndustryIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResPartnerIndustryModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResPartnerIndustryModel, criteria, options) } // FindResPartnerIndustryId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindResPartnerIndustryId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.partner.industry was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_partner_title.go b/res_partner_title.go index 1b6c3ea0..9ddb9f6d 100644 --- a/res_partner_title.go +++ b/res_partner_title.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResPartnerTitle represents res.partner.title model. type ResPartnerTitle struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateResPartnerTitles(rpts []*ResPartnerTitle) ([]int64, error for _, v := range rpts { vv = append(vv, v) } - return c.Create(ResPartnerTitleModel, vv) + return c.Create(ResPartnerTitleModel, vv, nil) } // UpdateResPartnerTitle updates an existing res.partner.title record. @@ -57,7 +53,7 @@ func (c *Client) UpdateResPartnerTitle(rpt *ResPartnerTitle) error { // UpdateResPartnerTitles updates existing res.partner.title records. // All records (represented by ids) will be updated by rpt values. func (c *Client) UpdateResPartnerTitles(ids []int64, rpt *ResPartnerTitle) error { - return c.Update(ResPartnerTitleModel, ids, rpt) + return c.Update(ResPartnerTitleModel, ids, rpt, nil) } // DeleteResPartnerTitle deletes an existing res.partner.title record. @@ -76,10 +72,7 @@ func (c *Client) GetResPartnerTitle(id int64) (*ResPartnerTitle, error) { if err != nil { return nil, err } - if rpts != nil && len(*rpts) > 0 { - return &((*rpts)[0]), nil - } - return nil, fmt.Errorf("id %v of res.partner.title not found", id) + return &((*rpts)[0]), nil } // GetResPartnerTitles gets res.partner.title existing records. @@ -97,10 +90,7 @@ func (c *Client) FindResPartnerTitle(criteria *Criteria) (*ResPartnerTitle, erro if err := c.SearchRead(ResPartnerTitleModel, criteria, NewOptions().Limit(1), rpts); err != nil { return nil, err } - if rpts != nil && len(*rpts) > 0 { - return &((*rpts)[0]), nil - } - return nil, fmt.Errorf("res.partner.title was not found with criteria %v", criteria) + return &((*rpts)[0]), nil } // FindResPartnerTitles finds res.partner.title records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindResPartnerTitles(criteria *Criteria, options *Options) (*Re // FindResPartnerTitleIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResPartnerTitleIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResPartnerTitleModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResPartnerTitleModel, criteria, options) } // FindResPartnerTitleId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindResPartnerTitleId(criteria *Criteria, options *Options) (in if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.partner.title was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_request_link.go b/res_request_link.go index 27bc10dc..e1dbb6f9 100644 --- a/res_request_link.go +++ b/res_request_link.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResRequestLink represents res.request.link model. type ResRequestLink struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateResRequestLinks(rrls []*ResRequestLink) ([]int64, error) for _, v := range rrls { vv = append(vv, v) } - return c.Create(ResRequestLinkModel, vv) + return c.Create(ResRequestLinkModel, vv, nil) } // UpdateResRequestLink updates an existing res.request.link record. @@ -58,7 +54,7 @@ func (c *Client) UpdateResRequestLink(rrl *ResRequestLink) error { // UpdateResRequestLinks updates existing res.request.link records. // All records (represented by ids) will be updated by rrl values. func (c *Client) UpdateResRequestLinks(ids []int64, rrl *ResRequestLink) error { - return c.Update(ResRequestLinkModel, ids, rrl) + return c.Update(ResRequestLinkModel, ids, rrl, nil) } // DeleteResRequestLink deletes an existing res.request.link record. @@ -77,10 +73,7 @@ func (c *Client) GetResRequestLink(id int64) (*ResRequestLink, error) { if err != nil { return nil, err } - if rrls != nil && len(*rrls) > 0 { - return &((*rrls)[0]), nil - } - return nil, fmt.Errorf("id %v of res.request.link not found", id) + return &((*rrls)[0]), nil } // GetResRequestLinks gets res.request.link existing records. @@ -98,10 +91,7 @@ func (c *Client) FindResRequestLink(criteria *Criteria) (*ResRequestLink, error) if err := c.SearchRead(ResRequestLinkModel, criteria, NewOptions().Limit(1), rrls); err != nil { return nil, err } - if rrls != nil && len(*rrls) > 0 { - return &((*rrls)[0]), nil - } - return nil, fmt.Errorf("res.request.link was not found with criteria %v", criteria) + return &((*rrls)[0]), nil } // FindResRequestLinks finds res.request.link records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindResRequestLinks(criteria *Criteria, options *Options) (*Res // FindResRequestLinkIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResRequestLinkIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResRequestLinkModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResRequestLinkModel, criteria, options) } // FindResRequestLinkId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindResRequestLinkId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.request.link was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_users.go b/res_users.go index e1ecd788..6f4fa612 100644 --- a/res_users.go +++ b/res_users.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResUsers represents res.users model. type ResUsers struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -72,6 +68,7 @@ type ResUsers struct { LogIds *Relation `xmlrpc:"log_ids,omptempty"` Login *String `xmlrpc:"login,omptempty"` LoginDate *Time `xmlrpc:"login_date,omptempty"` + MachineCompanyName *String `xmlrpc:"machine_company_name,omptempty"` MachineOrganizationName *String `xmlrpc:"machine_organization_name,omptempty"` MachineUserEmail *String `xmlrpc:"machine_user_email,omptempty"` MachineUserLogin *String `xmlrpc:"machine_user_login,omptempty"` @@ -131,13 +128,7 @@ type ResUsers struct { Self *Many2One `xmlrpc:"self,omptempty"` Share *Bool `xmlrpc:"share,omptempty"` Signature *String `xmlrpc:"signature,omptempty"` - SignupExpiration *Time `xmlrpc:"signup_expiration,omptempty"` - SignupToken *String `xmlrpc:"signup_token,omptempty"` - SignupType *String `xmlrpc:"signup_type,omptempty"` - SignupUrl *String `xmlrpc:"signup_url,omptempty"` - SignupValid *Bool `xmlrpc:"signup_valid,omptempty"` Siret *String `xmlrpc:"siret,omptempty"` - State *Selection `xmlrpc:"state,omptempty"` StateId *Many2One `xmlrpc:"state_id,omptempty"` Street *String `xmlrpc:"street,omptempty"` Street2 *String `xmlrpc:"street2,omptempty"` @@ -194,7 +185,7 @@ func (c *Client) CreateResUserss(rus []*ResUsers) ([]int64, error) { for _, v := range rus { vv = append(vv, v) } - return c.Create(ResUsersModel, vv) + return c.Create(ResUsersModel, vv, nil) } // UpdateResUsers updates an existing res.users record. @@ -205,7 +196,7 @@ func (c *Client) UpdateResUsers(ru *ResUsers) error { // UpdateResUserss updates existing res.users records. // All records (represented by ids) will be updated by ru values. func (c *Client) UpdateResUserss(ids []int64, ru *ResUsers) error { - return c.Update(ResUsersModel, ids, ru) + return c.Update(ResUsersModel, ids, ru, nil) } // DeleteResUsers deletes an existing res.users record. @@ -224,10 +215,7 @@ func (c *Client) GetResUsers(id int64) (*ResUsers, error) { if err != nil { return nil, err } - if rus != nil && len(*rus) > 0 { - return &((*rus)[0]), nil - } - return nil, fmt.Errorf("id %v of res.users not found", id) + return &((*rus)[0]), nil } // GetResUserss gets res.users existing records. @@ -245,10 +233,7 @@ func (c *Client) FindResUsers(criteria *Criteria) (*ResUsers, error) { if err := c.SearchRead(ResUsersModel, criteria, NewOptions().Limit(1), rus); err != nil { return nil, err } - if rus != nil && len(*rus) > 0 { - return &((*rus)[0]), nil - } - return nil, fmt.Errorf("res.users was not found with criteria %v", criteria) + return &((*rus)[0]), nil } // FindResUserss finds res.users records by querying it @@ -264,11 +249,7 @@ func (c *Client) FindResUserss(criteria *Criteria, options *Options) (*ResUserss // FindResUsersIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResUsersIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResUsersModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResUsersModel, criteria, options) } // FindResUsersId finds record id by querying it with criteria. @@ -277,8 +258,5 @@ func (c *Client) FindResUsersId(criteria *Criteria, options *Options) (int64, er if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.users was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/res_users_log.go b/res_users_log.go index 077c126d..33dfdeeb 100644 --- a/res_users_log.go +++ b/res_users_log.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResUsersLog represents res.users.log model. type ResUsersLog struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -44,7 +40,7 @@ func (c *Client) CreateResUsersLogs(ruls []*ResUsersLog) ([]int64, error) { for _, v := range ruls { vv = append(vv, v) } - return c.Create(ResUsersLogModel, vv) + return c.Create(ResUsersLogModel, vv, nil) } // UpdateResUsersLog updates an existing res.users.log record. @@ -55,7 +51,7 @@ func (c *Client) UpdateResUsersLog(rul *ResUsersLog) error { // UpdateResUsersLogs updates existing res.users.log records. // All records (represented by ids) will be updated by rul values. func (c *Client) UpdateResUsersLogs(ids []int64, rul *ResUsersLog) error { - return c.Update(ResUsersLogModel, ids, rul) + return c.Update(ResUsersLogModel, ids, rul, nil) } // DeleteResUsersLog deletes an existing res.users.log record. @@ -74,10 +70,7 @@ func (c *Client) GetResUsersLog(id int64) (*ResUsersLog, error) { if err != nil { return nil, err } - if ruls != nil && len(*ruls) > 0 { - return &((*ruls)[0]), nil - } - return nil, fmt.Errorf("id %v of res.users.log not found", id) + return &((*ruls)[0]), nil } // GetResUsersLogs gets res.users.log existing records. @@ -95,10 +88,7 @@ func (c *Client) FindResUsersLog(criteria *Criteria) (*ResUsersLog, error) { if err := c.SearchRead(ResUsersLogModel, criteria, NewOptions().Limit(1), ruls); err != nil { return nil, err } - if ruls != nil && len(*ruls) > 0 { - return &((*ruls)[0]), nil - } - return nil, fmt.Errorf("res.users.log was not found with criteria %v", criteria) + return &((*ruls)[0]), nil } // FindResUsersLogs finds res.users.log records by querying it @@ -114,11 +104,7 @@ func (c *Client) FindResUsersLogs(criteria *Criteria, options *Options) (*ResUse // FindResUsersLogIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResUsersLogIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResUsersLogModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResUsersLogModel, criteria, options) } // FindResUsersLogId finds record id by querying it with criteria. @@ -127,8 +113,5 @@ func (c *Client) FindResUsersLogId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("res.users.log was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/resource_calendar.go b/resource_calendar.go index e4545e70..01a26e4f 100644 --- a/resource_calendar.go +++ b/resource_calendar.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResourceCalendar represents resource.calendar model. type ResourceCalendar struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -49,7 +45,7 @@ func (c *Client) CreateResourceCalendars(rcs []*ResourceCalendar) ([]int64, erro for _, v := range rcs { vv = append(vv, v) } - return c.Create(ResourceCalendarModel, vv) + return c.Create(ResourceCalendarModel, vv, nil) } // UpdateResourceCalendar updates an existing resource.calendar record. @@ -60,7 +56,7 @@ func (c *Client) UpdateResourceCalendar(rc *ResourceCalendar) error { // UpdateResourceCalendars updates existing resource.calendar records. // All records (represented by ids) will be updated by rc values. func (c *Client) UpdateResourceCalendars(ids []int64, rc *ResourceCalendar) error { - return c.Update(ResourceCalendarModel, ids, rc) + return c.Update(ResourceCalendarModel, ids, rc, nil) } // DeleteResourceCalendar deletes an existing resource.calendar record. @@ -79,10 +75,7 @@ func (c *Client) GetResourceCalendar(id int64) (*ResourceCalendar, error) { if err != nil { return nil, err } - if rcs != nil && len(*rcs) > 0 { - return &((*rcs)[0]), nil - } - return nil, fmt.Errorf("id %v of resource.calendar not found", id) + return &((*rcs)[0]), nil } // GetResourceCalendars gets resource.calendar existing records. @@ -100,10 +93,7 @@ func (c *Client) FindResourceCalendar(criteria *Criteria) (*ResourceCalendar, er if err := c.SearchRead(ResourceCalendarModel, criteria, NewOptions().Limit(1), rcs); err != nil { return nil, err } - if rcs != nil && len(*rcs) > 0 { - return &((*rcs)[0]), nil - } - return nil, fmt.Errorf("resource.calendar was not found with criteria %v", criteria) + return &((*rcs)[0]), nil } // FindResourceCalendars finds resource.calendar records by querying it @@ -119,11 +109,7 @@ func (c *Client) FindResourceCalendars(criteria *Criteria, options *Options) (*R // FindResourceCalendarIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResourceCalendarIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResourceCalendarModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResourceCalendarModel, criteria, options) } // FindResourceCalendarId finds record id by querying it with criteria. @@ -132,8 +118,5 @@ func (c *Client) FindResourceCalendarId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("resource.calendar was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/resource_calendar_attendance.go b/resource_calendar_attendance.go index 6a465861..e4bbdea4 100644 --- a/resource_calendar_attendance.go +++ b/resource_calendar_attendance.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResourceCalendarAttendance represents resource.calendar.attendance model. type ResourceCalendarAttendance struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -51,7 +47,7 @@ func (c *Client) CreateResourceCalendarAttendances(rcas []*ResourceCalendarAtten for _, v := range rcas { vv = append(vv, v) } - return c.Create(ResourceCalendarAttendanceModel, vv) + return c.Create(ResourceCalendarAttendanceModel, vv, nil) } // UpdateResourceCalendarAttendance updates an existing resource.calendar.attendance record. @@ -62,7 +58,7 @@ func (c *Client) UpdateResourceCalendarAttendance(rca *ResourceCalendarAttendanc // UpdateResourceCalendarAttendances updates existing resource.calendar.attendance records. // All records (represented by ids) will be updated by rca values. func (c *Client) UpdateResourceCalendarAttendances(ids []int64, rca *ResourceCalendarAttendance) error { - return c.Update(ResourceCalendarAttendanceModel, ids, rca) + return c.Update(ResourceCalendarAttendanceModel, ids, rca, nil) } // DeleteResourceCalendarAttendance deletes an existing resource.calendar.attendance record. @@ -81,10 +77,7 @@ func (c *Client) GetResourceCalendarAttendance(id int64) (*ResourceCalendarAtten if err != nil { return nil, err } - if rcas != nil && len(*rcas) > 0 { - return &((*rcas)[0]), nil - } - return nil, fmt.Errorf("id %v of resource.calendar.attendance not found", id) + return &((*rcas)[0]), nil } // GetResourceCalendarAttendances gets resource.calendar.attendance existing records. @@ -102,10 +95,7 @@ func (c *Client) FindResourceCalendarAttendance(criteria *Criteria) (*ResourceCa if err := c.SearchRead(ResourceCalendarAttendanceModel, criteria, NewOptions().Limit(1), rcas); err != nil { return nil, err } - if rcas != nil && len(*rcas) > 0 { - return &((*rcas)[0]), nil - } - return nil, fmt.Errorf("resource.calendar.attendance was not found with criteria %v", criteria) + return &((*rcas)[0]), nil } // FindResourceCalendarAttendances finds resource.calendar.attendance records by querying it @@ -121,11 +111,7 @@ func (c *Client) FindResourceCalendarAttendances(criteria *Criteria, options *Op // FindResourceCalendarAttendanceIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResourceCalendarAttendanceIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResourceCalendarAttendanceModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResourceCalendarAttendanceModel, criteria, options) } // FindResourceCalendarAttendanceId finds record id by querying it with criteria. @@ -134,8 +120,5 @@ func (c *Client) FindResourceCalendarAttendanceId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("resource.calendar.attendance was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/resource_calendar_leaves.go b/resource_calendar_leaves.go index 3d4597a1..0c5132d7 100644 --- a/resource_calendar_leaves.go +++ b/resource_calendar_leaves.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResourceCalendarLeaves represents resource.calendar.leaves model. type ResourceCalendarLeaves struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -52,7 +48,7 @@ func (c *Client) CreateResourceCalendarLeavess(rcls []*ResourceCalendarLeaves) ( for _, v := range rcls { vv = append(vv, v) } - return c.Create(ResourceCalendarLeavesModel, vv) + return c.Create(ResourceCalendarLeavesModel, vv, nil) } // UpdateResourceCalendarLeaves updates an existing resource.calendar.leaves record. @@ -63,7 +59,7 @@ func (c *Client) UpdateResourceCalendarLeaves(rcl *ResourceCalendarLeaves) error // UpdateResourceCalendarLeavess updates existing resource.calendar.leaves records. // All records (represented by ids) will be updated by rcl values. func (c *Client) UpdateResourceCalendarLeavess(ids []int64, rcl *ResourceCalendarLeaves) error { - return c.Update(ResourceCalendarLeavesModel, ids, rcl) + return c.Update(ResourceCalendarLeavesModel, ids, rcl, nil) } // DeleteResourceCalendarLeaves deletes an existing resource.calendar.leaves record. @@ -82,10 +78,7 @@ func (c *Client) GetResourceCalendarLeaves(id int64) (*ResourceCalendarLeaves, e if err != nil { return nil, err } - if rcls != nil && len(*rcls) > 0 { - return &((*rcls)[0]), nil - } - return nil, fmt.Errorf("id %v of resource.calendar.leaves not found", id) + return &((*rcls)[0]), nil } // GetResourceCalendarLeavess gets resource.calendar.leaves existing records. @@ -103,10 +96,7 @@ func (c *Client) FindResourceCalendarLeaves(criteria *Criteria) (*ResourceCalend if err := c.SearchRead(ResourceCalendarLeavesModel, criteria, NewOptions().Limit(1), rcls); err != nil { return nil, err } - if rcls != nil && len(*rcls) > 0 { - return &((*rcls)[0]), nil - } - return nil, fmt.Errorf("resource.calendar.leaves was not found with criteria %v", criteria) + return &((*rcls)[0]), nil } // FindResourceCalendarLeavess finds resource.calendar.leaves records by querying it @@ -122,11 +112,7 @@ func (c *Client) FindResourceCalendarLeavess(criteria *Criteria, options *Option // FindResourceCalendarLeavesIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResourceCalendarLeavesIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResourceCalendarLeavesModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResourceCalendarLeavesModel, criteria, options) } // FindResourceCalendarLeavesId finds record id by querying it with criteria. @@ -135,8 +121,5 @@ func (c *Client) FindResourceCalendarLeavesId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("resource.calendar.leaves was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/resource_mixin.go b/resource_mixin.go index e25b063c..1bd33436 100644 --- a/resource_mixin.go +++ b/resource_mixin.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResourceMixin represents resource.mixin model. type ResourceMixin struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -43,7 +39,7 @@ func (c *Client) CreateResourceMixins(rms []*ResourceMixin) ([]int64, error) { for _, v := range rms { vv = append(vv, v) } - return c.Create(ResourceMixinModel, vv) + return c.Create(ResourceMixinModel, vv, nil) } // UpdateResourceMixin updates an existing resource.mixin record. @@ -54,7 +50,7 @@ func (c *Client) UpdateResourceMixin(rm *ResourceMixin) error { // UpdateResourceMixins updates existing resource.mixin records. // All records (represented by ids) will be updated by rm values. func (c *Client) UpdateResourceMixins(ids []int64, rm *ResourceMixin) error { - return c.Update(ResourceMixinModel, ids, rm) + return c.Update(ResourceMixinModel, ids, rm, nil) } // DeleteResourceMixin deletes an existing resource.mixin record. @@ -73,10 +69,7 @@ func (c *Client) GetResourceMixin(id int64) (*ResourceMixin, error) { if err != nil { return nil, err } - if rms != nil && len(*rms) > 0 { - return &((*rms)[0]), nil - } - return nil, fmt.Errorf("id %v of resource.mixin not found", id) + return &((*rms)[0]), nil } // GetResourceMixins gets resource.mixin existing records. @@ -94,10 +87,7 @@ func (c *Client) FindResourceMixin(criteria *Criteria) (*ResourceMixin, error) { if err := c.SearchRead(ResourceMixinModel, criteria, NewOptions().Limit(1), rms); err != nil { return nil, err } - if rms != nil && len(*rms) > 0 { - return &((*rms)[0]), nil - } - return nil, fmt.Errorf("resource.mixin was not found with criteria %v", criteria) + return &((*rms)[0]), nil } // FindResourceMixins finds resource.mixin records by querying it @@ -113,11 +103,7 @@ func (c *Client) FindResourceMixins(criteria *Criteria, options *Options) (*Reso // FindResourceMixinIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResourceMixinIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResourceMixinModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResourceMixinModel, criteria, options) } // FindResourceMixinId finds record id by querying it with criteria. @@ -126,8 +112,5 @@ func (c *Client) FindResourceMixinId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("resource.mixin was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/resource_resource.go b/resource_resource.go index 47fd7208..986d987d 100644 --- a/resource_resource.go +++ b/resource_resource.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResourceResource represents resource.resource model. type ResourceResource struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -51,7 +47,7 @@ func (c *Client) CreateResourceResources(rrs []*ResourceResource) ([]int64, erro for _, v := range rrs { vv = append(vv, v) } - return c.Create(ResourceResourceModel, vv) + return c.Create(ResourceResourceModel, vv, nil) } // UpdateResourceResource updates an existing resource.resource record. @@ -62,7 +58,7 @@ func (c *Client) UpdateResourceResource(rr *ResourceResource) error { // UpdateResourceResources updates existing resource.resource records. // All records (represented by ids) will be updated by rr values. func (c *Client) UpdateResourceResources(ids []int64, rr *ResourceResource) error { - return c.Update(ResourceResourceModel, ids, rr) + return c.Update(ResourceResourceModel, ids, rr, nil) } // DeleteResourceResource deletes an existing resource.resource record. @@ -81,10 +77,7 @@ func (c *Client) GetResourceResource(id int64) (*ResourceResource, error) { if err != nil { return nil, err } - if rrs != nil && len(*rrs) > 0 { - return &((*rrs)[0]), nil - } - return nil, fmt.Errorf("id %v of resource.resource not found", id) + return &((*rrs)[0]), nil } // GetResourceResources gets resource.resource existing records. @@ -102,10 +95,7 @@ func (c *Client) FindResourceResource(criteria *Criteria) (*ResourceResource, er if err := c.SearchRead(ResourceResourceModel, criteria, NewOptions().Limit(1), rrs); err != nil { return nil, err } - if rrs != nil && len(*rrs) > 0 { - return &((*rrs)[0]), nil - } - return nil, fmt.Errorf("resource.resource was not found with criteria %v", criteria) + return &((*rrs)[0]), nil } // FindResourceResources finds resource.resource records by querying it @@ -121,11 +111,7 @@ func (c *Client) FindResourceResources(criteria *Criteria, options *Options) (*R // FindResourceResourceIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResourceResourceIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResourceResourceModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResourceResourceModel, criteria, options) } // FindResourceResourceId finds record id by querying it with criteria. @@ -134,8 +120,5 @@ func (c *Client) FindResourceResourceId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("resource.resource was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/resource_test.go b/resource_test.go index 6f610ba5..520d5523 100644 --- a/resource_test.go +++ b/resource_test.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ResourceTest represents resource.test model. type ResourceTest struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateResourceTests(rts []*ResourceTest) ([]int64, error) { for _, v := range rts { vv = append(vv, v) } - return c.Create(ResourceTestModel, vv) + return c.Create(ResourceTestModel, vv, nil) } // UpdateResourceTest updates an existing resource.test record. @@ -59,7 +55,7 @@ func (c *Client) UpdateResourceTest(rt *ResourceTest) error { // UpdateResourceTests updates existing resource.test records. // All records (represented by ids) will be updated by rt values. func (c *Client) UpdateResourceTests(ids []int64, rt *ResourceTest) error { - return c.Update(ResourceTestModel, ids, rt) + return c.Update(ResourceTestModel, ids, rt, nil) } // DeleteResourceTest deletes an existing resource.test record. @@ -78,10 +74,7 @@ func (c *Client) GetResourceTest(id int64) (*ResourceTest, error) { if err != nil { return nil, err } - if rts != nil && len(*rts) > 0 { - return &((*rts)[0]), nil - } - return nil, fmt.Errorf("id %v of resource.test not found", id) + return &((*rts)[0]), nil } // GetResourceTests gets resource.test existing records. @@ -99,10 +92,7 @@ func (c *Client) FindResourceTest(criteria *Criteria) (*ResourceTest, error) { if err := c.SearchRead(ResourceTestModel, criteria, NewOptions().Limit(1), rts); err != nil { return nil, err } - if rts != nil && len(*rts) > 0 { - return &((*rts)[0]), nil - } - return nil, fmt.Errorf("resource.test was not found with criteria %v", criteria) + return &((*rts)[0]), nil } // FindResourceTests finds resource.test records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindResourceTests(criteria *Criteria, options *Options) (*Resou // FindResourceTestIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindResourceTestIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ResourceTestModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ResourceTestModel, criteria, options) } // FindResourceTestId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindResourceTestId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("resource.test was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/sale_advance_payment_inv.go b/sale_advance_payment_inv.go index 996d42ed..ad1ef602 100644 --- a/sale_advance_payment_inv.go +++ b/sale_advance_payment_inv.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // SaleAdvancePaymentInv represents sale.advance.payment.inv model. type SaleAdvancePaymentInv struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateSaleAdvancePaymentInvs(sapis []*SaleAdvancePaymentInv) ([ for _, v := range sapis { vv = append(vv, v) } - return c.Create(SaleAdvancePaymentInvModel, vv) + return c.Create(SaleAdvancePaymentInvModel, vv, nil) } // UpdateSaleAdvancePaymentInv updates an existing sale.advance.payment.inv record. @@ -61,7 +57,7 @@ func (c *Client) UpdateSaleAdvancePaymentInv(sapi *SaleAdvancePaymentInv) error // UpdateSaleAdvancePaymentInvs updates existing sale.advance.payment.inv records. // All records (represented by ids) will be updated by sapi values. func (c *Client) UpdateSaleAdvancePaymentInvs(ids []int64, sapi *SaleAdvancePaymentInv) error { - return c.Update(SaleAdvancePaymentInvModel, ids, sapi) + return c.Update(SaleAdvancePaymentInvModel, ids, sapi, nil) } // DeleteSaleAdvancePaymentInv deletes an existing sale.advance.payment.inv record. @@ -80,10 +76,7 @@ func (c *Client) GetSaleAdvancePaymentInv(id int64) (*SaleAdvancePaymentInv, err if err != nil { return nil, err } - if sapis != nil && len(*sapis) > 0 { - return &((*sapis)[0]), nil - } - return nil, fmt.Errorf("id %v of sale.advance.payment.inv not found", id) + return &((*sapis)[0]), nil } // GetSaleAdvancePaymentInvs gets sale.advance.payment.inv existing records. @@ -101,10 +94,7 @@ func (c *Client) FindSaleAdvancePaymentInv(criteria *Criteria) (*SaleAdvancePaym if err := c.SearchRead(SaleAdvancePaymentInvModel, criteria, NewOptions().Limit(1), sapis); err != nil { return nil, err } - if sapis != nil && len(*sapis) > 0 { - return &((*sapis)[0]), nil - } - return nil, fmt.Errorf("sale.advance.payment.inv was not found with criteria %v", criteria) + return &((*sapis)[0]), nil } // FindSaleAdvancePaymentInvs finds sale.advance.payment.inv records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindSaleAdvancePaymentInvs(criteria *Criteria, options *Options // FindSaleAdvancePaymentInvIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindSaleAdvancePaymentInvIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(SaleAdvancePaymentInvModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(SaleAdvancePaymentInvModel, criteria, options) } // FindSaleAdvancePaymentInvId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindSaleAdvancePaymentInvId(criteria *Criteria, options *Option if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("sale.advance.payment.inv was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/sale_layout_category.go b/sale_layout_category.go index 4cc7c423..0e5efc68 100644 --- a/sale_layout_category.go +++ b/sale_layout_category.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // SaleLayoutCategory represents sale.layout_category model. type SaleLayoutCategory struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateSaleLayoutCategorys(sls []*SaleLayoutCategory) ([]int64, for _, v := range sls { vv = append(vv, v) } - return c.Create(SaleLayoutCategoryModel, vv) + return c.Create(SaleLayoutCategoryModel, vv, nil) } // UpdateSaleLayoutCategory updates an existing sale.layout_category record. @@ -59,7 +55,7 @@ func (c *Client) UpdateSaleLayoutCategory(sl *SaleLayoutCategory) error { // UpdateSaleLayoutCategorys updates existing sale.layout_category records. // All records (represented by ids) will be updated by sl values. func (c *Client) UpdateSaleLayoutCategorys(ids []int64, sl *SaleLayoutCategory) error { - return c.Update(SaleLayoutCategoryModel, ids, sl) + return c.Update(SaleLayoutCategoryModel, ids, sl, nil) } // DeleteSaleLayoutCategory deletes an existing sale.layout_category record. @@ -78,10 +74,7 @@ func (c *Client) GetSaleLayoutCategory(id int64) (*SaleLayoutCategory, error) { if err != nil { return nil, err } - if sls != nil && len(*sls) > 0 { - return &((*sls)[0]), nil - } - return nil, fmt.Errorf("id %v of sale.layout_category not found", id) + return &((*sls)[0]), nil } // GetSaleLayoutCategorys gets sale.layout_category existing records. @@ -99,10 +92,7 @@ func (c *Client) FindSaleLayoutCategory(criteria *Criteria) (*SaleLayoutCategory if err := c.SearchRead(SaleLayoutCategoryModel, criteria, NewOptions().Limit(1), sls); err != nil { return nil, err } - if sls != nil && len(*sls) > 0 { - return &((*sls)[0]), nil - } - return nil, fmt.Errorf("sale.layout_category was not found with criteria %v", criteria) + return &((*sls)[0]), nil } // FindSaleLayoutCategorys finds sale.layout_category records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindSaleLayoutCategorys(criteria *Criteria, options *Options) ( // FindSaleLayoutCategoryIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindSaleLayoutCategoryIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(SaleLayoutCategoryModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(SaleLayoutCategoryModel, criteria, options) } // FindSaleLayoutCategoryId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindSaleLayoutCategoryId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("sale.layout_category was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/sale_order.go b/sale_order.go index 267d1b90..7b4e0fae 100644 --- a/sale_order.go +++ b/sale_order.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // SaleOrder represents sale.order model. type SaleOrder struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -69,6 +65,7 @@ type SaleOrder struct { State *Selection `xmlrpc:"state,omptempty"` TagIds *Relation `xmlrpc:"tag_ids,omptempty"` TasksCount *Int `xmlrpc:"tasks_count,omptempty"` + TasksCreated *Bool `xmlrpc:"tasks_created,omptempty"` TasksIds *Relation `xmlrpc:"tasks_ids,omptempty"` TeamId *Many2One `xmlrpc:"team_id,omptempty"` TimesheetCount *Float `xmlrpc:"timesheet_count,omptempty"` @@ -112,7 +109,7 @@ func (c *Client) CreateSaleOrders(sos []*SaleOrder) ([]int64, error) { for _, v := range sos { vv = append(vv, v) } - return c.Create(SaleOrderModel, vv) + return c.Create(SaleOrderModel, vv, nil) } // UpdateSaleOrder updates an existing sale.order record. @@ -123,7 +120,7 @@ func (c *Client) UpdateSaleOrder(so *SaleOrder) error { // UpdateSaleOrders updates existing sale.order records. // All records (represented by ids) will be updated by so values. func (c *Client) UpdateSaleOrders(ids []int64, so *SaleOrder) error { - return c.Update(SaleOrderModel, ids, so) + return c.Update(SaleOrderModel, ids, so, nil) } // DeleteSaleOrder deletes an existing sale.order record. @@ -142,10 +139,7 @@ func (c *Client) GetSaleOrder(id int64) (*SaleOrder, error) { if err != nil { return nil, err } - if sos != nil && len(*sos) > 0 { - return &((*sos)[0]), nil - } - return nil, fmt.Errorf("id %v of sale.order not found", id) + return &((*sos)[0]), nil } // GetSaleOrders gets sale.order existing records. @@ -163,10 +157,7 @@ func (c *Client) FindSaleOrder(criteria *Criteria) (*SaleOrder, error) { if err := c.SearchRead(SaleOrderModel, criteria, NewOptions().Limit(1), sos); err != nil { return nil, err } - if sos != nil && len(*sos) > 0 { - return &((*sos)[0]), nil - } - return nil, fmt.Errorf("sale.order was not found with criteria %v", criteria) + return &((*sos)[0]), nil } // FindSaleOrders finds sale.order records by querying it @@ -182,11 +173,7 @@ func (c *Client) FindSaleOrders(criteria *Criteria, options *Options) (*SaleOrde // FindSaleOrderIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindSaleOrderIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(SaleOrderModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(SaleOrderModel, criteria, options) } // FindSaleOrderId finds record id by querying it with criteria. @@ -195,8 +182,5 @@ func (c *Client) FindSaleOrderId(criteria *Criteria, options *Options) (int64, e if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("sale.order was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/sale_order_line.go b/sale_order_line.go index 75e696c3..abc19903 100644 --- a/sale_order_line.go +++ b/sale_order_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // SaleOrderLine represents sale.order.line model. type SaleOrderLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -86,7 +82,7 @@ func (c *Client) CreateSaleOrderLines(sols []*SaleOrderLine) ([]int64, error) { for _, v := range sols { vv = append(vv, v) } - return c.Create(SaleOrderLineModel, vv) + return c.Create(SaleOrderLineModel, vv, nil) } // UpdateSaleOrderLine updates an existing sale.order.line record. @@ -97,7 +93,7 @@ func (c *Client) UpdateSaleOrderLine(sol *SaleOrderLine) error { // UpdateSaleOrderLines updates existing sale.order.line records. // All records (represented by ids) will be updated by sol values. func (c *Client) UpdateSaleOrderLines(ids []int64, sol *SaleOrderLine) error { - return c.Update(SaleOrderLineModel, ids, sol) + return c.Update(SaleOrderLineModel, ids, sol, nil) } // DeleteSaleOrderLine deletes an existing sale.order.line record. @@ -116,10 +112,7 @@ func (c *Client) GetSaleOrderLine(id int64) (*SaleOrderLine, error) { if err != nil { return nil, err } - if sols != nil && len(*sols) > 0 { - return &((*sols)[0]), nil - } - return nil, fmt.Errorf("id %v of sale.order.line not found", id) + return &((*sols)[0]), nil } // GetSaleOrderLines gets sale.order.line existing records. @@ -137,10 +130,7 @@ func (c *Client) FindSaleOrderLine(criteria *Criteria) (*SaleOrderLine, error) { if err := c.SearchRead(SaleOrderLineModel, criteria, NewOptions().Limit(1), sols); err != nil { return nil, err } - if sols != nil && len(*sols) > 0 { - return &((*sols)[0]), nil - } - return nil, fmt.Errorf("sale.order.line was not found with criteria %v", criteria) + return &((*sols)[0]), nil } // FindSaleOrderLines finds sale.order.line records by querying it @@ -156,11 +146,7 @@ func (c *Client) FindSaleOrderLines(criteria *Criteria, options *Options) (*Sale // FindSaleOrderLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindSaleOrderLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(SaleOrderLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(SaleOrderLineModel, criteria, options) } // FindSaleOrderLineId finds record id by querying it with criteria. @@ -169,8 +155,5 @@ func (c *Client) FindSaleOrderLineId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("sale.order.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/sale_report.go b/sale_report.go index fe500571..0f42e96f 100644 --- a/sale_report.go +++ b/sale_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // SaleReport represents sale.report model. type SaleReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -68,7 +64,7 @@ func (c *Client) CreateSaleReports(srs []*SaleReport) ([]int64, error) { for _, v := range srs { vv = append(vv, v) } - return c.Create(SaleReportModel, vv) + return c.Create(SaleReportModel, vv, nil) } // UpdateSaleReport updates an existing sale.report record. @@ -79,7 +75,7 @@ func (c *Client) UpdateSaleReport(sr *SaleReport) error { // UpdateSaleReports updates existing sale.report records. // All records (represented by ids) will be updated by sr values. func (c *Client) UpdateSaleReports(ids []int64, sr *SaleReport) error { - return c.Update(SaleReportModel, ids, sr) + return c.Update(SaleReportModel, ids, sr, nil) } // DeleteSaleReport deletes an existing sale.report record. @@ -98,10 +94,7 @@ func (c *Client) GetSaleReport(id int64) (*SaleReport, error) { if err != nil { return nil, err } - if srs != nil && len(*srs) > 0 { - return &((*srs)[0]), nil - } - return nil, fmt.Errorf("id %v of sale.report not found", id) + return &((*srs)[0]), nil } // GetSaleReports gets sale.report existing records. @@ -119,10 +112,7 @@ func (c *Client) FindSaleReport(criteria *Criteria) (*SaleReport, error) { if err := c.SearchRead(SaleReportModel, criteria, NewOptions().Limit(1), srs); err != nil { return nil, err } - if srs != nil && len(*srs) > 0 { - return &((*srs)[0]), nil - } - return nil, fmt.Errorf("sale.report was not found with criteria %v", criteria) + return &((*srs)[0]), nil } // FindSaleReports finds sale.report records by querying it @@ -138,11 +128,7 @@ func (c *Client) FindSaleReports(criteria *Criteria, options *Options) (*SaleRep // FindSaleReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindSaleReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(SaleReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(SaleReportModel, criteria, options) } // FindSaleReportId finds record id by querying it with criteria. @@ -151,8 +137,5 @@ func (c *Client) FindSaleReportId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("sale.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/sms_api.go b/sms_api.go index 39605f8f..0822e2f0 100644 --- a/sms_api.go +++ b/sms_api.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // SmsApi represents sms.api model. type SmsApi struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -40,7 +36,7 @@ func (c *Client) CreateSmsApis(sas []*SmsApi) ([]int64, error) { for _, v := range sas { vv = append(vv, v) } - return c.Create(SmsApiModel, vv) + return c.Create(SmsApiModel, vv, nil) } // UpdateSmsApi updates an existing sms.api record. @@ -51,7 +47,7 @@ func (c *Client) UpdateSmsApi(sa *SmsApi) error { // UpdateSmsApis updates existing sms.api records. // All records (represented by ids) will be updated by sa values. func (c *Client) UpdateSmsApis(ids []int64, sa *SmsApi) error { - return c.Update(SmsApiModel, ids, sa) + return c.Update(SmsApiModel, ids, sa, nil) } // DeleteSmsApi deletes an existing sms.api record. @@ -70,10 +66,7 @@ func (c *Client) GetSmsApi(id int64) (*SmsApi, error) { if err != nil { return nil, err } - if sas != nil && len(*sas) > 0 { - return &((*sas)[0]), nil - } - return nil, fmt.Errorf("id %v of sms.api not found", id) + return &((*sas)[0]), nil } // GetSmsApis gets sms.api existing records. @@ -91,10 +84,7 @@ func (c *Client) FindSmsApi(criteria *Criteria) (*SmsApi, error) { if err := c.SearchRead(SmsApiModel, criteria, NewOptions().Limit(1), sas); err != nil { return nil, err } - if sas != nil && len(*sas) > 0 { - return &((*sas)[0]), nil - } - return nil, fmt.Errorf("sms.api was not found with criteria %v", criteria) + return &((*sas)[0]), nil } // FindSmsApis finds sms.api records by querying it @@ -110,11 +100,7 @@ func (c *Client) FindSmsApis(criteria *Criteria, options *Options) (*SmsApis, er // FindSmsApiIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindSmsApiIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(SmsApiModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(SmsApiModel, criteria, options) } // FindSmsApiId finds record id by querying it with criteria. @@ -123,8 +109,5 @@ func (c *Client) FindSmsApiId(criteria *Criteria, options *Options) (int64, erro if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("sms.api was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/sms_send_sms.go b/sms_send_sms.go index 8df3abbd..c93a099a 100644 --- a/sms_send_sms.go +++ b/sms_send_sms.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // SmsSendSms represents sms.send_sms model. type SmsSendSms struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateSmsSendSmss(sss []*SmsSendSms) ([]int64, error) { for _, v := range sss { vv = append(vv, v) } - return c.Create(SmsSendSmsModel, vv) + return c.Create(SmsSendSmsModel, vv, nil) } // UpdateSmsSendSms updates an existing sms.send_sms record. @@ -57,7 +53,7 @@ func (c *Client) UpdateSmsSendSms(ss *SmsSendSms) error { // UpdateSmsSendSmss updates existing sms.send_sms records. // All records (represented by ids) will be updated by ss values. func (c *Client) UpdateSmsSendSmss(ids []int64, ss *SmsSendSms) error { - return c.Update(SmsSendSmsModel, ids, ss) + return c.Update(SmsSendSmsModel, ids, ss, nil) } // DeleteSmsSendSms deletes an existing sms.send_sms record. @@ -76,10 +72,7 @@ func (c *Client) GetSmsSendSms(id int64) (*SmsSendSms, error) { if err != nil { return nil, err } - if sss != nil && len(*sss) > 0 { - return &((*sss)[0]), nil - } - return nil, fmt.Errorf("id %v of sms.send_sms not found", id) + return &((*sss)[0]), nil } // GetSmsSendSmss gets sms.send_sms existing records. @@ -97,10 +90,7 @@ func (c *Client) FindSmsSendSms(criteria *Criteria) (*SmsSendSms, error) { if err := c.SearchRead(SmsSendSmsModel, criteria, NewOptions().Limit(1), sss); err != nil { return nil, err } - if sss != nil && len(*sss) > 0 { - return &((*sss)[0]), nil - } - return nil, fmt.Errorf("sms.send_sms was not found with criteria %v", criteria) + return &((*sss)[0]), nil } // FindSmsSendSmss finds sms.send_sms records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindSmsSendSmss(criteria *Criteria, options *Options) (*SmsSend // FindSmsSendSmsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindSmsSendSmsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(SmsSendSmsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(SmsSendSmsModel, criteria, options) } // FindSmsSendSmsId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindSmsSendSmsId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("sms.send_sms was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_backorder_confirmation.go b/stock_backorder_confirmation.go index 95c4bb62..11f6d895 100644 --- a/stock_backorder_confirmation.go +++ b/stock_backorder_confirmation.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockBackorderConfirmation represents stock.backorder.confirmation model. type StockBackorderConfirmation struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateStockBackorderConfirmations(sbcs []*StockBackorderConfirm for _, v := range sbcs { vv = append(vv, v) } - return c.Create(StockBackorderConfirmationModel, vv) + return c.Create(StockBackorderConfirmationModel, vv, nil) } // UpdateStockBackorderConfirmation updates an existing stock.backorder.confirmation record. @@ -56,7 +52,7 @@ func (c *Client) UpdateStockBackorderConfirmation(sbc *StockBackorderConfirmatio // UpdateStockBackorderConfirmations updates existing stock.backorder.confirmation records. // All records (represented by ids) will be updated by sbc values. func (c *Client) UpdateStockBackorderConfirmations(ids []int64, sbc *StockBackorderConfirmation) error { - return c.Update(StockBackorderConfirmationModel, ids, sbc) + return c.Update(StockBackorderConfirmationModel, ids, sbc, nil) } // DeleteStockBackorderConfirmation deletes an existing stock.backorder.confirmation record. @@ -75,10 +71,7 @@ func (c *Client) GetStockBackorderConfirmation(id int64) (*StockBackorderConfirm if err != nil { return nil, err } - if sbcs != nil && len(*sbcs) > 0 { - return &((*sbcs)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.backorder.confirmation not found", id) + return &((*sbcs)[0]), nil } // GetStockBackorderConfirmations gets stock.backorder.confirmation existing records. @@ -96,10 +89,7 @@ func (c *Client) FindStockBackorderConfirmation(criteria *Criteria) (*StockBacko if err := c.SearchRead(StockBackorderConfirmationModel, criteria, NewOptions().Limit(1), sbcs); err != nil { return nil, err } - if sbcs != nil && len(*sbcs) > 0 { - return &((*sbcs)[0]), nil - } - return nil, fmt.Errorf("stock.backorder.confirmation was not found with criteria %v", criteria) + return &((*sbcs)[0]), nil } // FindStockBackorderConfirmations finds stock.backorder.confirmation records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindStockBackorderConfirmations(criteria *Criteria, options *Op // FindStockBackorderConfirmationIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockBackorderConfirmationIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockBackorderConfirmationModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockBackorderConfirmationModel, criteria, options) } // FindStockBackorderConfirmationId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindStockBackorderConfirmationId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.backorder.confirmation was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_change_product_qty.go b/stock_change_product_qty.go index 87e5fc04..68e9ba01 100644 --- a/stock_change_product_qty.go +++ b/stock_change_product_qty.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockChangeProductQty represents stock.change.product.qty model. type StockChangeProductQty struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateStockChangeProductQtys(scpqs []*StockChangeProductQty) ([ for _, v := range scpqs { vv = append(vv, v) } - return c.Create(StockChangeProductQtyModel, vv) + return c.Create(StockChangeProductQtyModel, vv, nil) } // UpdateStockChangeProductQty updates an existing stock.change.product.qty record. @@ -61,7 +57,7 @@ func (c *Client) UpdateStockChangeProductQty(scpq *StockChangeProductQty) error // UpdateStockChangeProductQtys updates existing stock.change.product.qty records. // All records (represented by ids) will be updated by scpq values. func (c *Client) UpdateStockChangeProductQtys(ids []int64, scpq *StockChangeProductQty) error { - return c.Update(StockChangeProductQtyModel, ids, scpq) + return c.Update(StockChangeProductQtyModel, ids, scpq, nil) } // DeleteStockChangeProductQty deletes an existing stock.change.product.qty record. @@ -80,10 +76,7 @@ func (c *Client) GetStockChangeProductQty(id int64) (*StockChangeProductQty, err if err != nil { return nil, err } - if scpqs != nil && len(*scpqs) > 0 { - return &((*scpqs)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.change.product.qty not found", id) + return &((*scpqs)[0]), nil } // GetStockChangeProductQtys gets stock.change.product.qty existing records. @@ -101,10 +94,7 @@ func (c *Client) FindStockChangeProductQty(criteria *Criteria) (*StockChangeProd if err := c.SearchRead(StockChangeProductQtyModel, criteria, NewOptions().Limit(1), scpqs); err != nil { return nil, err } - if scpqs != nil && len(*scpqs) > 0 { - return &((*scpqs)[0]), nil - } - return nil, fmt.Errorf("stock.change.product.qty was not found with criteria %v", criteria) + return &((*scpqs)[0]), nil } // FindStockChangeProductQtys finds stock.change.product.qty records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindStockChangeProductQtys(criteria *Criteria, options *Options // FindStockChangeProductQtyIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockChangeProductQtyIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockChangeProductQtyModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockChangeProductQtyModel, criteria, options) } // FindStockChangeProductQtyId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindStockChangeProductQtyId(criteria *Criteria, options *Option if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.change.product.qty was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_change_standard_price.go b/stock_change_standard_price.go index 67a4663f..34f12e08 100644 --- a/stock_change_standard_price.go +++ b/stock_change_standard_price.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockChangeStandardPrice represents stock.change.standard.price model. type StockChangeStandardPrice struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateStockChangeStandardPrices(scsps []*StockChangeStandardPri for _, v := range scsps { vv = append(vv, v) } - return c.Create(StockChangeStandardPriceModel, vv) + return c.Create(StockChangeStandardPriceModel, vv, nil) } // UpdateStockChangeStandardPrice updates an existing stock.change.standard.price record. @@ -58,7 +54,7 @@ func (c *Client) UpdateStockChangeStandardPrice(scsp *StockChangeStandardPrice) // UpdateStockChangeStandardPrices updates existing stock.change.standard.price records. // All records (represented by ids) will be updated by scsp values. func (c *Client) UpdateStockChangeStandardPrices(ids []int64, scsp *StockChangeStandardPrice) error { - return c.Update(StockChangeStandardPriceModel, ids, scsp) + return c.Update(StockChangeStandardPriceModel, ids, scsp, nil) } // DeleteStockChangeStandardPrice deletes an existing stock.change.standard.price record. @@ -77,10 +73,7 @@ func (c *Client) GetStockChangeStandardPrice(id int64) (*StockChangeStandardPric if err != nil { return nil, err } - if scsps != nil && len(*scsps) > 0 { - return &((*scsps)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.change.standard.price not found", id) + return &((*scsps)[0]), nil } // GetStockChangeStandardPrices gets stock.change.standard.price existing records. @@ -98,10 +91,7 @@ func (c *Client) FindStockChangeStandardPrice(criteria *Criteria) (*StockChangeS if err := c.SearchRead(StockChangeStandardPriceModel, criteria, NewOptions().Limit(1), scsps); err != nil { return nil, err } - if scsps != nil && len(*scsps) > 0 { - return &((*scsps)[0]), nil - } - return nil, fmt.Errorf("stock.change.standard.price was not found with criteria %v", criteria) + return &((*scsps)[0]), nil } // FindStockChangeStandardPrices finds stock.change.standard.price records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindStockChangeStandardPrices(criteria *Criteria, options *Opti // FindStockChangeStandardPriceIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockChangeStandardPriceIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockChangeStandardPriceModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockChangeStandardPriceModel, criteria, options) } // FindStockChangeStandardPriceId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindStockChangeStandardPriceId(criteria *Criteria, options *Opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.change.standard.price was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_fixed_putaway_strat.go b/stock_fixed_putaway_strat.go index 27bad87e..995fdaf9 100644 --- a/stock_fixed_putaway_strat.go +++ b/stock_fixed_putaway_strat.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockFixedPutawayStrat represents stock.fixed.putaway.strat model. type StockFixedPutawayStrat struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateStockFixedPutawayStrats(sfpss []*StockFixedPutawayStrat) for _, v := range sfpss { vv = append(vv, v) } - return c.Create(StockFixedPutawayStratModel, vv) + return c.Create(StockFixedPutawayStratModel, vv, nil) } // UpdateStockFixedPutawayStrat updates an existing stock.fixed.putaway.strat record. @@ -59,7 +55,7 @@ func (c *Client) UpdateStockFixedPutawayStrat(sfps *StockFixedPutawayStrat) erro // UpdateStockFixedPutawayStrats updates existing stock.fixed.putaway.strat records. // All records (represented by ids) will be updated by sfps values. func (c *Client) UpdateStockFixedPutawayStrats(ids []int64, sfps *StockFixedPutawayStrat) error { - return c.Update(StockFixedPutawayStratModel, ids, sfps) + return c.Update(StockFixedPutawayStratModel, ids, sfps, nil) } // DeleteStockFixedPutawayStrat deletes an existing stock.fixed.putaway.strat record. @@ -78,10 +74,7 @@ func (c *Client) GetStockFixedPutawayStrat(id int64) (*StockFixedPutawayStrat, e if err != nil { return nil, err } - if sfpss != nil && len(*sfpss) > 0 { - return &((*sfpss)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.fixed.putaway.strat not found", id) + return &((*sfpss)[0]), nil } // GetStockFixedPutawayStrats gets stock.fixed.putaway.strat existing records. @@ -99,10 +92,7 @@ func (c *Client) FindStockFixedPutawayStrat(criteria *Criteria) (*StockFixedPuta if err := c.SearchRead(StockFixedPutawayStratModel, criteria, NewOptions().Limit(1), sfpss); err != nil { return nil, err } - if sfpss != nil && len(*sfpss) > 0 { - return &((*sfpss)[0]), nil - } - return nil, fmt.Errorf("stock.fixed.putaway.strat was not found with criteria %v", criteria) + return &((*sfpss)[0]), nil } // FindStockFixedPutawayStrats finds stock.fixed.putaway.strat records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindStockFixedPutawayStrats(criteria *Criteria, options *Option // FindStockFixedPutawayStratIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockFixedPutawayStratIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockFixedPutawayStratModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockFixedPutawayStratModel, criteria, options) } // FindStockFixedPutawayStratId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindStockFixedPutawayStratId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.fixed.putaway.strat was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_immediate_transfer.go b/stock_immediate_transfer.go index cfe3997e..8f98e3f8 100644 --- a/stock_immediate_transfer.go +++ b/stock_immediate_transfer.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockImmediateTransfer represents stock.immediate.transfer model. type StockImmediateTransfer struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateStockImmediateTransfers(sits []*StockImmediateTransfer) ( for _, v := range sits { vv = append(vv, v) } - return c.Create(StockImmediateTransferModel, vv) + return c.Create(StockImmediateTransferModel, vv, nil) } // UpdateStockImmediateTransfer updates an existing stock.immediate.transfer record. @@ -56,7 +52,7 @@ func (c *Client) UpdateStockImmediateTransfer(sit *StockImmediateTransfer) error // UpdateStockImmediateTransfers updates existing stock.immediate.transfer records. // All records (represented by ids) will be updated by sit values. func (c *Client) UpdateStockImmediateTransfers(ids []int64, sit *StockImmediateTransfer) error { - return c.Update(StockImmediateTransferModel, ids, sit) + return c.Update(StockImmediateTransferModel, ids, sit, nil) } // DeleteStockImmediateTransfer deletes an existing stock.immediate.transfer record. @@ -75,10 +71,7 @@ func (c *Client) GetStockImmediateTransfer(id int64) (*StockImmediateTransfer, e if err != nil { return nil, err } - if sits != nil && len(*sits) > 0 { - return &((*sits)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.immediate.transfer not found", id) + return &((*sits)[0]), nil } // GetStockImmediateTransfers gets stock.immediate.transfer existing records. @@ -96,10 +89,7 @@ func (c *Client) FindStockImmediateTransfer(criteria *Criteria) (*StockImmediate if err := c.SearchRead(StockImmediateTransferModel, criteria, NewOptions().Limit(1), sits); err != nil { return nil, err } - if sits != nil && len(*sits) > 0 { - return &((*sits)[0]), nil - } - return nil, fmt.Errorf("stock.immediate.transfer was not found with criteria %v", criteria) + return &((*sits)[0]), nil } // FindStockImmediateTransfers finds stock.immediate.transfer records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindStockImmediateTransfers(criteria *Criteria, options *Option // FindStockImmediateTransferIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockImmediateTransferIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockImmediateTransferModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockImmediateTransferModel, criteria, options) } // FindStockImmediateTransferId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindStockImmediateTransferId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.immediate.transfer was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_incoterms.go b/stock_incoterms.go index 0b4dedf4..0f8730a0 100644 --- a/stock_incoterms.go +++ b/stock_incoterms.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockIncoterms represents stock.incoterms model. type StockIncoterms struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -47,7 +43,7 @@ func (c *Client) CreateStockIncotermss(sis []*StockIncoterms) ([]int64, error) { for _, v := range sis { vv = append(vv, v) } - return c.Create(StockIncotermsModel, vv) + return c.Create(StockIncotermsModel, vv, nil) } // UpdateStockIncoterms updates an existing stock.incoterms record. @@ -58,7 +54,7 @@ func (c *Client) UpdateStockIncoterms(si *StockIncoterms) error { // UpdateStockIncotermss updates existing stock.incoterms records. // All records (represented by ids) will be updated by si values. func (c *Client) UpdateStockIncotermss(ids []int64, si *StockIncoterms) error { - return c.Update(StockIncotermsModel, ids, si) + return c.Update(StockIncotermsModel, ids, si, nil) } // DeleteStockIncoterms deletes an existing stock.incoterms record. @@ -77,10 +73,7 @@ func (c *Client) GetStockIncoterms(id int64) (*StockIncoterms, error) { if err != nil { return nil, err } - if sis != nil && len(*sis) > 0 { - return &((*sis)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.incoterms not found", id) + return &((*sis)[0]), nil } // GetStockIncotermss gets stock.incoterms existing records. @@ -98,10 +91,7 @@ func (c *Client) FindStockIncoterms(criteria *Criteria) (*StockIncoterms, error) if err := c.SearchRead(StockIncotermsModel, criteria, NewOptions().Limit(1), sis); err != nil { return nil, err } - if sis != nil && len(*sis) > 0 { - return &((*sis)[0]), nil - } - return nil, fmt.Errorf("stock.incoterms was not found with criteria %v", criteria) + return &((*sis)[0]), nil } // FindStockIncotermss finds stock.incoterms records by querying it @@ -117,11 +107,7 @@ func (c *Client) FindStockIncotermss(criteria *Criteria, options *Options) (*Sto // FindStockIncotermsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockIncotermsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockIncotermsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockIncotermsModel, criteria, options) } // FindStockIncotermsId finds record id by querying it with criteria. @@ -130,8 +116,5 @@ func (c *Client) FindStockIncotermsId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.incoterms was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_inventory.go b/stock_inventory.go index f86fd194..a2fca907 100644 --- a/stock_inventory.go +++ b/stock_inventory.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockInventory represents stock.inventory model. type StockInventory struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -60,7 +56,7 @@ func (c *Client) CreateStockInventorys(sis []*StockInventory) ([]int64, error) { for _, v := range sis { vv = append(vv, v) } - return c.Create(StockInventoryModel, vv) + return c.Create(StockInventoryModel, vv, nil) } // UpdateStockInventory updates an existing stock.inventory record. @@ -71,7 +67,7 @@ func (c *Client) UpdateStockInventory(si *StockInventory) error { // UpdateStockInventorys updates existing stock.inventory records. // All records (represented by ids) will be updated by si values. func (c *Client) UpdateStockInventorys(ids []int64, si *StockInventory) error { - return c.Update(StockInventoryModel, ids, si) + return c.Update(StockInventoryModel, ids, si, nil) } // DeleteStockInventory deletes an existing stock.inventory record. @@ -90,10 +86,7 @@ func (c *Client) GetStockInventory(id int64) (*StockInventory, error) { if err != nil { return nil, err } - if sis != nil && len(*sis) > 0 { - return &((*sis)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.inventory not found", id) + return &((*sis)[0]), nil } // GetStockInventorys gets stock.inventory existing records. @@ -111,10 +104,7 @@ func (c *Client) FindStockInventory(criteria *Criteria) (*StockInventory, error) if err := c.SearchRead(StockInventoryModel, criteria, NewOptions().Limit(1), sis); err != nil { return nil, err } - if sis != nil && len(*sis) > 0 { - return &((*sis)[0]), nil - } - return nil, fmt.Errorf("stock.inventory was not found with criteria %v", criteria) + return &((*sis)[0]), nil } // FindStockInventorys finds stock.inventory records by querying it @@ -130,11 +120,7 @@ func (c *Client) FindStockInventorys(criteria *Criteria, options *Options) (*Sto // FindStockInventoryIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockInventoryIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockInventoryModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockInventoryModel, criteria, options) } // FindStockInventoryId finds record id by querying it with criteria. @@ -143,8 +129,5 @@ func (c *Client) FindStockInventoryId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.inventory was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_inventory_line.go b/stock_inventory_line.go index 48cf91dd..8cbe6bf6 100644 --- a/stock_inventory_line.go +++ b/stock_inventory_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockInventoryLine represents stock.inventory.line model. type StockInventoryLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -60,7 +56,7 @@ func (c *Client) CreateStockInventoryLines(sils []*StockInventoryLine) ([]int64, for _, v := range sils { vv = append(vv, v) } - return c.Create(StockInventoryLineModel, vv) + return c.Create(StockInventoryLineModel, vv, nil) } // UpdateStockInventoryLine updates an existing stock.inventory.line record. @@ -71,7 +67,7 @@ func (c *Client) UpdateStockInventoryLine(sil *StockInventoryLine) error { // UpdateStockInventoryLines updates existing stock.inventory.line records. // All records (represented by ids) will be updated by sil values. func (c *Client) UpdateStockInventoryLines(ids []int64, sil *StockInventoryLine) error { - return c.Update(StockInventoryLineModel, ids, sil) + return c.Update(StockInventoryLineModel, ids, sil, nil) } // DeleteStockInventoryLine deletes an existing stock.inventory.line record. @@ -90,10 +86,7 @@ func (c *Client) GetStockInventoryLine(id int64) (*StockInventoryLine, error) { if err != nil { return nil, err } - if sils != nil && len(*sils) > 0 { - return &((*sils)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.inventory.line not found", id) + return &((*sils)[0]), nil } // GetStockInventoryLines gets stock.inventory.line existing records. @@ -111,10 +104,7 @@ func (c *Client) FindStockInventoryLine(criteria *Criteria) (*StockInventoryLine if err := c.SearchRead(StockInventoryLineModel, criteria, NewOptions().Limit(1), sils); err != nil { return nil, err } - if sils != nil && len(*sils) > 0 { - return &((*sils)[0]), nil - } - return nil, fmt.Errorf("stock.inventory.line was not found with criteria %v", criteria) + return &((*sils)[0]), nil } // FindStockInventoryLines finds stock.inventory.line records by querying it @@ -130,11 +120,7 @@ func (c *Client) FindStockInventoryLines(criteria *Criteria, options *Options) ( // FindStockInventoryLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockInventoryLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockInventoryLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockInventoryLineModel, criteria, options) } // FindStockInventoryLineId finds record id by querying it with criteria. @@ -143,8 +129,5 @@ func (c *Client) FindStockInventoryLineId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.inventory.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_location.go b/stock_location.go index d9f28330..9d7abca7 100644 --- a/stock_location.go +++ b/stock_location.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockLocation represents stock.location model. type StockLocation struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -66,7 +62,7 @@ func (c *Client) CreateStockLocations(sls []*StockLocation) ([]int64, error) { for _, v := range sls { vv = append(vv, v) } - return c.Create(StockLocationModel, vv) + return c.Create(StockLocationModel, vv, nil) } // UpdateStockLocation updates an existing stock.location record. @@ -77,7 +73,7 @@ func (c *Client) UpdateStockLocation(sl *StockLocation) error { // UpdateStockLocations updates existing stock.location records. // All records (represented by ids) will be updated by sl values. func (c *Client) UpdateStockLocations(ids []int64, sl *StockLocation) error { - return c.Update(StockLocationModel, ids, sl) + return c.Update(StockLocationModel, ids, sl, nil) } // DeleteStockLocation deletes an existing stock.location record. @@ -96,10 +92,7 @@ func (c *Client) GetStockLocation(id int64) (*StockLocation, error) { if err != nil { return nil, err } - if sls != nil && len(*sls) > 0 { - return &((*sls)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.location not found", id) + return &((*sls)[0]), nil } // GetStockLocations gets stock.location existing records. @@ -117,10 +110,7 @@ func (c *Client) FindStockLocation(criteria *Criteria) (*StockLocation, error) { if err := c.SearchRead(StockLocationModel, criteria, NewOptions().Limit(1), sls); err != nil { return nil, err } - if sls != nil && len(*sls) > 0 { - return &((*sls)[0]), nil - } - return nil, fmt.Errorf("stock.location was not found with criteria %v", criteria) + return &((*sls)[0]), nil } // FindStockLocations finds stock.location records by querying it @@ -136,11 +126,7 @@ func (c *Client) FindStockLocations(criteria *Criteria, options *Options) (*Stoc // FindStockLocationIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockLocationIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockLocationModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockLocationModel, criteria, options) } // FindStockLocationId finds record id by querying it with criteria. @@ -149,8 +135,5 @@ func (c *Client) FindStockLocationId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.location was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_location_path.go b/stock_location_path.go index 13b8cf04..317eb99e 100644 --- a/stock_location_path.go +++ b/stock_location_path.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockLocationPath represents stock.location.path model. type StockLocationPath struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -57,7 +53,7 @@ func (c *Client) CreateStockLocationPaths(slps []*StockLocationPath) ([]int64, e for _, v := range slps { vv = append(vv, v) } - return c.Create(StockLocationPathModel, vv) + return c.Create(StockLocationPathModel, vv, nil) } // UpdateStockLocationPath updates an existing stock.location.path record. @@ -68,7 +64,7 @@ func (c *Client) UpdateStockLocationPath(slp *StockLocationPath) error { // UpdateStockLocationPaths updates existing stock.location.path records. // All records (represented by ids) will be updated by slp values. func (c *Client) UpdateStockLocationPaths(ids []int64, slp *StockLocationPath) error { - return c.Update(StockLocationPathModel, ids, slp) + return c.Update(StockLocationPathModel, ids, slp, nil) } // DeleteStockLocationPath deletes an existing stock.location.path record. @@ -87,10 +83,7 @@ func (c *Client) GetStockLocationPath(id int64) (*StockLocationPath, error) { if err != nil { return nil, err } - if slps != nil && len(*slps) > 0 { - return &((*slps)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.location.path not found", id) + return &((*slps)[0]), nil } // GetStockLocationPaths gets stock.location.path existing records. @@ -108,10 +101,7 @@ func (c *Client) FindStockLocationPath(criteria *Criteria) (*StockLocationPath, if err := c.SearchRead(StockLocationPathModel, criteria, NewOptions().Limit(1), slps); err != nil { return nil, err } - if slps != nil && len(*slps) > 0 { - return &((*slps)[0]), nil - } - return nil, fmt.Errorf("stock.location.path was not found with criteria %v", criteria) + return &((*slps)[0]), nil } // FindStockLocationPaths finds stock.location.path records by querying it @@ -127,11 +117,7 @@ func (c *Client) FindStockLocationPaths(criteria *Criteria, options *Options) (* // FindStockLocationPathIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockLocationPathIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockLocationPathModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockLocationPathModel, criteria, options) } // FindStockLocationPathId finds record id by querying it with criteria. @@ -140,8 +126,5 @@ func (c *Client) FindStockLocationPathId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.location.path was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_location_route.go b/stock_location_route.go index 59c664c2..cc8a529d 100644 --- a/stock_location_route.go +++ b/stock_location_route.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockLocationRoute represents stock.location.route model. type StockLocationRoute struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -59,7 +55,7 @@ func (c *Client) CreateStockLocationRoutes(slrs []*StockLocationRoute) ([]int64, for _, v := range slrs { vv = append(vv, v) } - return c.Create(StockLocationRouteModel, vv) + return c.Create(StockLocationRouteModel, vv, nil) } // UpdateStockLocationRoute updates an existing stock.location.route record. @@ -70,7 +66,7 @@ func (c *Client) UpdateStockLocationRoute(slr *StockLocationRoute) error { // UpdateStockLocationRoutes updates existing stock.location.route records. // All records (represented by ids) will be updated by slr values. func (c *Client) UpdateStockLocationRoutes(ids []int64, slr *StockLocationRoute) error { - return c.Update(StockLocationRouteModel, ids, slr) + return c.Update(StockLocationRouteModel, ids, slr, nil) } // DeleteStockLocationRoute deletes an existing stock.location.route record. @@ -89,10 +85,7 @@ func (c *Client) GetStockLocationRoute(id int64) (*StockLocationRoute, error) { if err != nil { return nil, err } - if slrs != nil && len(*slrs) > 0 { - return &((*slrs)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.location.route not found", id) + return &((*slrs)[0]), nil } // GetStockLocationRoutes gets stock.location.route existing records. @@ -110,10 +103,7 @@ func (c *Client) FindStockLocationRoute(criteria *Criteria) (*StockLocationRoute if err := c.SearchRead(StockLocationRouteModel, criteria, NewOptions().Limit(1), slrs); err != nil { return nil, err } - if slrs != nil && len(*slrs) > 0 { - return &((*slrs)[0]), nil - } - return nil, fmt.Errorf("stock.location.route was not found with criteria %v", criteria) + return &((*slrs)[0]), nil } // FindStockLocationRoutes finds stock.location.route records by querying it @@ -129,11 +119,7 @@ func (c *Client) FindStockLocationRoutes(criteria *Criteria, options *Options) ( // FindStockLocationRouteIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockLocationRouteIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockLocationRouteModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockLocationRouteModel, criteria, options) } // FindStockLocationRouteId finds record id by querying it with criteria. @@ -142,8 +128,5 @@ func (c *Client) FindStockLocationRouteId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.location.route was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_move.go b/stock_move.go index 6061f69d..618c38e4 100644 --- a/stock_move.go +++ b/stock_move.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockMove represents stock.move model. type StockMove struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -109,7 +105,7 @@ func (c *Client) CreateStockMoves(sms []*StockMove) ([]int64, error) { for _, v := range sms { vv = append(vv, v) } - return c.Create(StockMoveModel, vv) + return c.Create(StockMoveModel, vv, nil) } // UpdateStockMove updates an existing stock.move record. @@ -120,7 +116,7 @@ func (c *Client) UpdateStockMove(sm *StockMove) error { // UpdateStockMoves updates existing stock.move records. // All records (represented by ids) will be updated by sm values. func (c *Client) UpdateStockMoves(ids []int64, sm *StockMove) error { - return c.Update(StockMoveModel, ids, sm) + return c.Update(StockMoveModel, ids, sm, nil) } // DeleteStockMove deletes an existing stock.move record. @@ -139,10 +135,7 @@ func (c *Client) GetStockMove(id int64) (*StockMove, error) { if err != nil { return nil, err } - if sms != nil && len(*sms) > 0 { - return &((*sms)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.move not found", id) + return &((*sms)[0]), nil } // GetStockMoves gets stock.move existing records. @@ -160,10 +153,7 @@ func (c *Client) FindStockMove(criteria *Criteria) (*StockMove, error) { if err := c.SearchRead(StockMoveModel, criteria, NewOptions().Limit(1), sms); err != nil { return nil, err } - if sms != nil && len(*sms) > 0 { - return &((*sms)[0]), nil - } - return nil, fmt.Errorf("stock.move was not found with criteria %v", criteria) + return &((*sms)[0]), nil } // FindStockMoves finds stock.move records by querying it @@ -179,11 +169,7 @@ func (c *Client) FindStockMoves(criteria *Criteria, options *Options) (*StockMov // FindStockMoveIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockMoveIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockMoveModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockMoveModel, criteria, options) } // FindStockMoveId finds record id by querying it with criteria. @@ -192,8 +178,5 @@ func (c *Client) FindStockMoveId(criteria *Criteria, options *Options) (int64, e if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.move was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_move_line.go b/stock_move_line.go index ec88a4bf..c9fd5fb8 100644 --- a/stock_move_line.go +++ b/stock_move_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockMoveLine represents stock.move.line model. type StockMoveLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -70,7 +66,7 @@ func (c *Client) CreateStockMoveLines(smls []*StockMoveLine) ([]int64, error) { for _, v := range smls { vv = append(vv, v) } - return c.Create(StockMoveLineModel, vv) + return c.Create(StockMoveLineModel, vv, nil) } // UpdateStockMoveLine updates an existing stock.move.line record. @@ -81,7 +77,7 @@ func (c *Client) UpdateStockMoveLine(sml *StockMoveLine) error { // UpdateStockMoveLines updates existing stock.move.line records. // All records (represented by ids) will be updated by sml values. func (c *Client) UpdateStockMoveLines(ids []int64, sml *StockMoveLine) error { - return c.Update(StockMoveLineModel, ids, sml) + return c.Update(StockMoveLineModel, ids, sml, nil) } // DeleteStockMoveLine deletes an existing stock.move.line record. @@ -100,10 +96,7 @@ func (c *Client) GetStockMoveLine(id int64) (*StockMoveLine, error) { if err != nil { return nil, err } - if smls != nil && len(*smls) > 0 { - return &((*smls)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.move.line not found", id) + return &((*smls)[0]), nil } // GetStockMoveLines gets stock.move.line existing records. @@ -121,10 +114,7 @@ func (c *Client) FindStockMoveLine(criteria *Criteria) (*StockMoveLine, error) { if err := c.SearchRead(StockMoveLineModel, criteria, NewOptions().Limit(1), smls); err != nil { return nil, err } - if smls != nil && len(*smls) > 0 { - return &((*smls)[0]), nil - } - return nil, fmt.Errorf("stock.move.line was not found with criteria %v", criteria) + return &((*smls)[0]), nil } // FindStockMoveLines finds stock.move.line records by querying it @@ -140,11 +130,7 @@ func (c *Client) FindStockMoveLines(criteria *Criteria, options *Options) (*Stoc // FindStockMoveLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockMoveLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockMoveLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockMoveLineModel, criteria, options) } // FindStockMoveLineId finds record id by querying it with criteria. @@ -153,8 +139,5 @@ func (c *Client) FindStockMoveLineId(criteria *Criteria, options *Options) (int6 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.move.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_overprocessed_transfer.go b/stock_overprocessed_transfer.go index 3b748fa3..70905d09 100644 --- a/stock_overprocessed_transfer.go +++ b/stock_overprocessed_transfer.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockOverprocessedTransfer represents stock.overprocessed.transfer model. type StockOverprocessedTransfer struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateStockOverprocessedTransfers(sots []*StockOverprocessedTra for _, v := range sots { vv = append(vv, v) } - return c.Create(StockOverprocessedTransferModel, vv) + return c.Create(StockOverprocessedTransferModel, vv, nil) } // UpdateStockOverprocessedTransfer updates an existing stock.overprocessed.transfer record. @@ -57,7 +53,7 @@ func (c *Client) UpdateStockOverprocessedTransfer(sot *StockOverprocessedTransfe // UpdateStockOverprocessedTransfers updates existing stock.overprocessed.transfer records. // All records (represented by ids) will be updated by sot values. func (c *Client) UpdateStockOverprocessedTransfers(ids []int64, sot *StockOverprocessedTransfer) error { - return c.Update(StockOverprocessedTransferModel, ids, sot) + return c.Update(StockOverprocessedTransferModel, ids, sot, nil) } // DeleteStockOverprocessedTransfer deletes an existing stock.overprocessed.transfer record. @@ -76,10 +72,7 @@ func (c *Client) GetStockOverprocessedTransfer(id int64) (*StockOverprocessedTra if err != nil { return nil, err } - if sots != nil && len(*sots) > 0 { - return &((*sots)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.overprocessed.transfer not found", id) + return &((*sots)[0]), nil } // GetStockOverprocessedTransfers gets stock.overprocessed.transfer existing records. @@ -97,10 +90,7 @@ func (c *Client) FindStockOverprocessedTransfer(criteria *Criteria) (*StockOverp if err := c.SearchRead(StockOverprocessedTransferModel, criteria, NewOptions().Limit(1), sots); err != nil { return nil, err } - if sots != nil && len(*sots) > 0 { - return &((*sots)[0]), nil - } - return nil, fmt.Errorf("stock.overprocessed.transfer was not found with criteria %v", criteria) + return &((*sots)[0]), nil } // FindStockOverprocessedTransfers finds stock.overprocessed.transfer records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindStockOverprocessedTransfers(criteria *Criteria, options *Op // FindStockOverprocessedTransferIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockOverprocessedTransferIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockOverprocessedTransferModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockOverprocessedTransferModel, criteria, options) } // FindStockOverprocessedTransferId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindStockOverprocessedTransferId(criteria *Criteria, options *O if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.overprocessed.transfer was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_picking.go b/stock_picking.go index d622e2ad..68780dc8 100644 --- a/stock_picking.go +++ b/stock_picking.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockPicking represents stock.picking model. type StockPicking struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -98,7 +94,7 @@ func (c *Client) CreateStockPickings(sps []*StockPicking) ([]int64, error) { for _, v := range sps { vv = append(vv, v) } - return c.Create(StockPickingModel, vv) + return c.Create(StockPickingModel, vv, nil) } // UpdateStockPicking updates an existing stock.picking record. @@ -109,7 +105,7 @@ func (c *Client) UpdateStockPicking(sp *StockPicking) error { // UpdateStockPickings updates existing stock.picking records. // All records (represented by ids) will be updated by sp values. func (c *Client) UpdateStockPickings(ids []int64, sp *StockPicking) error { - return c.Update(StockPickingModel, ids, sp) + return c.Update(StockPickingModel, ids, sp, nil) } // DeleteStockPicking deletes an existing stock.picking record. @@ -128,10 +124,7 @@ func (c *Client) GetStockPicking(id int64) (*StockPicking, error) { if err != nil { return nil, err } - if sps != nil && len(*sps) > 0 { - return &((*sps)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.picking not found", id) + return &((*sps)[0]), nil } // GetStockPickings gets stock.picking existing records. @@ -149,10 +142,7 @@ func (c *Client) FindStockPicking(criteria *Criteria) (*StockPicking, error) { if err := c.SearchRead(StockPickingModel, criteria, NewOptions().Limit(1), sps); err != nil { return nil, err } - if sps != nil && len(*sps) > 0 { - return &((*sps)[0]), nil - } - return nil, fmt.Errorf("stock.picking was not found with criteria %v", criteria) + return &((*sps)[0]), nil } // FindStockPickings finds stock.picking records by querying it @@ -168,11 +158,7 @@ func (c *Client) FindStockPickings(criteria *Criteria, options *Options) (*Stock // FindStockPickingIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockPickingIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockPickingModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockPickingModel, criteria, options) } // FindStockPickingId finds record id by querying it with criteria. @@ -181,8 +167,5 @@ func (c *Client) FindStockPickingId(criteria *Criteria, options *Options) (int64 if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.picking was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_picking_type.go b/stock_picking_type.go index 755e4521..51b42e04 100644 --- a/stock_picking_type.go +++ b/stock_picking_type.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockPickingType represents stock.picking.type model. type StockPickingType struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -69,7 +65,7 @@ func (c *Client) CreateStockPickingTypes(spts []*StockPickingType) ([]int64, err for _, v := range spts { vv = append(vv, v) } - return c.Create(StockPickingTypeModel, vv) + return c.Create(StockPickingTypeModel, vv, nil) } // UpdateStockPickingType updates an existing stock.picking.type record. @@ -80,7 +76,7 @@ func (c *Client) UpdateStockPickingType(spt *StockPickingType) error { // UpdateStockPickingTypes updates existing stock.picking.type records. // All records (represented by ids) will be updated by spt values. func (c *Client) UpdateStockPickingTypes(ids []int64, spt *StockPickingType) error { - return c.Update(StockPickingTypeModel, ids, spt) + return c.Update(StockPickingTypeModel, ids, spt, nil) } // DeleteStockPickingType deletes an existing stock.picking.type record. @@ -99,10 +95,7 @@ func (c *Client) GetStockPickingType(id int64) (*StockPickingType, error) { if err != nil { return nil, err } - if spts != nil && len(*spts) > 0 { - return &((*spts)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.picking.type not found", id) + return &((*spts)[0]), nil } // GetStockPickingTypes gets stock.picking.type existing records. @@ -120,10 +113,7 @@ func (c *Client) FindStockPickingType(criteria *Criteria) (*StockPickingType, er if err := c.SearchRead(StockPickingTypeModel, criteria, NewOptions().Limit(1), spts); err != nil { return nil, err } - if spts != nil && len(*spts) > 0 { - return &((*spts)[0]), nil - } - return nil, fmt.Errorf("stock.picking.type was not found with criteria %v", criteria) + return &((*spts)[0]), nil } // FindStockPickingTypes finds stock.picking.type records by querying it @@ -139,11 +129,7 @@ func (c *Client) FindStockPickingTypes(criteria *Criteria, options *Options) (*S // FindStockPickingTypeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockPickingTypeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockPickingTypeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockPickingTypeModel, criteria, options) } // FindStockPickingTypeId finds record id by querying it with criteria. @@ -152,8 +138,5 @@ func (c *Client) FindStockPickingTypeId(criteria *Criteria, options *Options) (i if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.picking.type was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_production_lot.go b/stock_production_lot.go index d878fa5e..c8958aea 100644 --- a/stock_production_lot.go +++ b/stock_production_lot.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockProductionLot represents stock.production.lot model. type StockProductionLot struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -61,7 +57,7 @@ func (c *Client) CreateStockProductionLots(spls []*StockProductionLot) ([]int64, for _, v := range spls { vv = append(vv, v) } - return c.Create(StockProductionLotModel, vv) + return c.Create(StockProductionLotModel, vv, nil) } // UpdateStockProductionLot updates an existing stock.production.lot record. @@ -72,7 +68,7 @@ func (c *Client) UpdateStockProductionLot(spl *StockProductionLot) error { // UpdateStockProductionLots updates existing stock.production.lot records. // All records (represented by ids) will be updated by spl values. func (c *Client) UpdateStockProductionLots(ids []int64, spl *StockProductionLot) error { - return c.Update(StockProductionLotModel, ids, spl) + return c.Update(StockProductionLotModel, ids, spl, nil) } // DeleteStockProductionLot deletes an existing stock.production.lot record. @@ -91,10 +87,7 @@ func (c *Client) GetStockProductionLot(id int64) (*StockProductionLot, error) { if err != nil { return nil, err } - if spls != nil && len(*spls) > 0 { - return &((*spls)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.production.lot not found", id) + return &((*spls)[0]), nil } // GetStockProductionLots gets stock.production.lot existing records. @@ -112,10 +105,7 @@ func (c *Client) FindStockProductionLot(criteria *Criteria) (*StockProductionLot if err := c.SearchRead(StockProductionLotModel, criteria, NewOptions().Limit(1), spls); err != nil { return nil, err } - if spls != nil && len(*spls) > 0 { - return &((*spls)[0]), nil - } - return nil, fmt.Errorf("stock.production.lot was not found with criteria %v", criteria) + return &((*spls)[0]), nil } // FindStockProductionLots finds stock.production.lot records by querying it @@ -131,11 +121,7 @@ func (c *Client) FindStockProductionLots(criteria *Criteria, options *Options) ( // FindStockProductionLotIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockProductionLotIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockProductionLotModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockProductionLotModel, criteria, options) } // FindStockProductionLotId finds record id by querying it with criteria. @@ -144,8 +130,5 @@ func (c *Client) FindStockProductionLotId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.production.lot was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_quant.go b/stock_quant.go index d708f3c6..5bcb5c38 100644 --- a/stock_quant.go +++ b/stock_quant.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockQuant represents stock.quant model. type StockQuant struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -55,7 +51,7 @@ func (c *Client) CreateStockQuants(sqs []*StockQuant) ([]int64, error) { for _, v := range sqs { vv = append(vv, v) } - return c.Create(StockQuantModel, vv) + return c.Create(StockQuantModel, vv, nil) } // UpdateStockQuant updates an existing stock.quant record. @@ -66,7 +62,7 @@ func (c *Client) UpdateStockQuant(sq *StockQuant) error { // UpdateStockQuants updates existing stock.quant records. // All records (represented by ids) will be updated by sq values. func (c *Client) UpdateStockQuants(ids []int64, sq *StockQuant) error { - return c.Update(StockQuantModel, ids, sq) + return c.Update(StockQuantModel, ids, sq, nil) } // DeleteStockQuant deletes an existing stock.quant record. @@ -85,10 +81,7 @@ func (c *Client) GetStockQuant(id int64) (*StockQuant, error) { if err != nil { return nil, err } - if sqs != nil && len(*sqs) > 0 { - return &((*sqs)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.quant not found", id) + return &((*sqs)[0]), nil } // GetStockQuants gets stock.quant existing records. @@ -106,10 +99,7 @@ func (c *Client) FindStockQuant(criteria *Criteria) (*StockQuant, error) { if err := c.SearchRead(StockQuantModel, criteria, NewOptions().Limit(1), sqs); err != nil { return nil, err } - if sqs != nil && len(*sqs) > 0 { - return &((*sqs)[0]), nil - } - return nil, fmt.Errorf("stock.quant was not found with criteria %v", criteria) + return &((*sqs)[0]), nil } // FindStockQuants finds stock.quant records by querying it @@ -125,11 +115,7 @@ func (c *Client) FindStockQuants(criteria *Criteria, options *Options) (*StockQu // FindStockQuantIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockQuantIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockQuantModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockQuantModel, criteria, options) } // FindStockQuantId finds record id by querying it with criteria. @@ -138,8 +124,5 @@ func (c *Client) FindStockQuantId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.quant was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_quant_package.go b/stock_quant_package.go index 0db746db..31108670 100644 --- a/stock_quant_package.go +++ b/stock_quant_package.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockQuantPackage represents stock.quant.package model. type StockQuantPackage struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -56,7 +52,7 @@ func (c *Client) CreateStockQuantPackages(sqps []*StockQuantPackage) ([]int64, e for _, v := range sqps { vv = append(vv, v) } - return c.Create(StockQuantPackageModel, vv) + return c.Create(StockQuantPackageModel, vv, nil) } // UpdateStockQuantPackage updates an existing stock.quant.package record. @@ -67,7 +63,7 @@ func (c *Client) UpdateStockQuantPackage(sqp *StockQuantPackage) error { // UpdateStockQuantPackages updates existing stock.quant.package records. // All records (represented by ids) will be updated by sqp values. func (c *Client) UpdateStockQuantPackages(ids []int64, sqp *StockQuantPackage) error { - return c.Update(StockQuantPackageModel, ids, sqp) + return c.Update(StockQuantPackageModel, ids, sqp, nil) } // DeleteStockQuantPackage deletes an existing stock.quant.package record. @@ -86,10 +82,7 @@ func (c *Client) GetStockQuantPackage(id int64) (*StockQuantPackage, error) { if err != nil { return nil, err } - if sqps != nil && len(*sqps) > 0 { - return &((*sqps)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.quant.package not found", id) + return &((*sqps)[0]), nil } // GetStockQuantPackages gets stock.quant.package existing records. @@ -107,10 +100,7 @@ func (c *Client) FindStockQuantPackage(criteria *Criteria) (*StockQuantPackage, if err := c.SearchRead(StockQuantPackageModel, criteria, NewOptions().Limit(1), sqps); err != nil { return nil, err } - if sqps != nil && len(*sqps) > 0 { - return &((*sqps)[0]), nil - } - return nil, fmt.Errorf("stock.quant.package was not found with criteria %v", criteria) + return &((*sqps)[0]), nil } // FindStockQuantPackages finds stock.quant.package records by querying it @@ -126,11 +116,7 @@ func (c *Client) FindStockQuantPackages(criteria *Criteria, options *Options) (* // FindStockQuantPackageIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockQuantPackageIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockQuantPackageModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockQuantPackageModel, criteria, options) } // FindStockQuantPackageId finds record id by querying it with criteria. @@ -139,8 +125,5 @@ func (c *Client) FindStockQuantPackageId(criteria *Criteria, options *Options) ( if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.quant.package was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_quantity_history.go b/stock_quantity_history.go index 0a1f1244..e95fdc17 100644 --- a/stock_quantity_history.go +++ b/stock_quantity_history.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockQuantityHistory represents stock.quantity.history model. type StockQuantityHistory struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateStockQuantityHistorys(sqhs []*StockQuantityHistory) ([]in for _, v := range sqhs { vv = append(vv, v) } - return c.Create(StockQuantityHistoryModel, vv) + return c.Create(StockQuantityHistoryModel, vv, nil) } // UpdateStockQuantityHistory updates an existing stock.quantity.history record. @@ -57,7 +53,7 @@ func (c *Client) UpdateStockQuantityHistory(sqh *StockQuantityHistory) error { // UpdateStockQuantityHistorys updates existing stock.quantity.history records. // All records (represented by ids) will be updated by sqh values. func (c *Client) UpdateStockQuantityHistorys(ids []int64, sqh *StockQuantityHistory) error { - return c.Update(StockQuantityHistoryModel, ids, sqh) + return c.Update(StockQuantityHistoryModel, ids, sqh, nil) } // DeleteStockQuantityHistory deletes an existing stock.quantity.history record. @@ -76,10 +72,7 @@ func (c *Client) GetStockQuantityHistory(id int64) (*StockQuantityHistory, error if err != nil { return nil, err } - if sqhs != nil && len(*sqhs) > 0 { - return &((*sqhs)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.quantity.history not found", id) + return &((*sqhs)[0]), nil } // GetStockQuantityHistorys gets stock.quantity.history existing records. @@ -97,10 +90,7 @@ func (c *Client) FindStockQuantityHistory(criteria *Criteria) (*StockQuantityHis if err := c.SearchRead(StockQuantityHistoryModel, criteria, NewOptions().Limit(1), sqhs); err != nil { return nil, err } - if sqhs != nil && len(*sqhs) > 0 { - return &((*sqhs)[0]), nil - } - return nil, fmt.Errorf("stock.quantity.history was not found with criteria %v", criteria) + return &((*sqhs)[0]), nil } // FindStockQuantityHistorys finds stock.quantity.history records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindStockQuantityHistorys(criteria *Criteria, options *Options) // FindStockQuantityHistoryIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockQuantityHistoryIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockQuantityHistoryModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockQuantityHistoryModel, criteria, options) } // FindStockQuantityHistoryId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindStockQuantityHistoryId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.quantity.history was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_return_picking.go b/stock_return_picking.go index 23292b82..192e200b 100644 --- a/stock_return_picking.go +++ b/stock_return_picking.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockReturnPicking represents stock.return.picking model. type StockReturnPicking struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateStockReturnPickings(srps []*StockReturnPicking) ([]int64, for _, v := range srps { vv = append(vv, v) } - return c.Create(StockReturnPickingModel, vv) + return c.Create(StockReturnPickingModel, vv, nil) } // UpdateStockReturnPicking updates an existing stock.return.picking record. @@ -61,7 +57,7 @@ func (c *Client) UpdateStockReturnPicking(srp *StockReturnPicking) error { // UpdateStockReturnPickings updates existing stock.return.picking records. // All records (represented by ids) will be updated by srp values. func (c *Client) UpdateStockReturnPickings(ids []int64, srp *StockReturnPicking) error { - return c.Update(StockReturnPickingModel, ids, srp) + return c.Update(StockReturnPickingModel, ids, srp, nil) } // DeleteStockReturnPicking deletes an existing stock.return.picking record. @@ -80,10 +76,7 @@ func (c *Client) GetStockReturnPicking(id int64) (*StockReturnPicking, error) { if err != nil { return nil, err } - if srps != nil && len(*srps) > 0 { - return &((*srps)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.return.picking not found", id) + return &((*srps)[0]), nil } // GetStockReturnPickings gets stock.return.picking existing records. @@ -101,10 +94,7 @@ func (c *Client) FindStockReturnPicking(criteria *Criteria) (*StockReturnPicking if err := c.SearchRead(StockReturnPickingModel, criteria, NewOptions().Limit(1), srps); err != nil { return nil, err } - if srps != nil && len(*srps) > 0 { - return &((*srps)[0]), nil - } - return nil, fmt.Errorf("stock.return.picking was not found with criteria %v", criteria) + return &((*srps)[0]), nil } // FindStockReturnPickings finds stock.return.picking records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindStockReturnPickings(criteria *Criteria, options *Options) ( // FindStockReturnPickingIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockReturnPickingIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockReturnPickingModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockReturnPickingModel, criteria, options) } // FindStockReturnPickingId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindStockReturnPickingId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.return.picking was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_return_picking_line.go b/stock_return_picking_line.go index 6f799d4d..3219f78b 100644 --- a/stock_return_picking_line.go +++ b/stock_return_picking_line.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockReturnPickingLine represents stock.return.picking.line model. type StockReturnPickingLine struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -50,7 +46,7 @@ func (c *Client) CreateStockReturnPickingLines(srpls []*StockReturnPickingLine) for _, v := range srpls { vv = append(vv, v) } - return c.Create(StockReturnPickingLineModel, vv) + return c.Create(StockReturnPickingLineModel, vv, nil) } // UpdateStockReturnPickingLine updates an existing stock.return.picking.line record. @@ -61,7 +57,7 @@ func (c *Client) UpdateStockReturnPickingLine(srpl *StockReturnPickingLine) erro // UpdateStockReturnPickingLines updates existing stock.return.picking.line records. // All records (represented by ids) will be updated by srpl values. func (c *Client) UpdateStockReturnPickingLines(ids []int64, srpl *StockReturnPickingLine) error { - return c.Update(StockReturnPickingLineModel, ids, srpl) + return c.Update(StockReturnPickingLineModel, ids, srpl, nil) } // DeleteStockReturnPickingLine deletes an existing stock.return.picking.line record. @@ -80,10 +76,7 @@ func (c *Client) GetStockReturnPickingLine(id int64) (*StockReturnPickingLine, e if err != nil { return nil, err } - if srpls != nil && len(*srpls) > 0 { - return &((*srpls)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.return.picking.line not found", id) + return &((*srpls)[0]), nil } // GetStockReturnPickingLines gets stock.return.picking.line existing records. @@ -101,10 +94,7 @@ func (c *Client) FindStockReturnPickingLine(criteria *Criteria) (*StockReturnPic if err := c.SearchRead(StockReturnPickingLineModel, criteria, NewOptions().Limit(1), srpls); err != nil { return nil, err } - if srpls != nil && len(*srpls) > 0 { - return &((*srpls)[0]), nil - } - return nil, fmt.Errorf("stock.return.picking.line was not found with criteria %v", criteria) + return &((*srpls)[0]), nil } // FindStockReturnPickingLines finds stock.return.picking.line records by querying it @@ -120,11 +110,7 @@ func (c *Client) FindStockReturnPickingLines(criteria *Criteria, options *Option // FindStockReturnPickingLineIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockReturnPickingLineIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockReturnPickingLineModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockReturnPickingLineModel, criteria, options) } // FindStockReturnPickingLineId finds record id by querying it with criteria. @@ -133,8 +119,5 @@ func (c *Client) FindStockReturnPickingLineId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.return.picking.line was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_scheduler_compute.go b/stock_scheduler_compute.go index cda39cb7..08eb2d35 100644 --- a/stock_scheduler_compute.go +++ b/stock_scheduler_compute.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockSchedulerCompute represents stock.scheduler.compute model. type StockSchedulerCompute struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -44,7 +40,7 @@ func (c *Client) CreateStockSchedulerComputes(sscs []*StockSchedulerCompute) ([] for _, v := range sscs { vv = append(vv, v) } - return c.Create(StockSchedulerComputeModel, vv) + return c.Create(StockSchedulerComputeModel, vv, nil) } // UpdateStockSchedulerCompute updates an existing stock.scheduler.compute record. @@ -55,7 +51,7 @@ func (c *Client) UpdateStockSchedulerCompute(ssc *StockSchedulerCompute) error { // UpdateStockSchedulerComputes updates existing stock.scheduler.compute records. // All records (represented by ids) will be updated by ssc values. func (c *Client) UpdateStockSchedulerComputes(ids []int64, ssc *StockSchedulerCompute) error { - return c.Update(StockSchedulerComputeModel, ids, ssc) + return c.Update(StockSchedulerComputeModel, ids, ssc, nil) } // DeleteStockSchedulerCompute deletes an existing stock.scheduler.compute record. @@ -74,10 +70,7 @@ func (c *Client) GetStockSchedulerCompute(id int64) (*StockSchedulerCompute, err if err != nil { return nil, err } - if sscs != nil && len(*sscs) > 0 { - return &((*sscs)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.scheduler.compute not found", id) + return &((*sscs)[0]), nil } // GetStockSchedulerComputes gets stock.scheduler.compute existing records. @@ -95,10 +88,7 @@ func (c *Client) FindStockSchedulerCompute(criteria *Criteria) (*StockSchedulerC if err := c.SearchRead(StockSchedulerComputeModel, criteria, NewOptions().Limit(1), sscs); err != nil { return nil, err } - if sscs != nil && len(*sscs) > 0 { - return &((*sscs)[0]), nil - } - return nil, fmt.Errorf("stock.scheduler.compute was not found with criteria %v", criteria) + return &((*sscs)[0]), nil } // FindStockSchedulerComputes finds stock.scheduler.compute records by querying it @@ -114,11 +104,7 @@ func (c *Client) FindStockSchedulerComputes(criteria *Criteria, options *Options // FindStockSchedulerComputeIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockSchedulerComputeIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockSchedulerComputeModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockSchedulerComputeModel, criteria, options) } // FindStockSchedulerComputeId finds record id by querying it with criteria. @@ -127,8 +113,5 @@ func (c *Client) FindStockSchedulerComputeId(criteria *Criteria, options *Option if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.scheduler.compute was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_scrap.go b/stock_scrap.go index f5ca1d15..f2a0cdc5 100644 --- a/stock_scrap.go +++ b/stock_scrap.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockScrap represents stock.scrap model. type StockScrap struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -59,7 +55,7 @@ func (c *Client) CreateStockScraps(sss []*StockScrap) ([]int64, error) { for _, v := range sss { vv = append(vv, v) } - return c.Create(StockScrapModel, vv) + return c.Create(StockScrapModel, vv, nil) } // UpdateStockScrap updates an existing stock.scrap record. @@ -70,7 +66,7 @@ func (c *Client) UpdateStockScrap(ss *StockScrap) error { // UpdateStockScraps updates existing stock.scrap records. // All records (represented by ids) will be updated by ss values. func (c *Client) UpdateStockScraps(ids []int64, ss *StockScrap) error { - return c.Update(StockScrapModel, ids, ss) + return c.Update(StockScrapModel, ids, ss, nil) } // DeleteStockScrap deletes an existing stock.scrap record. @@ -89,10 +85,7 @@ func (c *Client) GetStockScrap(id int64) (*StockScrap, error) { if err != nil { return nil, err } - if sss != nil && len(*sss) > 0 { - return &((*sss)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.scrap not found", id) + return &((*sss)[0]), nil } // GetStockScraps gets stock.scrap existing records. @@ -110,10 +103,7 @@ func (c *Client) FindStockScrap(criteria *Criteria) (*StockScrap, error) { if err := c.SearchRead(StockScrapModel, criteria, NewOptions().Limit(1), sss); err != nil { return nil, err } - if sss != nil && len(*sss) > 0 { - return &((*sss)[0]), nil - } - return nil, fmt.Errorf("stock.scrap was not found with criteria %v", criteria) + return &((*sss)[0]), nil } // FindStockScraps finds stock.scrap records by querying it @@ -129,11 +119,7 @@ func (c *Client) FindStockScraps(criteria *Criteria, options *Options) (*StockSc // FindStockScrapIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockScrapIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockScrapModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockScrapModel, criteria, options) } // FindStockScrapId finds record id by querying it with criteria. @@ -142,8 +128,5 @@ func (c *Client) FindStockScrapId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.scrap was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_traceability_report.go b/stock_traceability_report.go index f14ba257..5c7e1cc4 100644 --- a/stock_traceability_report.go +++ b/stock_traceability_report.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockTraceabilityReport represents stock.traceability.report model. type StockTraceabilityReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -44,7 +40,7 @@ func (c *Client) CreateStockTraceabilityReports(strs []*StockTraceabilityReport) for _, v := range strs { vv = append(vv, v) } - return c.Create(StockTraceabilityReportModel, vv) + return c.Create(StockTraceabilityReportModel, vv, nil) } // UpdateStockTraceabilityReport updates an existing stock.traceability.report record. @@ -55,7 +51,7 @@ func (c *Client) UpdateStockTraceabilityReport(str *StockTraceabilityReport) err // UpdateStockTraceabilityReports updates existing stock.traceability.report records. // All records (represented by ids) will be updated by str values. func (c *Client) UpdateStockTraceabilityReports(ids []int64, str *StockTraceabilityReport) error { - return c.Update(StockTraceabilityReportModel, ids, str) + return c.Update(StockTraceabilityReportModel, ids, str, nil) } // DeleteStockTraceabilityReport deletes an existing stock.traceability.report record. @@ -74,10 +70,7 @@ func (c *Client) GetStockTraceabilityReport(id int64) (*StockTraceabilityReport, if err != nil { return nil, err } - if strs != nil && len(*strs) > 0 { - return &((*strs)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.traceability.report not found", id) + return &((*strs)[0]), nil } // GetStockTraceabilityReports gets stock.traceability.report existing records. @@ -95,10 +88,7 @@ func (c *Client) FindStockTraceabilityReport(criteria *Criteria) (*StockTraceabi if err := c.SearchRead(StockTraceabilityReportModel, criteria, NewOptions().Limit(1), strs); err != nil { return nil, err } - if strs != nil && len(*strs) > 0 { - return &((*strs)[0]), nil - } - return nil, fmt.Errorf("stock.traceability.report was not found with criteria %v", criteria) + return &((*strs)[0]), nil } // FindStockTraceabilityReports finds stock.traceability.report records by querying it @@ -114,11 +104,7 @@ func (c *Client) FindStockTraceabilityReports(criteria *Criteria, options *Optio // FindStockTraceabilityReportIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockTraceabilityReportIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockTraceabilityReportModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockTraceabilityReportModel, criteria, options) } // FindStockTraceabilityReportId finds record id by querying it with criteria. @@ -127,8 +113,5 @@ func (c *Client) FindStockTraceabilityReportId(criteria *Criteria, options *Opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.traceability.report was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_warehouse.go b/stock_warehouse.go index 6085533f..1f1de48e 100644 --- a/stock_warehouse.go +++ b/stock_warehouse.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockWarehouse represents stock.warehouse model. type StockWarehouse struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -72,7 +68,7 @@ func (c *Client) CreateStockWarehouses(sws []*StockWarehouse) ([]int64, error) { for _, v := range sws { vv = append(vv, v) } - return c.Create(StockWarehouseModel, vv) + return c.Create(StockWarehouseModel, vv, nil) } // UpdateStockWarehouse updates an existing stock.warehouse record. @@ -83,7 +79,7 @@ func (c *Client) UpdateStockWarehouse(sw *StockWarehouse) error { // UpdateStockWarehouses updates existing stock.warehouse records. // All records (represented by ids) will be updated by sw values. func (c *Client) UpdateStockWarehouses(ids []int64, sw *StockWarehouse) error { - return c.Update(StockWarehouseModel, ids, sw) + return c.Update(StockWarehouseModel, ids, sw, nil) } // DeleteStockWarehouse deletes an existing stock.warehouse record. @@ -102,10 +98,7 @@ func (c *Client) GetStockWarehouse(id int64) (*StockWarehouse, error) { if err != nil { return nil, err } - if sws != nil && len(*sws) > 0 { - return &((*sws)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.warehouse not found", id) + return &((*sws)[0]), nil } // GetStockWarehouses gets stock.warehouse existing records. @@ -123,10 +116,7 @@ func (c *Client) FindStockWarehouse(criteria *Criteria) (*StockWarehouse, error) if err := c.SearchRead(StockWarehouseModel, criteria, NewOptions().Limit(1), sws); err != nil { return nil, err } - if sws != nil && len(*sws) > 0 { - return &((*sws)[0]), nil - } - return nil, fmt.Errorf("stock.warehouse was not found with criteria %v", criteria) + return &((*sws)[0]), nil } // FindStockWarehouses finds stock.warehouse records by querying it @@ -142,11 +132,7 @@ func (c *Client) FindStockWarehouses(criteria *Criteria, options *Options) (*Sto // FindStockWarehouseIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockWarehouseIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockWarehouseModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockWarehouseModel, criteria, options) } // FindStockWarehouseId finds record id by querying it with criteria. @@ -155,8 +141,5 @@ func (c *Client) FindStockWarehouseId(criteria *Criteria, options *Options) (int if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.warehouse was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_warehouse_orderpoint.go b/stock_warehouse_orderpoint.go index 3962871d..9c1673c2 100644 --- a/stock_warehouse_orderpoint.go +++ b/stock_warehouse_orderpoint.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockWarehouseOrderpoint represents stock.warehouse.orderpoint model. type StockWarehouseOrderpoint struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -57,7 +53,7 @@ func (c *Client) CreateStockWarehouseOrderpoints(swos []*StockWarehouseOrderpoin for _, v := range swos { vv = append(vv, v) } - return c.Create(StockWarehouseOrderpointModel, vv) + return c.Create(StockWarehouseOrderpointModel, vv, nil) } // UpdateStockWarehouseOrderpoint updates an existing stock.warehouse.orderpoint record. @@ -68,7 +64,7 @@ func (c *Client) UpdateStockWarehouseOrderpoint(swo *StockWarehouseOrderpoint) e // UpdateStockWarehouseOrderpoints updates existing stock.warehouse.orderpoint records. // All records (represented by ids) will be updated by swo values. func (c *Client) UpdateStockWarehouseOrderpoints(ids []int64, swo *StockWarehouseOrderpoint) error { - return c.Update(StockWarehouseOrderpointModel, ids, swo) + return c.Update(StockWarehouseOrderpointModel, ids, swo, nil) } // DeleteStockWarehouseOrderpoint deletes an existing stock.warehouse.orderpoint record. @@ -87,10 +83,7 @@ func (c *Client) GetStockWarehouseOrderpoint(id int64) (*StockWarehouseOrderpoin if err != nil { return nil, err } - if swos != nil && len(*swos) > 0 { - return &((*swos)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.warehouse.orderpoint not found", id) + return &((*swos)[0]), nil } // GetStockWarehouseOrderpoints gets stock.warehouse.orderpoint existing records. @@ -108,10 +101,7 @@ func (c *Client) FindStockWarehouseOrderpoint(criteria *Criteria) (*StockWarehou if err := c.SearchRead(StockWarehouseOrderpointModel, criteria, NewOptions().Limit(1), swos); err != nil { return nil, err } - if swos != nil && len(*swos) > 0 { - return &((*swos)[0]), nil - } - return nil, fmt.Errorf("stock.warehouse.orderpoint was not found with criteria %v", criteria) + return &((*swos)[0]), nil } // FindStockWarehouseOrderpoints finds stock.warehouse.orderpoint records by querying it @@ -127,11 +117,7 @@ func (c *Client) FindStockWarehouseOrderpoints(criteria *Criteria, options *Opti // FindStockWarehouseOrderpointIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockWarehouseOrderpointIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockWarehouseOrderpointModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockWarehouseOrderpointModel, criteria, options) } // FindStockWarehouseOrderpointId finds record id by querying it with criteria. @@ -140,8 +126,5 @@ func (c *Client) FindStockWarehouseOrderpointId(criteria *Criteria, options *Opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.warehouse.orderpoint was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_warn_insufficient_qty.go b/stock_warn_insufficient_qty.go index 3b108a01..574857d8 100644 --- a/stock_warn_insufficient_qty.go +++ b/stock_warn_insufficient_qty.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockWarnInsufficientQty represents stock.warn.insufficient.qty model. type StockWarnInsufficientQty struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -43,7 +39,7 @@ func (c *Client) CreateStockWarnInsufficientQtys(swiqs []*StockWarnInsufficientQ for _, v := range swiqs { vv = append(vv, v) } - return c.Create(StockWarnInsufficientQtyModel, vv) + return c.Create(StockWarnInsufficientQtyModel, vv, nil) } // UpdateStockWarnInsufficientQty updates an existing stock.warn.insufficient.qty record. @@ -54,7 +50,7 @@ func (c *Client) UpdateStockWarnInsufficientQty(swiq *StockWarnInsufficientQty) // UpdateStockWarnInsufficientQtys updates existing stock.warn.insufficient.qty records. // All records (represented by ids) will be updated by swiq values. func (c *Client) UpdateStockWarnInsufficientQtys(ids []int64, swiq *StockWarnInsufficientQty) error { - return c.Update(StockWarnInsufficientQtyModel, ids, swiq) + return c.Update(StockWarnInsufficientQtyModel, ids, swiq, nil) } // DeleteStockWarnInsufficientQty deletes an existing stock.warn.insufficient.qty record. @@ -73,10 +69,7 @@ func (c *Client) GetStockWarnInsufficientQty(id int64) (*StockWarnInsufficientQt if err != nil { return nil, err } - if swiqs != nil && len(*swiqs) > 0 { - return &((*swiqs)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.warn.insufficient.qty not found", id) + return &((*swiqs)[0]), nil } // GetStockWarnInsufficientQtys gets stock.warn.insufficient.qty existing records. @@ -94,10 +87,7 @@ func (c *Client) FindStockWarnInsufficientQty(criteria *Criteria) (*StockWarnIns if err := c.SearchRead(StockWarnInsufficientQtyModel, criteria, NewOptions().Limit(1), swiqs); err != nil { return nil, err } - if swiqs != nil && len(*swiqs) > 0 { - return &((*swiqs)[0]), nil - } - return nil, fmt.Errorf("stock.warn.insufficient.qty was not found with criteria %v", criteria) + return &((*swiqs)[0]), nil } // FindStockWarnInsufficientQtys finds stock.warn.insufficient.qty records by querying it @@ -113,11 +103,7 @@ func (c *Client) FindStockWarnInsufficientQtys(criteria *Criteria, options *Opti // FindStockWarnInsufficientQtyIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockWarnInsufficientQtyIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockWarnInsufficientQtyModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockWarnInsufficientQtyModel, criteria, options) } // FindStockWarnInsufficientQtyId finds record id by querying it with criteria. @@ -126,8 +112,5 @@ func (c *Client) FindStockWarnInsufficientQtyId(criteria *Criteria, options *Opt if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.warn.insufficient.qty was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/stock_warn_insufficient_qty_scrap.go b/stock_warn_insufficient_qty_scrap.go index ceaa8518..d26940c4 100644 --- a/stock_warn_insufficient_qty_scrap.go +++ b/stock_warn_insufficient_qty_scrap.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // StockWarnInsufficientQtyScrap represents stock.warn.insufficient.qty.scrap model. type StockWarnInsufficientQtyScrap struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -48,7 +44,7 @@ func (c *Client) CreateStockWarnInsufficientQtyScraps(swiqss []*StockWarnInsuffi for _, v := range swiqss { vv = append(vv, v) } - return c.Create(StockWarnInsufficientQtyScrapModel, vv) + return c.Create(StockWarnInsufficientQtyScrapModel, vv, nil) } // UpdateStockWarnInsufficientQtyScrap updates an existing stock.warn.insufficient.qty.scrap record. @@ -59,7 +55,7 @@ func (c *Client) UpdateStockWarnInsufficientQtyScrap(swiqs *StockWarnInsufficien // UpdateStockWarnInsufficientQtyScraps updates existing stock.warn.insufficient.qty.scrap records. // All records (represented by ids) will be updated by swiqs values. func (c *Client) UpdateStockWarnInsufficientQtyScraps(ids []int64, swiqs *StockWarnInsufficientQtyScrap) error { - return c.Update(StockWarnInsufficientQtyScrapModel, ids, swiqs) + return c.Update(StockWarnInsufficientQtyScrapModel, ids, swiqs, nil) } // DeleteStockWarnInsufficientQtyScrap deletes an existing stock.warn.insufficient.qty.scrap record. @@ -78,10 +74,7 @@ func (c *Client) GetStockWarnInsufficientQtyScrap(id int64) (*StockWarnInsuffici if err != nil { return nil, err } - if swiqss != nil && len(*swiqss) > 0 { - return &((*swiqss)[0]), nil - } - return nil, fmt.Errorf("id %v of stock.warn.insufficient.qty.scrap not found", id) + return &((*swiqss)[0]), nil } // GetStockWarnInsufficientQtyScraps gets stock.warn.insufficient.qty.scrap existing records. @@ -99,10 +92,7 @@ func (c *Client) FindStockWarnInsufficientQtyScrap(criteria *Criteria) (*StockWa if err := c.SearchRead(StockWarnInsufficientQtyScrapModel, criteria, NewOptions().Limit(1), swiqss); err != nil { return nil, err } - if swiqss != nil && len(*swiqss) > 0 { - return &((*swiqss)[0]), nil - } - return nil, fmt.Errorf("stock.warn.insufficient.qty.scrap was not found with criteria %v", criteria) + return &((*swiqss)[0]), nil } // FindStockWarnInsufficientQtyScraps finds stock.warn.insufficient.qty.scrap records by querying it @@ -118,11 +108,7 @@ func (c *Client) FindStockWarnInsufficientQtyScraps(criteria *Criteria, options // FindStockWarnInsufficientQtyScrapIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindStockWarnInsufficientQtyScrapIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(StockWarnInsufficientQtyScrapModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(StockWarnInsufficientQtyScrapModel, criteria, options) } // FindStockWarnInsufficientQtyScrapId finds record id by querying it with criteria. @@ -131,8 +117,5 @@ func (c *Client) FindStockWarnInsufficientQtyScrapId(criteria *Criteria, options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("stock.warn.insufficient.qty.scrap was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/tax_adjustments_wizard.go b/tax_adjustments_wizard.go index 43d35b0b..763f13dd 100644 --- a/tax_adjustments_wizard.go +++ b/tax_adjustments_wizard.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // TaxAdjustmentsWizard represents tax.adjustments.wizard model. type TaxAdjustmentsWizard struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -53,7 +49,7 @@ func (c *Client) CreateTaxAdjustmentsWizards(taws []*TaxAdjustmentsWizard) ([]in for _, v := range taws { vv = append(vv, v) } - return c.Create(TaxAdjustmentsWizardModel, vv) + return c.Create(TaxAdjustmentsWizardModel, vv, nil) } // UpdateTaxAdjustmentsWizard updates an existing tax.adjustments.wizard record. @@ -64,7 +60,7 @@ func (c *Client) UpdateTaxAdjustmentsWizard(taw *TaxAdjustmentsWizard) error { // UpdateTaxAdjustmentsWizards updates existing tax.adjustments.wizard records. // All records (represented by ids) will be updated by taw values. func (c *Client) UpdateTaxAdjustmentsWizards(ids []int64, taw *TaxAdjustmentsWizard) error { - return c.Update(TaxAdjustmentsWizardModel, ids, taw) + return c.Update(TaxAdjustmentsWizardModel, ids, taw, nil) } // DeleteTaxAdjustmentsWizard deletes an existing tax.adjustments.wizard record. @@ -83,10 +79,7 @@ func (c *Client) GetTaxAdjustmentsWizard(id int64) (*TaxAdjustmentsWizard, error if err != nil { return nil, err } - if taws != nil && len(*taws) > 0 { - return &((*taws)[0]), nil - } - return nil, fmt.Errorf("id %v of tax.adjustments.wizard not found", id) + return &((*taws)[0]), nil } // GetTaxAdjustmentsWizards gets tax.adjustments.wizard existing records. @@ -104,10 +97,7 @@ func (c *Client) FindTaxAdjustmentsWizard(criteria *Criteria) (*TaxAdjustmentsWi if err := c.SearchRead(TaxAdjustmentsWizardModel, criteria, NewOptions().Limit(1), taws); err != nil { return nil, err } - if taws != nil && len(*taws) > 0 { - return &((*taws)[0]), nil - } - return nil, fmt.Errorf("tax.adjustments.wizard was not found with criteria %v", criteria) + return &((*taws)[0]), nil } // FindTaxAdjustmentsWizards finds tax.adjustments.wizard records by querying it @@ -123,11 +113,7 @@ func (c *Client) FindTaxAdjustmentsWizards(criteria *Criteria, options *Options) // FindTaxAdjustmentsWizardIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindTaxAdjustmentsWizardIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(TaxAdjustmentsWizardModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(TaxAdjustmentsWizardModel, criteria, options) } // FindTaxAdjustmentsWizardId finds record id by querying it with criteria. @@ -136,8 +122,5 @@ func (c *Client) FindTaxAdjustmentsWizardId(criteria *Criteria, options *Options if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("tax.adjustments.wizard was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/utm_campaign.go b/utm_campaign.go index e91f33f9..aba5756e 100644 --- a/utm_campaign.go +++ b/utm_campaign.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // UtmCampaign represents utm.campaign model. type UtmCampaign struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateUtmCampaigns(ucs []*UtmCampaign) ([]int64, error) { for _, v := range ucs { vv = append(vv, v) } - return c.Create(UtmCampaignModel, vv) + return c.Create(UtmCampaignModel, vv, nil) } // UpdateUtmCampaign updates an existing utm.campaign record. @@ -56,7 +52,7 @@ func (c *Client) UpdateUtmCampaign(uc *UtmCampaign) error { // UpdateUtmCampaigns updates existing utm.campaign records. // All records (represented by ids) will be updated by uc values. func (c *Client) UpdateUtmCampaigns(ids []int64, uc *UtmCampaign) error { - return c.Update(UtmCampaignModel, ids, uc) + return c.Update(UtmCampaignModel, ids, uc, nil) } // DeleteUtmCampaign deletes an existing utm.campaign record. @@ -75,10 +71,7 @@ func (c *Client) GetUtmCampaign(id int64) (*UtmCampaign, error) { if err != nil { return nil, err } - if ucs != nil && len(*ucs) > 0 { - return &((*ucs)[0]), nil - } - return nil, fmt.Errorf("id %v of utm.campaign not found", id) + return &((*ucs)[0]), nil } // GetUtmCampaigns gets utm.campaign existing records. @@ -96,10 +89,7 @@ func (c *Client) FindUtmCampaign(criteria *Criteria) (*UtmCampaign, error) { if err := c.SearchRead(UtmCampaignModel, criteria, NewOptions().Limit(1), ucs); err != nil { return nil, err } - if ucs != nil && len(*ucs) > 0 { - return &((*ucs)[0]), nil - } - return nil, fmt.Errorf("utm.campaign was not found with criteria %v", criteria) + return &((*ucs)[0]), nil } // FindUtmCampaigns finds utm.campaign records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindUtmCampaigns(criteria *Criteria, options *Options) (*UtmCam // FindUtmCampaignIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindUtmCampaignIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(UtmCampaignModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(UtmCampaignModel, criteria, options) } // FindUtmCampaignId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindUtmCampaignId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("utm.campaign was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/utm_medium.go b/utm_medium.go index 221904e1..74f96b6a 100644 --- a/utm_medium.go +++ b/utm_medium.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // UtmMedium represents utm.medium model. type UtmMedium struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateUtmMediums(ums []*UtmMedium) ([]int64, error) { for _, v := range ums { vv = append(vv, v) } - return c.Create(UtmMediumModel, vv) + return c.Create(UtmMediumModel, vv, nil) } // UpdateUtmMedium updates an existing utm.medium record. @@ -57,7 +53,7 @@ func (c *Client) UpdateUtmMedium(um *UtmMedium) error { // UpdateUtmMediums updates existing utm.medium records. // All records (represented by ids) will be updated by um values. func (c *Client) UpdateUtmMediums(ids []int64, um *UtmMedium) error { - return c.Update(UtmMediumModel, ids, um) + return c.Update(UtmMediumModel, ids, um, nil) } // DeleteUtmMedium deletes an existing utm.medium record. @@ -76,10 +72,7 @@ func (c *Client) GetUtmMedium(id int64) (*UtmMedium, error) { if err != nil { return nil, err } - if ums != nil && len(*ums) > 0 { - return &((*ums)[0]), nil - } - return nil, fmt.Errorf("id %v of utm.medium not found", id) + return &((*ums)[0]), nil } // GetUtmMediums gets utm.medium existing records. @@ -97,10 +90,7 @@ func (c *Client) FindUtmMedium(criteria *Criteria) (*UtmMedium, error) { if err := c.SearchRead(UtmMediumModel, criteria, NewOptions().Limit(1), ums); err != nil { return nil, err } - if ums != nil && len(*ums) > 0 { - return &((*ums)[0]), nil - } - return nil, fmt.Errorf("utm.medium was not found with criteria %v", criteria) + return &((*ums)[0]), nil } // FindUtmMediums finds utm.medium records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindUtmMediums(criteria *Criteria, options *Options) (*UtmMediu // FindUtmMediumIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindUtmMediumIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(UtmMediumModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(UtmMediumModel, criteria, options) } // FindUtmMediumId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindUtmMediumId(criteria *Criteria, options *Options) (int64, e if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("utm.medium was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/utm_mixin.go b/utm_mixin.go index 6dd0582d..6169e2c7 100644 --- a/utm_mixin.go +++ b/utm_mixin.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // UtmMixin represents utm.mixin model. type UtmMixin struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -43,7 +39,7 @@ func (c *Client) CreateUtmMixins(ums []*UtmMixin) ([]int64, error) { for _, v := range ums { vv = append(vv, v) } - return c.Create(UtmMixinModel, vv) + return c.Create(UtmMixinModel, vv, nil) } // UpdateUtmMixin updates an existing utm.mixin record. @@ -54,7 +50,7 @@ func (c *Client) UpdateUtmMixin(um *UtmMixin) error { // UpdateUtmMixins updates existing utm.mixin records. // All records (represented by ids) will be updated by um values. func (c *Client) UpdateUtmMixins(ids []int64, um *UtmMixin) error { - return c.Update(UtmMixinModel, ids, um) + return c.Update(UtmMixinModel, ids, um, nil) } // DeleteUtmMixin deletes an existing utm.mixin record. @@ -73,10 +69,7 @@ func (c *Client) GetUtmMixin(id int64) (*UtmMixin, error) { if err != nil { return nil, err } - if ums != nil && len(*ums) > 0 { - return &((*ums)[0]), nil - } - return nil, fmt.Errorf("id %v of utm.mixin not found", id) + return &((*ums)[0]), nil } // GetUtmMixins gets utm.mixin existing records. @@ -94,10 +87,7 @@ func (c *Client) FindUtmMixin(criteria *Criteria) (*UtmMixin, error) { if err := c.SearchRead(UtmMixinModel, criteria, NewOptions().Limit(1), ums); err != nil { return nil, err } - if ums != nil && len(*ums) > 0 { - return &((*ums)[0]), nil - } - return nil, fmt.Errorf("utm.mixin was not found with criteria %v", criteria) + return &((*ums)[0]), nil } // FindUtmMixins finds utm.mixin records by querying it @@ -113,11 +103,7 @@ func (c *Client) FindUtmMixins(criteria *Criteria, options *Options) (*UtmMixins // FindUtmMixinIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindUtmMixinIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(UtmMixinModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(UtmMixinModel, criteria, options) } // FindUtmMixinId finds record id by querying it with criteria. @@ -126,8 +112,5 @@ func (c *Client) FindUtmMixinId(criteria *Criteria, options *Options) (int64, er if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("utm.mixin was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/utm_source.go b/utm_source.go index 506f2ef7..cd5c173c 100644 --- a/utm_source.go +++ b/utm_source.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // UtmSource represents utm.source model. type UtmSource struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateUtmSources(uss []*UtmSource) ([]int64, error) { for _, v := range uss { vv = append(vv, v) } - return c.Create(UtmSourceModel, vv) + return c.Create(UtmSourceModel, vv, nil) } // UpdateUtmSource updates an existing utm.source record. @@ -56,7 +52,7 @@ func (c *Client) UpdateUtmSource(us *UtmSource) error { // UpdateUtmSources updates existing utm.source records. // All records (represented by ids) will be updated by us values. func (c *Client) UpdateUtmSources(ids []int64, us *UtmSource) error { - return c.Update(UtmSourceModel, ids, us) + return c.Update(UtmSourceModel, ids, us, nil) } // DeleteUtmSource deletes an existing utm.source record. @@ -75,10 +71,7 @@ func (c *Client) GetUtmSource(id int64) (*UtmSource, error) { if err != nil { return nil, err } - if uss != nil && len(*uss) > 0 { - return &((*uss)[0]), nil - } - return nil, fmt.Errorf("id %v of utm.source not found", id) + return &((*uss)[0]), nil } // GetUtmSources gets utm.source existing records. @@ -96,10 +89,7 @@ func (c *Client) FindUtmSource(criteria *Criteria) (*UtmSource, error) { if err := c.SearchRead(UtmSourceModel, criteria, NewOptions().Limit(1), uss); err != nil { return nil, err } - if uss != nil && len(*uss) > 0 { - return &((*uss)[0]), nil - } - return nil, fmt.Errorf("utm.source was not found with criteria %v", criteria) + return &((*uss)[0]), nil } // FindUtmSources finds utm.source records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindUtmSources(criteria *Criteria, options *Options) (*UtmSourc // FindUtmSourceIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindUtmSourceIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(UtmSourceModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(UtmSourceModel, criteria, options) } // FindUtmSourceId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindUtmSourceId(criteria *Criteria, options *Options) (int64, e if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("utm.source was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/validate_account_move.go b/validate_account_move.go index 33772404..c6db8734 100644 --- a/validate_account_move.go +++ b/validate_account_move.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // ValidateAccountMove represents validate.account.move model. type ValidateAccountMove struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -44,7 +40,7 @@ func (c *Client) CreateValidateAccountMoves(vams []*ValidateAccountMove) ([]int6 for _, v := range vams { vv = append(vv, v) } - return c.Create(ValidateAccountMoveModel, vv) + return c.Create(ValidateAccountMoveModel, vv, nil) } // UpdateValidateAccountMove updates an existing validate.account.move record. @@ -55,7 +51,7 @@ func (c *Client) UpdateValidateAccountMove(vam *ValidateAccountMove) error { // UpdateValidateAccountMoves updates existing validate.account.move records. // All records (represented by ids) will be updated by vam values. func (c *Client) UpdateValidateAccountMoves(ids []int64, vam *ValidateAccountMove) error { - return c.Update(ValidateAccountMoveModel, ids, vam) + return c.Update(ValidateAccountMoveModel, ids, vam, nil) } // DeleteValidateAccountMove deletes an existing validate.account.move record. @@ -74,10 +70,7 @@ func (c *Client) GetValidateAccountMove(id int64) (*ValidateAccountMove, error) if err != nil { return nil, err } - if vams != nil && len(*vams) > 0 { - return &((*vams)[0]), nil - } - return nil, fmt.Errorf("id %v of validate.account.move not found", id) + return &((*vams)[0]), nil } // GetValidateAccountMoves gets validate.account.move existing records. @@ -95,10 +88,7 @@ func (c *Client) FindValidateAccountMove(criteria *Criteria) (*ValidateAccountMo if err := c.SearchRead(ValidateAccountMoveModel, criteria, NewOptions().Limit(1), vams); err != nil { return nil, err } - if vams != nil && len(*vams) > 0 { - return &((*vams)[0]), nil - } - return nil, fmt.Errorf("validate.account.move was not found with criteria %v", criteria) + return &((*vams)[0]), nil } // FindValidateAccountMoves finds validate.account.move records by querying it @@ -114,11 +104,7 @@ func (c *Client) FindValidateAccountMoves(criteria *Criteria, options *Options) // FindValidateAccountMoveIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindValidateAccountMoveIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(ValidateAccountMoveModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(ValidateAccountMoveModel, criteria, options) } // FindValidateAccountMoveId finds record id by querying it with criteria. @@ -127,8 +113,5 @@ func (c *Client) FindValidateAccountMoveId(criteria *Criteria, options *Options) if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("validate.account.move was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/web_editor_converter_test.go b/web_editor_converter_test.go index 905094e0..f7b3becf 100644 --- a/web_editor_converter_test.go +++ b/web_editor_converter_test.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // WebEditorConverterTest represents web_editor.converter.test model. type WebEditorConverterTest struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -56,7 +52,7 @@ func (c *Client) CreateWebEditorConverterTests(wcts []*WebEditorConverterTest) ( for _, v := range wcts { vv = append(vv, v) } - return c.Create(WebEditorConverterTestModel, vv) + return c.Create(WebEditorConverterTestModel, vv, nil) } // UpdateWebEditorConverterTest updates an existing web_editor.converter.test record. @@ -67,7 +63,7 @@ func (c *Client) UpdateWebEditorConverterTest(wct *WebEditorConverterTest) error // UpdateWebEditorConverterTests updates existing web_editor.converter.test records. // All records (represented by ids) will be updated by wct values. func (c *Client) UpdateWebEditorConverterTests(ids []int64, wct *WebEditorConverterTest) error { - return c.Update(WebEditorConverterTestModel, ids, wct) + return c.Update(WebEditorConverterTestModel, ids, wct, nil) } // DeleteWebEditorConverterTest deletes an existing web_editor.converter.test record. @@ -86,10 +82,7 @@ func (c *Client) GetWebEditorConverterTest(id int64) (*WebEditorConverterTest, e if err != nil { return nil, err } - if wcts != nil && len(*wcts) > 0 { - return &((*wcts)[0]), nil - } - return nil, fmt.Errorf("id %v of web_editor.converter.test not found", id) + return &((*wcts)[0]), nil } // GetWebEditorConverterTests gets web_editor.converter.test existing records. @@ -107,10 +100,7 @@ func (c *Client) FindWebEditorConverterTest(criteria *Criteria) (*WebEditorConve if err := c.SearchRead(WebEditorConverterTestModel, criteria, NewOptions().Limit(1), wcts); err != nil { return nil, err } - if wcts != nil && len(*wcts) > 0 { - return &((*wcts)[0]), nil - } - return nil, fmt.Errorf("web_editor.converter.test was not found with criteria %v", criteria) + return &((*wcts)[0]), nil } // FindWebEditorConverterTests finds web_editor.converter.test records by querying it @@ -126,11 +116,7 @@ func (c *Client) FindWebEditorConverterTests(criteria *Criteria, options *Option // FindWebEditorConverterTestIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindWebEditorConverterTestIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(WebEditorConverterTestModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(WebEditorConverterTestModel, criteria, options) } // FindWebEditorConverterTestId finds record id by querying it with criteria. @@ -139,8 +125,5 @@ func (c *Client) FindWebEditorConverterTestId(criteria *Criteria, options *Optio if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("web_editor.converter.test was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/web_editor_converter_test_sub.go b/web_editor_converter_test_sub.go index 4f9ae494..64edc8e2 100644 --- a/web_editor_converter_test_sub.go +++ b/web_editor_converter_test_sub.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // WebEditorConverterTestSub represents web_editor.converter.test.sub model. type WebEditorConverterTestSub struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -45,7 +41,7 @@ func (c *Client) CreateWebEditorConverterTestSubs(wctss []*WebEditorConverterTes for _, v := range wctss { vv = append(vv, v) } - return c.Create(WebEditorConverterTestSubModel, vv) + return c.Create(WebEditorConverterTestSubModel, vv, nil) } // UpdateWebEditorConverterTestSub updates an existing web_editor.converter.test.sub record. @@ -56,7 +52,7 @@ func (c *Client) UpdateWebEditorConverterTestSub(wcts *WebEditorConverterTestSub // UpdateWebEditorConverterTestSubs updates existing web_editor.converter.test.sub records. // All records (represented by ids) will be updated by wcts values. func (c *Client) UpdateWebEditorConverterTestSubs(ids []int64, wcts *WebEditorConverterTestSub) error { - return c.Update(WebEditorConverterTestSubModel, ids, wcts) + return c.Update(WebEditorConverterTestSubModel, ids, wcts, nil) } // DeleteWebEditorConverterTestSub deletes an existing web_editor.converter.test.sub record. @@ -75,10 +71,7 @@ func (c *Client) GetWebEditorConverterTestSub(id int64) (*WebEditorConverterTest if err != nil { return nil, err } - if wctss != nil && len(*wctss) > 0 { - return &((*wctss)[0]), nil - } - return nil, fmt.Errorf("id %v of web_editor.converter.test.sub not found", id) + return &((*wctss)[0]), nil } // GetWebEditorConverterTestSubs gets web_editor.converter.test.sub existing records. @@ -96,10 +89,7 @@ func (c *Client) FindWebEditorConverterTestSub(criteria *Criteria) (*WebEditorCo if err := c.SearchRead(WebEditorConverterTestSubModel, criteria, NewOptions().Limit(1), wctss); err != nil { return nil, err } - if wctss != nil && len(*wctss) > 0 { - return &((*wctss)[0]), nil - } - return nil, fmt.Errorf("web_editor.converter.test.sub was not found with criteria %v", criteria) + return &((*wctss)[0]), nil } // FindWebEditorConverterTestSubs finds web_editor.converter.test.sub records by querying it @@ -115,11 +105,7 @@ func (c *Client) FindWebEditorConverterTestSubs(criteria *Criteria, options *Opt // FindWebEditorConverterTestSubIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindWebEditorConverterTestSubIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(WebEditorConverterTestSubModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(WebEditorConverterTestSubModel, criteria, options) } // FindWebEditorConverterTestSubId finds record id by querying it with criteria. @@ -128,8 +114,5 @@ func (c *Client) FindWebEditorConverterTestSubId(criteria *Criteria, options *Op if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("web_editor.converter.test.sub was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/web_planner.go b/web_planner.go index 19fc1142..3f3f4520 100644 --- a/web_planner.go +++ b/web_planner.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // WebPlanner represents web.planner model. type WebPlanner struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -52,7 +48,7 @@ func (c *Client) CreateWebPlanners(wps []*WebPlanner) ([]int64, error) { for _, v := range wps { vv = append(vv, v) } - return c.Create(WebPlannerModel, vv) + return c.Create(WebPlannerModel, vv, nil) } // UpdateWebPlanner updates an existing web.planner record. @@ -63,7 +59,7 @@ func (c *Client) UpdateWebPlanner(wp *WebPlanner) error { // UpdateWebPlanners updates existing web.planner records. // All records (represented by ids) will be updated by wp values. func (c *Client) UpdateWebPlanners(ids []int64, wp *WebPlanner) error { - return c.Update(WebPlannerModel, ids, wp) + return c.Update(WebPlannerModel, ids, wp, nil) } // DeleteWebPlanner deletes an existing web.planner record. @@ -82,10 +78,7 @@ func (c *Client) GetWebPlanner(id int64) (*WebPlanner, error) { if err != nil { return nil, err } - if wps != nil && len(*wps) > 0 { - return &((*wps)[0]), nil - } - return nil, fmt.Errorf("id %v of web.planner not found", id) + return &((*wps)[0]), nil } // GetWebPlanners gets web.planner existing records. @@ -103,10 +96,7 @@ func (c *Client) FindWebPlanner(criteria *Criteria) (*WebPlanner, error) { if err := c.SearchRead(WebPlannerModel, criteria, NewOptions().Limit(1), wps); err != nil { return nil, err } - if wps != nil && len(*wps) > 0 { - return &((*wps)[0]), nil - } - return nil, fmt.Errorf("web.planner was not found with criteria %v", criteria) + return &((*wps)[0]), nil } // FindWebPlanners finds web.planner records by querying it @@ -122,11 +112,7 @@ func (c *Client) FindWebPlanners(criteria *Criteria, options *Options) (*WebPlan // FindWebPlannerIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindWebPlannerIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(WebPlannerModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(WebPlannerModel, criteria, options) } // FindWebPlannerId finds record id by querying it with criteria. @@ -135,8 +121,5 @@ func (c *Client) FindWebPlannerId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("web.planner was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/web_tour_tour.go b/web_tour_tour.go index 18484cec..95e775a9 100644 --- a/web_tour_tour.go +++ b/web_tour_tour.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // WebTourTour represents web_tour.tour model. type WebTourTour struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -42,7 +38,7 @@ func (c *Client) CreateWebTourTours(wts []*WebTourTour) ([]int64, error) { for _, v := range wts { vv = append(vv, v) } - return c.Create(WebTourTourModel, vv) + return c.Create(WebTourTourModel, vv, nil) } // UpdateWebTourTour updates an existing web_tour.tour record. @@ -53,7 +49,7 @@ func (c *Client) UpdateWebTourTour(wt *WebTourTour) error { // UpdateWebTourTours updates existing web_tour.tour records. // All records (represented by ids) will be updated by wt values. func (c *Client) UpdateWebTourTours(ids []int64, wt *WebTourTour) error { - return c.Update(WebTourTourModel, ids, wt) + return c.Update(WebTourTourModel, ids, wt, nil) } // DeleteWebTourTour deletes an existing web_tour.tour record. @@ -72,10 +68,7 @@ func (c *Client) GetWebTourTour(id int64) (*WebTourTour, error) { if err != nil { return nil, err } - if wts != nil && len(*wts) > 0 { - return &((*wts)[0]), nil - } - return nil, fmt.Errorf("id %v of web_tour.tour not found", id) + return &((*wts)[0]), nil } // GetWebTourTours gets web_tour.tour existing records. @@ -93,10 +86,7 @@ func (c *Client) FindWebTourTour(criteria *Criteria) (*WebTourTour, error) { if err := c.SearchRead(WebTourTourModel, criteria, NewOptions().Limit(1), wts); err != nil { return nil, err } - if wts != nil && len(*wts) > 0 { - return &((*wts)[0]), nil - } - return nil, fmt.Errorf("web_tour.tour was not found with criteria %v", criteria) + return &((*wts)[0]), nil } // FindWebTourTours finds web_tour.tour records by querying it @@ -112,11 +102,7 @@ func (c *Client) FindWebTourTours(criteria *Criteria, options *Options) (*WebTou // FindWebTourTourIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindWebTourTourIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(WebTourTourModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(WebTourTourModel, criteria, options) } // FindWebTourTourId finds record id by querying it with criteria. @@ -125,8 +111,5 @@ func (c *Client) FindWebTourTourId(criteria *Criteria, options *Options) (int64, if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("web_tour.tour was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/wizard_ir_model_menu_create.go b/wizard_ir_model_menu_create.go index 03b189cb..b08222c1 100644 --- a/wizard_ir_model_menu_create.go +++ b/wizard_ir_model_menu_create.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // WizardIrModelMenuCreate represents wizard.ir.model.menu.create model. type WizardIrModelMenuCreate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -46,7 +42,7 @@ func (c *Client) CreateWizardIrModelMenuCreates(wimmcs []*WizardIrModelMenuCreat for _, v := range wimmcs { vv = append(vv, v) } - return c.Create(WizardIrModelMenuCreateModel, vv) + return c.Create(WizardIrModelMenuCreateModel, vv, nil) } // UpdateWizardIrModelMenuCreate updates an existing wizard.ir.model.menu.create record. @@ -57,7 +53,7 @@ func (c *Client) UpdateWizardIrModelMenuCreate(wimmc *WizardIrModelMenuCreate) e // UpdateWizardIrModelMenuCreates updates existing wizard.ir.model.menu.create records. // All records (represented by ids) will be updated by wimmc values. func (c *Client) UpdateWizardIrModelMenuCreates(ids []int64, wimmc *WizardIrModelMenuCreate) error { - return c.Update(WizardIrModelMenuCreateModel, ids, wimmc) + return c.Update(WizardIrModelMenuCreateModel, ids, wimmc, nil) } // DeleteWizardIrModelMenuCreate deletes an existing wizard.ir.model.menu.create record. @@ -76,10 +72,7 @@ func (c *Client) GetWizardIrModelMenuCreate(id int64) (*WizardIrModelMenuCreate, if err != nil { return nil, err } - if wimmcs != nil && len(*wimmcs) > 0 { - return &((*wimmcs)[0]), nil - } - return nil, fmt.Errorf("id %v of wizard.ir.model.menu.create not found", id) + return &((*wimmcs)[0]), nil } // GetWizardIrModelMenuCreates gets wizard.ir.model.menu.create existing records. @@ -97,10 +90,7 @@ func (c *Client) FindWizardIrModelMenuCreate(criteria *Criteria) (*WizardIrModel if err := c.SearchRead(WizardIrModelMenuCreateModel, criteria, NewOptions().Limit(1), wimmcs); err != nil { return nil, err } - if wimmcs != nil && len(*wimmcs) > 0 { - return &((*wimmcs)[0]), nil - } - return nil, fmt.Errorf("wizard.ir.model.menu.create was not found with criteria %v", criteria) + return &((*wimmcs)[0]), nil } // FindWizardIrModelMenuCreates finds wizard.ir.model.menu.create records by querying it @@ -116,11 +106,7 @@ func (c *Client) FindWizardIrModelMenuCreates(criteria *Criteria, options *Optio // FindWizardIrModelMenuCreateIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindWizardIrModelMenuCreateIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(WizardIrModelMenuCreateModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(WizardIrModelMenuCreateModel, criteria, options) } // FindWizardIrModelMenuCreateId finds record id by querying it with criteria. @@ -129,8 +115,5 @@ func (c *Client) FindWizardIrModelMenuCreateId(criteria *Criteria, options *Opti if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("wizard.ir.model.menu.create was not found with criteria %v and options %v", criteria, options) + return ids[0], nil } diff --git a/wizard_multi_charts_accounts.go b/wizard_multi_charts_accounts.go index 860be714..a5eec917 100644 --- a/wizard_multi_charts_accounts.go +++ b/wizard_multi_charts_accounts.go @@ -1,9 +1,5 @@ package odoo -import ( - "fmt" -) - // WizardMultiChartsAccounts represents wizard.multi.charts.accounts model. type WizardMultiChartsAccounts struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` @@ -59,7 +55,7 @@ func (c *Client) CreateWizardMultiChartsAccountss(wmcas []*WizardMultiChartsAcco for _, v := range wmcas { vv = append(vv, v) } - return c.Create(WizardMultiChartsAccountsModel, vv) + return c.Create(WizardMultiChartsAccountsModel, vv, nil) } // UpdateWizardMultiChartsAccounts updates an existing wizard.multi.charts.accounts record. @@ -70,7 +66,7 @@ func (c *Client) UpdateWizardMultiChartsAccounts(wmca *WizardMultiChartsAccounts // UpdateWizardMultiChartsAccountss updates existing wizard.multi.charts.accounts records. // All records (represented by ids) will be updated by wmca values. func (c *Client) UpdateWizardMultiChartsAccountss(ids []int64, wmca *WizardMultiChartsAccounts) error { - return c.Update(WizardMultiChartsAccountsModel, ids, wmca) + return c.Update(WizardMultiChartsAccountsModel, ids, wmca, nil) } // DeleteWizardMultiChartsAccounts deletes an existing wizard.multi.charts.accounts record. @@ -89,10 +85,7 @@ func (c *Client) GetWizardMultiChartsAccounts(id int64) (*WizardMultiChartsAccou if err != nil { return nil, err } - if wmcas != nil && len(*wmcas) > 0 { - return &((*wmcas)[0]), nil - } - return nil, fmt.Errorf("id %v of wizard.multi.charts.accounts not found", id) + return &((*wmcas)[0]), nil } // GetWizardMultiChartsAccountss gets wizard.multi.charts.accounts existing records. @@ -110,10 +103,7 @@ func (c *Client) FindWizardMultiChartsAccounts(criteria *Criteria) (*WizardMulti if err := c.SearchRead(WizardMultiChartsAccountsModel, criteria, NewOptions().Limit(1), wmcas); err != nil { return nil, err } - if wmcas != nil && len(*wmcas) > 0 { - return &((*wmcas)[0]), nil - } - return nil, fmt.Errorf("wizard.multi.charts.accounts was not found with criteria %v", criteria) + return &((*wmcas)[0]), nil } // FindWizardMultiChartsAccountss finds wizard.multi.charts.accounts records by querying it @@ -129,11 +119,7 @@ func (c *Client) FindWizardMultiChartsAccountss(criteria *Criteria, options *Opt // FindWizardMultiChartsAccountsIds finds records ids by querying it // and filtering it with criteria and options. func (c *Client) FindWizardMultiChartsAccountsIds(criteria *Criteria, options *Options) ([]int64, error) { - ids, err := c.Search(WizardMultiChartsAccountsModel, criteria, options) - if err != nil { - return []int64{}, err - } - return ids, nil + return c.Search(WizardMultiChartsAccountsModel, criteria, options) } // FindWizardMultiChartsAccountsId finds record id by querying it with criteria. @@ -142,8 +128,5 @@ func (c *Client) FindWizardMultiChartsAccountsId(criteria *Criteria, options *Op if err != nil { return -1, err } - if len(ids) > 0 { - return ids[0], nil - } - return -1, fmt.Errorf("wizard.multi.charts.accounts was not found with criteria %v and options %v", criteria, options) + return ids[0], nil }