-
Notifications
You must be signed in to change notification settings - Fork 64
/
account_fiscal_position_template.go
130 lines (114 loc) · 5.76 KB
/
account_fiscal_position_template.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package odoo
// AccountFiscalPositionTemplate represents account.fiscal.position.template model.
type AccountFiscalPositionTemplate struct {
LastUpdate *Time `xmlrpc:"__last_update,omitempty"`
AccountIds *Relation `xmlrpc:"account_ids,omitempty"`
AutoApply *Bool `xmlrpc:"auto_apply,omitempty"`
ChartTemplateId *Many2One `xmlrpc:"chart_template_id,omitempty"`
CountryGroupId *Many2One `xmlrpc:"country_group_id,omitempty"`
CountryId *Many2One `xmlrpc:"country_id,omitempty"`
CreateDate *Time `xmlrpc:"create_date,omitempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omitempty"`
DisplayName *String `xmlrpc:"display_name,omitempty"`
Id *Int `xmlrpc:"id,omitempty"`
Name *String `xmlrpc:"name,omitempty"`
Note *String `xmlrpc:"note,omitempty"`
Sequence *Int `xmlrpc:"sequence,omitempty"`
StateIds *Relation `xmlrpc:"state_ids,omitempty"`
TaxIds *Relation `xmlrpc:"tax_ids,omitempty"`
VatRequired *Bool `xmlrpc:"vat_required,omitempty"`
WriteDate *Time `xmlrpc:"write_date,omitempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omitempty"`
ZipFrom *Int `xmlrpc:"zip_from,omitempty"`
ZipTo *Int `xmlrpc:"zip_to,omitempty"`
}
// AccountFiscalPositionTemplates represents array of account.fiscal.position.template model.
type AccountFiscalPositionTemplates []AccountFiscalPositionTemplate
// AccountFiscalPositionTemplateModel is the odoo model name.
const AccountFiscalPositionTemplateModel = "account.fiscal.position.template"
// Many2One convert AccountFiscalPositionTemplate to *Many2One.
func (afpt *AccountFiscalPositionTemplate) Many2One() *Many2One {
return NewMany2One(afpt.Id.Get(), "")
}
// CreateAccountFiscalPositionTemplate creates a new account.fiscal.position.template model and returns its id.
func (c *Client) CreateAccountFiscalPositionTemplate(afpt *AccountFiscalPositionTemplate) (int64, error) {
ids, err := c.CreateAccountFiscalPositionTemplates([]*AccountFiscalPositionTemplate{afpt})
if err != nil {
return -1, err
}
if len(ids) == 0 {
return -1, nil
}
return ids[0], nil
}
// CreateAccountFiscalPositionTemplates creates a new account.fiscal.position.template model and returns its id.
func (c *Client) CreateAccountFiscalPositionTemplates(afpts []*AccountFiscalPositionTemplate) ([]int64, error) {
var vv []interface{}
for _, v := range afpts {
vv = append(vv, v)
}
return c.Create(AccountFiscalPositionTemplateModel, vv, nil)
}
// UpdateAccountFiscalPositionTemplate updates an existing account.fiscal.position.template record.
func (c *Client) UpdateAccountFiscalPositionTemplate(afpt *AccountFiscalPositionTemplate) error {
return c.UpdateAccountFiscalPositionTemplates([]int64{afpt.Id.Get()}, afpt)
}
// 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, nil)
}
// DeleteAccountFiscalPositionTemplate deletes an existing account.fiscal.position.template record.
func (c *Client) DeleteAccountFiscalPositionTemplate(id int64) error {
return c.DeleteAccountFiscalPositionTemplates([]int64{id})
}
// DeleteAccountFiscalPositionTemplates deletes existing account.fiscal.position.template records.
func (c *Client) DeleteAccountFiscalPositionTemplates(ids []int64) error {
return c.Delete(AccountFiscalPositionTemplateModel, ids)
}
// GetAccountFiscalPositionTemplate gets account.fiscal.position.template existing record.
func (c *Client) GetAccountFiscalPositionTemplate(id int64) (*AccountFiscalPositionTemplate, error) {
afpts, err := c.GetAccountFiscalPositionTemplates([]int64{id})
if err != nil {
return nil, err
}
return &((*afpts)[0]), nil
}
// GetAccountFiscalPositionTemplates gets account.fiscal.position.template existing records.
func (c *Client) GetAccountFiscalPositionTemplates(ids []int64) (*AccountFiscalPositionTemplates, error) {
afpts := &AccountFiscalPositionTemplates{}
if err := c.Read(AccountFiscalPositionTemplateModel, ids, nil, afpts); err != nil {
return nil, err
}
return afpts, nil
}
// FindAccountFiscalPositionTemplate finds account.fiscal.position.template record by querying it with criteria.
func (c *Client) FindAccountFiscalPositionTemplate(criteria *Criteria) (*AccountFiscalPositionTemplate, error) {
afpts := &AccountFiscalPositionTemplates{}
if err := c.SearchRead(AccountFiscalPositionTemplateModel, criteria, NewOptions().Limit(1), afpts); err != nil {
return nil, err
}
return &((*afpts)[0]), nil
}
// FindAccountFiscalPositionTemplates finds account.fiscal.position.template records by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountFiscalPositionTemplates(criteria *Criteria, options *Options) (*AccountFiscalPositionTemplates, error) {
afpts := &AccountFiscalPositionTemplates{}
if err := c.SearchRead(AccountFiscalPositionTemplateModel, criteria, options, afpts); err != nil {
return nil, err
}
return afpts, nil
}
// FindAccountFiscalPositionTemplateIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountFiscalPositionTemplateIds(criteria *Criteria, options *Options) ([]int64, error) {
return c.Search(AccountFiscalPositionTemplateModel, criteria, options)
}
// FindAccountFiscalPositionTemplateId finds record id by querying it with criteria.
func (c *Client) FindAccountFiscalPositionTemplateId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(AccountFiscalPositionTemplateModel, criteria, options)
if err != nil {
return -1, err
}
return ids[0], nil
}