forked from skilld-labs/go-odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_fiscal_position_tax_template.go
137 lines (120 loc) · 5.89 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package odoo
import (
"fmt"
)
// AccountFiscalPositionTaxTemplate represents account.fiscal.position.tax.template model.
type AccountFiscalPositionTaxTemplate struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
PositionId *Many2One `xmlrpc:"position_id,omptempty"`
TaxDestId *Many2One `xmlrpc:"tax_dest_id,omptempty"`
TaxSrcId *Many2One `xmlrpc:"tax_src_id,omptempty"`
WriteDate *Time `xmlrpc:"write_date,omptempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}
// 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
}
// CreateAccountFiscalPositionTaxTemplate 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)
}
// 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)
}
// 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
}
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)
}
// 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
}
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)
}
// 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) {
ids, err := c.Search(AccountFiscalPositionTaxTemplateModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// 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
}
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)
}