Skip to content

Commit bb6d596

Browse files
authored
Making errors more verbose + generating missing models (#35)
1 parent e429767 commit bb6d596

File tree

361 files changed

+44327
-1161
lines changed

Some content is hidden

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

361 files changed

+44327
-1161
lines changed

account_abstract_payment.go

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package odoo
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// AccountAbstractPayment represents account.abstract.payment model.
8+
type AccountAbstractPayment struct {
9+
LastUpdate *Time `xmlrpc:"__last_update,omitempty"`
10+
Amount *Float `xmlrpc:"amount,omitempty"`
11+
Communication *String `xmlrpc:"communication,omitempty"`
12+
CompanyId *Many2One `xmlrpc:"company_id,omitempty"`
13+
CurrencyId *Many2One `xmlrpc:"currency_id,omitempty"`
14+
DisplayName *String `xmlrpc:"display_name,omitempty"`
15+
HidePaymentMethod *Bool `xmlrpc:"hide_payment_method,omitempty"`
16+
Id *Int `xmlrpc:"id,omitempty"`
17+
JournalId *Many2One `xmlrpc:"journal_id,omitempty"`
18+
PartnerId *Many2One `xmlrpc:"partner_id,omitempty"`
19+
PartnerType *Selection `xmlrpc:"partner_type,omitempty"`
20+
PaymentDate *Time `xmlrpc:"payment_date,omitempty"`
21+
PaymentMethodCode *String `xmlrpc:"payment_method_code,omitempty"`
22+
PaymentMethodId *Many2One `xmlrpc:"payment_method_id,omitempty"`
23+
PaymentType *Selection `xmlrpc:"payment_type,omitempty"`
24+
}
25+
26+
// AccountAbstractPayments represents array of account.abstract.payment model.
27+
type AccountAbstractPayments []AccountAbstractPayment
28+
29+
// AccountAbstractPaymentModel is the odoo model name.
30+
const AccountAbstractPaymentModel = "account.abstract.payment"
31+
32+
// Many2One convert AccountAbstractPayment to *Many2One.
33+
func (aap *AccountAbstractPayment) Many2One() *Many2One {
34+
return NewMany2One(aap.Id.Get(), "")
35+
}
36+
37+
// CreateAccountAbstractPayment creates a new account.abstract.payment model and returns its id.
38+
func (c *Client) CreateAccountAbstractPayment(aap *AccountAbstractPayment) (int64, error) {
39+
return c.Create(AccountAbstractPaymentModel, aap)
40+
}
41+
42+
// UpdateAccountAbstractPayment updates an existing account.abstract.payment record.
43+
func (c *Client) UpdateAccountAbstractPayment(aap *AccountAbstractPayment) error {
44+
return c.UpdateAccountAbstractPayments([]int64{aap.Id.Get()}, aap)
45+
}
46+
47+
// UpdateAccountAbstractPayments updates existing account.abstract.payment records.
48+
// All records (represented by ids) will be updated by aap values.
49+
func (c *Client) UpdateAccountAbstractPayments(ids []int64, aap *AccountAbstractPayment) error {
50+
return c.Update(AccountAbstractPaymentModel, ids, aap)
51+
}
52+
53+
// DeleteAccountAbstractPayment deletes an existing account.abstract.payment record.
54+
func (c *Client) DeleteAccountAbstractPayment(id int64) error {
55+
return c.DeleteAccountAbstractPayments([]int64{id})
56+
}
57+
58+
// DeleteAccountAbstractPayments deletes existing account.abstract.payment records.
59+
func (c *Client) DeleteAccountAbstractPayments(ids []int64) error {
60+
return c.Delete(AccountAbstractPaymentModel, ids)
61+
}
62+
63+
// GetAccountAbstractPayment gets account.abstract.payment existing record.
64+
func (c *Client) GetAccountAbstractPayment(id int64) (*AccountAbstractPayment, error) {
65+
aaps, err := c.GetAccountAbstractPayments([]int64{id})
66+
if err != nil {
67+
return nil, err
68+
}
69+
if aaps != nil && len(*aaps) > 0 {
70+
return &((*aaps)[0]), nil
71+
}
72+
return nil, fmt.Errorf("id %v of account.abstract.payment not found", id)
73+
}
74+
75+
// GetAccountAbstractPayments gets account.abstract.payment existing records.
76+
func (c *Client) GetAccountAbstractPayments(ids []int64) (*AccountAbstractPayments, error) {
77+
aaps := &AccountAbstractPayments{}
78+
if err := c.Read(AccountAbstractPaymentModel, ids, nil, aaps); err != nil {
79+
return nil, err
80+
}
81+
return aaps, nil
82+
}
83+
84+
// FindAccountAbstractPayment finds account.abstract.payment record by querying it with criteria.
85+
func (c *Client) FindAccountAbstractPayment(criteria *Criteria) (*AccountAbstractPayment, error) {
86+
aaps := &AccountAbstractPayments{}
87+
if err := c.SearchRead(AccountAbstractPaymentModel, criteria, NewOptions().Limit(1), aaps); err != nil {
88+
return nil, err
89+
}
90+
if aaps != nil && len(*aaps) > 0 {
91+
return &((*aaps)[0]), nil
92+
}
93+
return nil, fmt.Errorf("no account.abstract.payment was found with criteria %v", criteria)
94+
}
95+
96+
// FindAccountAbstractPayments finds account.abstract.payment records by querying it
97+
// and filtering it with criteria and options.
98+
func (c *Client) FindAccountAbstractPayments(criteria *Criteria, options *Options) (*AccountAbstractPayments, error) {
99+
aaps := &AccountAbstractPayments{}
100+
if err := c.SearchRead(AccountAbstractPaymentModel, criteria, options, aaps); err != nil {
101+
return nil, err
102+
}
103+
return aaps, nil
104+
}
105+
106+
// FindAccountAbstractPaymentIds finds records ids by querying it
107+
// and filtering it with criteria and options.
108+
func (c *Client) FindAccountAbstractPaymentIds(criteria *Criteria, options *Options) ([]int64, error) {
109+
ids, err := c.Search(AccountAbstractPaymentModel, criteria, options)
110+
if err != nil {
111+
return []int64{}, err
112+
}
113+
return ids, nil
114+
}
115+
116+
// FindAccountAbstractPaymentId finds record id by querying it with criteria.
117+
func (c *Client) FindAccountAbstractPaymentId(criteria *Criteria, options *Options) (int64, error) {
118+
ids, err := c.Search(AccountAbstractPaymentModel, criteria, options)
119+
if err != nil {
120+
return -1, err
121+
}
122+
if len(ids) > 0 {
123+
return ids[0], nil
124+
}
125+
return -1, fmt.Errorf("no account.abstract.payment was found with criteria %v and options %v", criteria, options)
126+
}

account_account.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@ import (
66

77
// AccountAccount represents account.account model.
88
type AccountAccount struct {
9-
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
10-
Code *String `xmlrpc:"code,omptempty"`
11-
CompanyId *Many2One `xmlrpc:"company_id,omptempty"`
12-
CreateDate *Time `xmlrpc:"create_date,omptempty"`
13-
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
14-
CurrencyId *Many2One `xmlrpc:"currency_id,omptempty"`
15-
Deprecated *Bool `xmlrpc:"deprecated,omptempty"`
16-
DisplayName *String `xmlrpc:"display_name,omptempty"`
17-
GroupId *Many2One `xmlrpc:"group_id,omptempty"`
18-
Id *Int `xmlrpc:"id,omptempty"`
19-
InternalType *Selection `xmlrpc:"internal_type,omptempty"`
20-
LastTimeEntriesChecked *Time `xmlrpc:"last_time_entries_checked,omptempty"`
21-
Name *String `xmlrpc:"name,omptempty"`
22-
Note *String `xmlrpc:"note,omptempty"`
23-
OpeningCredit *Float `xmlrpc:"opening_credit,omptempty"`
24-
OpeningDebit *Float `xmlrpc:"opening_debit,omptempty"`
25-
Reconcile *Bool `xmlrpc:"reconcile,omptempty"`
26-
TagIds *Relation `xmlrpc:"tag_ids,omptempty"`
27-
TaxIds *Relation `xmlrpc:"tax_ids,omptempty"`
28-
UserTypeId *Many2One `xmlrpc:"user_type_id,omptempty"`
29-
WriteDate *Time `xmlrpc:"write_date,omptempty"`
30-
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
9+
LastUpdate *Time `xmlrpc:"__last_update,omitempty"`
10+
Code *String `xmlrpc:"code,omitempty"`
11+
CompanyId *Many2One `xmlrpc:"company_id,omitempty"`
12+
CreateDate *Time `xmlrpc:"create_date,omitempty"`
13+
CreateUid *Many2One `xmlrpc:"create_uid,omitempty"`
14+
CurrencyId *Many2One `xmlrpc:"currency_id,omitempty"`
15+
Deprecated *Bool `xmlrpc:"deprecated,omitempty"`
16+
DisplayName *String `xmlrpc:"display_name,omitempty"`
17+
GroupId *Many2One `xmlrpc:"group_id,omitempty"`
18+
Id *Int `xmlrpc:"id,omitempty"`
19+
InternalType *Selection `xmlrpc:"internal_type,omitempty"`
20+
LastTimeEntriesChecked *Time `xmlrpc:"last_time_entries_checked,omitempty"`
21+
Name *String `xmlrpc:"name,omitempty"`
22+
Note *String `xmlrpc:"note,omitempty"`
23+
OpeningCredit *Float `xmlrpc:"opening_credit,omitempty"`
24+
OpeningDebit *Float `xmlrpc:"opening_debit,omitempty"`
25+
Reconcile *Bool `xmlrpc:"reconcile,omitempty"`
26+
TagIds *Relation `xmlrpc:"tag_ids,omitempty"`
27+
TaxIds *Relation `xmlrpc:"tax_ids,omitempty"`
28+
UserTypeId *Many2One `xmlrpc:"user_type_id,omitempty"`
29+
WriteDate *Time `xmlrpc:"write_date,omitempty"`
30+
WriteUid *Many2One `xmlrpc:"write_uid,omitempty"`
3131
}
3232

3333
// AccountAccounts represents array of account.account model.
@@ -97,7 +97,7 @@ func (c *Client) FindAccountAccount(criteria *Criteria) (*AccountAccount, error)
9797
if aas != nil && len(*aas) > 0 {
9898
return &((*aas)[0]), nil
9999
}
100-
return nil, fmt.Errorf("account.account was not found")
100+
return nil, fmt.Errorf("no account.account was found with criteria %v", criteria)
101101
}
102102

103103
// FindAccountAccounts finds account.account records by querying it
@@ -129,5 +129,5 @@ func (c *Client) FindAccountAccountId(criteria *Criteria, options *Options) (int
129129
if len(ids) > 0 {
130130
return ids[0], nil
131131
}
132-
return -1, fmt.Errorf("account.account was not found")
132+
return -1, fmt.Errorf("no account.account was found with criteria %v and options %v", criteria, options)
133133
}

account_account_tag.go

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
package odoo
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// AccountAccountTag represents account.account.tag model.
8+
type AccountAccountTag struct {
9+
LastUpdate *Time `xmlrpc:"__last_update,omitempty"`
10+
Active *Bool `xmlrpc:"active,omitempty"`
11+
Applicability *Selection `xmlrpc:"applicability,omitempty"`
12+
Color *Int `xmlrpc:"color,omitempty"`
13+
CreateDate *Time `xmlrpc:"create_date,omitempty"`
14+
CreateUid *Many2One `xmlrpc:"create_uid,omitempty"`
15+
DisplayName *String `xmlrpc:"display_name,omitempty"`
16+
Id *Int `xmlrpc:"id,omitempty"`
17+
Name *String `xmlrpc:"name,omitempty"`
18+
WriteDate *Time `xmlrpc:"write_date,omitempty"`
19+
WriteUid *Many2One `xmlrpc:"write_uid,omitempty"`
20+
}
21+
22+
// AccountAccountTags represents array of account.account.tag model.
23+
type AccountAccountTags []AccountAccountTag
24+
25+
// AccountAccountTagModel is the odoo model name.
26+
const AccountAccountTagModel = "account.account.tag"
27+
28+
// Many2One convert AccountAccountTag to *Many2One.
29+
func (aat *AccountAccountTag) Many2One() *Many2One {
30+
return NewMany2One(aat.Id.Get(), "")
31+
}
32+
33+
// CreateAccountAccountTag creates a new account.account.tag model and returns its id.
34+
func (c *Client) CreateAccountAccountTag(aat *AccountAccountTag) (int64, error) {
35+
return c.Create(AccountAccountTagModel, aat)
36+
}
37+
38+
// UpdateAccountAccountTag updates an existing account.account.tag record.
39+
func (c *Client) UpdateAccountAccountTag(aat *AccountAccountTag) error {
40+
return c.UpdateAccountAccountTags([]int64{aat.Id.Get()}, aat)
41+
}
42+
43+
// UpdateAccountAccountTags updates existing account.account.tag records.
44+
// All records (represented by ids) will be updated by aat values.
45+
func (c *Client) UpdateAccountAccountTags(ids []int64, aat *AccountAccountTag) error {
46+
return c.Update(AccountAccountTagModel, ids, aat)
47+
}
48+
49+
// DeleteAccountAccountTag deletes an existing account.account.tag record.
50+
func (c *Client) DeleteAccountAccountTag(id int64) error {
51+
return c.DeleteAccountAccountTags([]int64{id})
52+
}
53+
54+
// DeleteAccountAccountTags deletes existing account.account.tag records.
55+
func (c *Client) DeleteAccountAccountTags(ids []int64) error {
56+
return c.Delete(AccountAccountTagModel, ids)
57+
}
58+
59+
// GetAccountAccountTag gets account.account.tag existing record.
60+
func (c *Client) GetAccountAccountTag(id int64) (*AccountAccountTag, error) {
61+
aats, err := c.GetAccountAccountTags([]int64{id})
62+
if err != nil {
63+
return nil, err
64+
}
65+
if aats != nil && len(*aats) > 0 {
66+
return &((*aats)[0]), nil
67+
}
68+
return nil, fmt.Errorf("id %v of account.account.tag not found", id)
69+
}
70+
71+
// GetAccountAccountTags gets account.account.tag existing records.
72+
func (c *Client) GetAccountAccountTags(ids []int64) (*AccountAccountTags, error) {
73+
aats := &AccountAccountTags{}
74+
if err := c.Read(AccountAccountTagModel, ids, nil, aats); err != nil {
75+
return nil, err
76+
}
77+
return aats, nil
78+
}
79+
80+
// FindAccountAccountTag finds account.account.tag record by querying it with criteria.
81+
func (c *Client) FindAccountAccountTag(criteria *Criteria) (*AccountAccountTag, error) {
82+
aats := &AccountAccountTags{}
83+
if err := c.SearchRead(AccountAccountTagModel, criteria, NewOptions().Limit(1), aats); err != nil {
84+
return nil, err
85+
}
86+
if aats != nil && len(*aats) > 0 {
87+
return &((*aats)[0]), nil
88+
}
89+
return nil, fmt.Errorf("no account.account.tag was found with criteria %v", criteria)
90+
}
91+
92+
// FindAccountAccountTags finds account.account.tag records by querying it
93+
// and filtering it with criteria and options.
94+
func (c *Client) FindAccountAccountTags(criteria *Criteria, options *Options) (*AccountAccountTags, error) {
95+
aats := &AccountAccountTags{}
96+
if err := c.SearchRead(AccountAccountTagModel, criteria, options, aats); err != nil {
97+
return nil, err
98+
}
99+
return aats, nil
100+
}
101+
102+
// FindAccountAccountTagIds finds records ids by querying it
103+
// and filtering it with criteria and options.
104+
func (c *Client) FindAccountAccountTagIds(criteria *Criteria, options *Options) ([]int64, error) {
105+
ids, err := c.Search(AccountAccountTagModel, criteria, options)
106+
if err != nil {
107+
return []int64{}, err
108+
}
109+
return ids, nil
110+
}
111+
112+
// FindAccountAccountTagId finds record id by querying it with criteria.
113+
func (c *Client) FindAccountAccountTagId(criteria *Criteria, options *Options) (int64, error) {
114+
ids, err := c.Search(AccountAccountTagModel, criteria, options)
115+
if err != nil {
116+
return -1, err
117+
}
118+
if len(ids) > 0 {
119+
return ids[0], nil
120+
}
121+
return -1, fmt.Errorf("no account.account.tag was found with criteria %v and options %v", criteria, options)
122+
}

0 commit comments

Comments
 (0)