Skip to content

Commit 6b74ea2

Browse files
author
Antoine Huret
committed
changed create low level function to create multiple instances in one api call, added high level methods and changed template accordingly
1 parent ebddbd1 commit 6b74ea2

File tree

365 files changed

+6178
-1115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

365 files changed

+6178
-1115
lines changed

account_abstract_payment.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,23 @@ func (aap *AccountAbstractPayment) Many2One() *Many2One {
3636

3737
// CreateAccountAbstractPayment creates a new account.abstract.payment model and returns its id.
3838
func (c *Client) CreateAccountAbstractPayment(aap *AccountAbstractPayment) (int64, error) {
39-
return c.Create(AccountAbstractPaymentModel, aap)
39+
ids, err := c.Create(AccountAbstractPaymentModel, []interface{}{aap})
40+
if err != nil {
41+
return -1, err
42+
}
43+
if len(ids) == 0 {
44+
return -1, nil
45+
}
46+
return ids[0], nil
47+
}
48+
49+
// CreateAccountAbstractPayment creates a new account.abstract.payment model and returns its id.
50+
func (c *Client) CreateAccountAbstractPayments(aaps []*AccountAbstractPayment) ([]int64, error) {
51+
var vv []interface{}
52+
for _, v := range aaps {
53+
vv = append(vv, v)
54+
}
55+
return c.Create(AccountAbstractPaymentModel, vv)
4056
}
4157

4258
// UpdateAccountAbstractPayment updates an existing account.abstract.payment record.

account_account.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,23 @@ func (aa *AccountAccount) Many2One() *Many2One {
4343

4444
// CreateAccountAccount creates a new account.account model and returns its id.
4545
func (c *Client) CreateAccountAccount(aa *AccountAccount) (int64, error) {
46-
return c.Create(AccountAccountModel, aa)
46+
ids, err := c.Create(AccountAccountModel, []interface{}{aa})
47+
if err != nil {
48+
return -1, err
49+
}
50+
if len(ids) == 0 {
51+
return -1, nil
52+
}
53+
return ids[0], nil
54+
}
55+
56+
// CreateAccountAccount creates a new account.account model and returns its id.
57+
func (c *Client) CreateAccountAccounts(aas []*AccountAccount) ([]int64, error) {
58+
var vv []interface{}
59+
for _, v := range aas {
60+
vv = append(vv, v)
61+
}
62+
return c.Create(AccountAccountModel, vv)
4763
}
4864

4965
// UpdateAccountAccount updates an existing account.account record.

account_account_tag.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,23 @@ func (aat *AccountAccountTag) Many2One() *Many2One {
3232

3333
// CreateAccountAccountTag creates a new account.account.tag model and returns its id.
3434
func (c *Client) CreateAccountAccountTag(aat *AccountAccountTag) (int64, error) {
35-
return c.Create(AccountAccountTagModel, aat)
35+
ids, err := c.Create(AccountAccountTagModel, []interface{}{aat})
36+
if err != nil {
37+
return -1, err
38+
}
39+
if len(ids) == 0 {
40+
return -1, nil
41+
}
42+
return ids[0], nil
43+
}
44+
45+
// CreateAccountAccountTag creates a new account.account.tag model and returns its id.
46+
func (c *Client) CreateAccountAccountTags(aats []*AccountAccountTag) ([]int64, error) {
47+
var vv []interface{}
48+
for _, v := range aats {
49+
vv = append(vv, v)
50+
}
51+
return c.Create(AccountAccountTagModel, vv)
3652
}
3753

3854
// UpdateAccountAccountTag updates an existing account.account.tag record.

account_account_template.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,23 @@ func (aat *AccountAccountTemplate) Many2One() *Many2One {
3939

4040
// CreateAccountAccountTemplate creates a new account.account.template model and returns its id.
4141
func (c *Client) CreateAccountAccountTemplate(aat *AccountAccountTemplate) (int64, error) {
42-
return c.Create(AccountAccountTemplateModel, aat)
42+
ids, err := c.Create(AccountAccountTemplateModel, []interface{}{aat})
43+
if err != nil {
44+
return -1, err
45+
}
46+
if len(ids) == 0 {
47+
return -1, nil
48+
}
49+
return ids[0], nil
50+
}
51+
52+
// CreateAccountAccountTemplate creates a new account.account.template model and returns its id.
53+
func (c *Client) CreateAccountAccountTemplates(aats []*AccountAccountTemplate) ([]int64, error) {
54+
var vv []interface{}
55+
for _, v := range aats {
56+
vv = append(vv, v)
57+
}
58+
return c.Create(AccountAccountTemplateModel, vv)
4359
}
4460

4561
// UpdateAccountAccountTemplate updates an existing account.account.template record.

account_account_type.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,23 @@ func (aat *AccountAccountType) Many2One() *Many2One {
3232

3333
// CreateAccountAccountType creates a new account.account.type model and returns its id.
3434
func (c *Client) CreateAccountAccountType(aat *AccountAccountType) (int64, error) {
35-
return c.Create(AccountAccountTypeModel, aat)
35+
ids, err := c.Create(AccountAccountTypeModel, []interface{}{aat})
36+
if err != nil {
37+
return -1, err
38+
}
39+
if len(ids) == 0 {
40+
return -1, nil
41+
}
42+
return ids[0], nil
43+
}
44+
45+
// CreateAccountAccountType creates a new account.account.type model and returns its id.
46+
func (c *Client) CreateAccountAccountTypes(aats []*AccountAccountType) ([]int64, error) {
47+
var vv []interface{}
48+
for _, v := range aats {
49+
vv = append(vv, v)
50+
}
51+
return c.Create(AccountAccountTypeModel, vv)
3652
}
3753

3854
// UpdateAccountAccountType updates an existing account.account.type record.

account_aged_trial_balance.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,23 @@ func (aatb *AccountAgedTrialBalance) Many2One() *Many2One {
3535

3636
// CreateAccountAgedTrialBalance creates a new account.aged.trial.balance model and returns its id.
3737
func (c *Client) CreateAccountAgedTrialBalance(aatb *AccountAgedTrialBalance) (int64, error) {
38-
return c.Create(AccountAgedTrialBalanceModel, aatb)
38+
ids, err := c.Create(AccountAgedTrialBalanceModel, []interface{}{aatb})
39+
if err != nil {
40+
return -1, err
41+
}
42+
if len(ids) == 0 {
43+
return -1, nil
44+
}
45+
return ids[0], nil
46+
}
47+
48+
// CreateAccountAgedTrialBalance creates a new account.aged.trial.balance model and returns its id.
49+
func (c *Client) CreateAccountAgedTrialBalances(aatbs []*AccountAgedTrialBalance) ([]int64, error) {
50+
var vv []interface{}
51+
for _, v := range aatbs {
52+
vv = append(vv, v)
53+
}
54+
return c.Create(AccountAgedTrialBalanceModel, vv)
3955
}
4056

4157
// UpdateAccountAgedTrialBalance updates an existing account.aged.trial.balance record.

account_analytic_account.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type AccountAnalyticAccount struct {
2020
DisplayName *String `xmlrpc:"display_name,omptempty"`
2121
Id *Int `xmlrpc:"id,omptempty"`
2222
LineIds *Relation `xmlrpc:"line_ids,omptempty"`
23-
MachineProjectName *String `xmlrpc:"machine_project_name,omptempty"`
23+
MachineInitiativeName *String `xmlrpc:"machine_initiative_name,omptempty"`
2424
MessageChannelIds *Relation `xmlrpc:"message_channel_ids,omptempty"`
2525
MessageFollowerIds *Relation `xmlrpc:"message_follower_ids,omptempty"`
2626
MessageIds *Relation `xmlrpc:"message_ids,omptempty"`
@@ -34,7 +34,6 @@ type AccountAnalyticAccount struct {
3434
Name *String `xmlrpc:"name,omptempty"`
3535
PartnerId *Many2One `xmlrpc:"partner_id,omptempty"`
3636
ProjectCount *Int `xmlrpc:"project_count,omptempty"`
37-
ProjectCreated *Bool `xmlrpc:"project_created,omptempty"`
3837
ProjectIds *Relation `xmlrpc:"project_ids,omptempty"`
3938
TagIds *Relation `xmlrpc:"tag_ids,omptempty"`
4039
WebsiteMessageIds *Relation `xmlrpc:"website_message_ids,omptempty"`
@@ -55,7 +54,23 @@ func (aaa *AccountAnalyticAccount) Many2One() *Many2One {
5554

5655
// CreateAccountAnalyticAccount creates a new account.analytic.account model and returns its id.
5756
func (c *Client) CreateAccountAnalyticAccount(aaa *AccountAnalyticAccount) (int64, error) {
58-
return c.Create(AccountAnalyticAccountModel, aaa)
57+
ids, err := c.Create(AccountAnalyticAccountModel, []interface{}{aaa})
58+
if err != nil {
59+
return -1, err
60+
}
61+
if len(ids) == 0 {
62+
return -1, nil
63+
}
64+
return ids[0], nil
65+
}
66+
67+
// CreateAccountAnalyticAccount creates a new account.analytic.account model and returns its id.
68+
func (c *Client) CreateAccountAnalyticAccounts(aaas []*AccountAnalyticAccount) ([]int64, error) {
69+
var vv []interface{}
70+
for _, v := range aaas {
71+
vv = append(vv, v)
72+
}
73+
return c.Create(AccountAnalyticAccountModel, vv)
5974
}
6075

6176
// UpdateAccountAnalyticAccount updates an existing account.analytic.account record.

account_analytic_line.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,23 @@ func (aal *AccountAnalyticLine) Many2One() *Many2One {
5656

5757
// CreateAccountAnalyticLine creates a new account.analytic.line model and returns its id.
5858
func (c *Client) CreateAccountAnalyticLine(aal *AccountAnalyticLine) (int64, error) {
59-
return c.Create(AccountAnalyticLineModel, aal)
59+
ids, err := c.Create(AccountAnalyticLineModel, []interface{}{aal})
60+
if err != nil {
61+
return -1, err
62+
}
63+
if len(ids) == 0 {
64+
return -1, nil
65+
}
66+
return ids[0], nil
67+
}
68+
69+
// CreateAccountAnalyticLine creates a new account.analytic.line model and returns its id.
70+
func (c *Client) CreateAccountAnalyticLines(aals []*AccountAnalyticLine) ([]int64, error) {
71+
var vv []interface{}
72+
for _, v := range aals {
73+
vv = append(vv, v)
74+
}
75+
return c.Create(AccountAnalyticLineModel, vv)
6076
}
6177

6278
// UpdateAccountAnalyticLine updates an existing account.analytic.line record.

account_analytic_tag.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,23 @@ func (aat *AccountAnalyticTag) Many2One() *Many2One {
3131

3232
// CreateAccountAnalyticTag creates a new account.analytic.tag model and returns its id.
3333
func (c *Client) CreateAccountAnalyticTag(aat *AccountAnalyticTag) (int64, error) {
34-
return c.Create(AccountAnalyticTagModel, aat)
34+
ids, err := c.Create(AccountAnalyticTagModel, []interface{}{aat})
35+
if err != nil {
36+
return -1, err
37+
}
38+
if len(ids) == 0 {
39+
return -1, nil
40+
}
41+
return ids[0], nil
42+
}
43+
44+
// CreateAccountAnalyticTag creates a new account.analytic.tag model and returns its id.
45+
func (c *Client) CreateAccountAnalyticTags(aats []*AccountAnalyticTag) ([]int64, error) {
46+
var vv []interface{}
47+
for _, v := range aats {
48+
vv = append(vv, v)
49+
}
50+
return c.Create(AccountAnalyticTagModel, vv)
3551
}
3652

3753
// UpdateAccountAnalyticTag updates an existing account.analytic.tag record.

account_balance_report.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,23 @@ func (abr *AccountBalanceReport) Many2One() *Many2One {
3434

3535
// CreateAccountBalanceReport creates a new account.balance.report model and returns its id.
3636
func (c *Client) CreateAccountBalanceReport(abr *AccountBalanceReport) (int64, error) {
37-
return c.Create(AccountBalanceReportModel, abr)
37+
ids, err := c.Create(AccountBalanceReportModel, []interface{}{abr})
38+
if err != nil {
39+
return -1, err
40+
}
41+
if len(ids) == 0 {
42+
return -1, nil
43+
}
44+
return ids[0], nil
45+
}
46+
47+
// CreateAccountBalanceReport creates a new account.balance.report model and returns its id.
48+
func (c *Client) CreateAccountBalanceReports(abrs []*AccountBalanceReport) ([]int64, error) {
49+
var vv []interface{}
50+
for _, v := range abrs {
51+
vv = append(vv, v)
52+
}
53+
return c.Create(AccountBalanceReportModel, vv)
3854
}
3955

4056
// UpdateAccountBalanceReport updates an existing account.balance.report record.

0 commit comments

Comments
 (0)