-
Notifications
You must be signed in to change notification settings - Fork 64
/
account_fiscal_position_tax_template.go
120 lines (104 loc) · 5.4 KB
/
account_fiscal_position_tax_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
package odoo
// AccountFiscalPositionTaxTemplate represents account.fiscal.position.tax.template model.
type AccountFiscalPositionTaxTemplate struct {
LastUpdate *Time `xmlrpc:"__last_update,omitempty"`
CreateDate *Time `xmlrpc:"create_date,omitempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omitempty"`
DisplayName *String `xmlrpc:"display_name,omitempty"`
Id *Int `xmlrpc:"id,omitempty"`
PositionId *Many2One `xmlrpc:"position_id,omitempty"`
TaxDestId *Many2One `xmlrpc:"tax_dest_id,omitempty"`
TaxSrcId *Many2One `xmlrpc:"tax_src_id,omitempty"`
WriteDate *Time `xmlrpc:"write_date,omitempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omitempty"`
}
// AccountFiscalPositionTaxTemplates represents array of account.fiscal.position.tax.template model.
type AccountFiscalPositionTaxTemplates []AccountFiscalPositionTaxTemplate
// AccountFiscalPositionTaxTemplateModel is the odoo model name.
const AccountFiscalPositionTaxTemplateModel = "account.fiscal.position.tax.template"
// Many2One convert AccountFiscalPositionTaxTemplate to *Many2One.
func (afptt *AccountFiscalPositionTaxTemplate) Many2One() *Many2One {
return NewMany2One(afptt.Id.Get(), "")
}
// CreateAccountFiscalPositionTaxTemplate creates a new account.fiscal.position.tax.template model and returns its id.
func (c *Client) CreateAccountFiscalPositionTaxTemplate(afptt *AccountFiscalPositionTaxTemplate) (int64, error) {
ids, err := c.CreateAccountFiscalPositionTaxTemplates([]*AccountFiscalPositionTaxTemplate{afptt})
if err != nil {
return -1, err
}
if len(ids) == 0 {
return -1, nil
}
return ids[0], nil
}
// CreateAccountFiscalPositionTaxTemplates creates a new account.fiscal.position.tax.template model and returns its id.
func (c *Client) CreateAccountFiscalPositionTaxTemplates(afptts []*AccountFiscalPositionTaxTemplate) ([]int64, error) {
var vv []interface{}
for _, v := range afptts {
vv = append(vv, v)
}
return c.Create(AccountFiscalPositionTaxTemplateModel, vv, nil)
}
// UpdateAccountFiscalPositionTaxTemplate updates an existing account.fiscal.position.tax.template record.
func (c *Client) UpdateAccountFiscalPositionTaxTemplate(afptt *AccountFiscalPositionTaxTemplate) error {
return c.UpdateAccountFiscalPositionTaxTemplates([]int64{afptt.Id.Get()}, afptt)
}
// 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, nil)
}
// DeleteAccountFiscalPositionTaxTemplate deletes an existing account.fiscal.position.tax.template record.
func (c *Client) DeleteAccountFiscalPositionTaxTemplate(id int64) error {
return c.DeleteAccountFiscalPositionTaxTemplates([]int64{id})
}
// DeleteAccountFiscalPositionTaxTemplates deletes existing account.fiscal.position.tax.template records.
func (c *Client) DeleteAccountFiscalPositionTaxTemplates(ids []int64) error {
return c.Delete(AccountFiscalPositionTaxTemplateModel, ids)
}
// GetAccountFiscalPositionTaxTemplate gets account.fiscal.position.tax.template existing record.
func (c *Client) GetAccountFiscalPositionTaxTemplate(id int64) (*AccountFiscalPositionTaxTemplate, error) {
afptts, err := c.GetAccountFiscalPositionTaxTemplates([]int64{id})
if err != nil {
return nil, err
}
return &((*afptts)[0]), nil
}
// GetAccountFiscalPositionTaxTemplates gets account.fiscal.position.tax.template existing records.
func (c *Client) GetAccountFiscalPositionTaxTemplates(ids []int64) (*AccountFiscalPositionTaxTemplates, error) {
afptts := &AccountFiscalPositionTaxTemplates{}
if err := c.Read(AccountFiscalPositionTaxTemplateModel, ids, nil, afptts); err != nil {
return nil, err
}
return afptts, nil
}
// FindAccountFiscalPositionTaxTemplate finds account.fiscal.position.tax.template record by querying it with criteria.
func (c *Client) FindAccountFiscalPositionTaxTemplate(criteria *Criteria) (*AccountFiscalPositionTaxTemplate, error) {
afptts := &AccountFiscalPositionTaxTemplates{}
if err := c.SearchRead(AccountFiscalPositionTaxTemplateModel, criteria, NewOptions().Limit(1), afptts); err != nil {
return nil, err
}
return &((*afptts)[0]), nil
}
// FindAccountFiscalPositionTaxTemplates finds account.fiscal.position.tax.template records by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountFiscalPositionTaxTemplates(criteria *Criteria, options *Options) (*AccountFiscalPositionTaxTemplates, error) {
afptts := &AccountFiscalPositionTaxTemplates{}
if err := c.SearchRead(AccountFiscalPositionTaxTemplateModel, criteria, options, afptts); err != nil {
return nil, err
}
return afptts, nil
}
// FindAccountFiscalPositionTaxTemplateIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAccountFiscalPositionTaxTemplateIds(criteria *Criteria, options *Options) ([]int64, error) {
return c.Search(AccountFiscalPositionTaxTemplateModel, criteria, options)
}
// FindAccountFiscalPositionTaxTemplateId finds record id by querying it with criteria.
func (c *Client) FindAccountFiscalPositionTaxTemplateId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(AccountFiscalPositionTaxTemplateModel, criteria, options)
if err != nil {
return -1, err
}
return ids[0], nil
}