-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathir_fields_converter.go
114 lines (98 loc) · 3.95 KB
/
ir_fields_converter.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
package odoo
import (
"fmt"
)
// IrFieldsConverter represents ir.fields.converter model.
type IrFieldsConverter struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
}
// IrFieldsConverters represents array of ir.fields.converter model.
type IrFieldsConverters []IrFieldsConverter
// IrFieldsConverterModel is the odoo model name.
const IrFieldsConverterModel = "ir.fields.converter"
// Many2One convert IrFieldsConverter to *Many2One.
func (ifc *IrFieldsConverter) Many2One() *Many2One {
return NewMany2One(ifc.Id.Get(), "")
}
// CreateIrFieldsConverter creates a new ir.fields.converter model and returns its id.
func (c *Client) CreateIrFieldsConverter(ifc *IrFieldsConverter) (int64, error) {
return c.Create(IrFieldsConverterModel, ifc)
}
// UpdateIrFieldsConverter updates an existing ir.fields.converter record.
func (c *Client) UpdateIrFieldsConverter(ifc *IrFieldsConverter) error {
return c.UpdateIrFieldsConverters([]int64{ifc.Id.Get()}, ifc)
}
// UpdateIrFieldsConverters updates existing ir.fields.converter records.
// All records (represented by ids) will be updated by ifc values.
func (c *Client) UpdateIrFieldsConverters(ids []int64, ifc *IrFieldsConverter) error {
return c.Update(IrFieldsConverterModel, ids, ifc)
}
// DeleteIrFieldsConverter deletes an existing ir.fields.converter record.
func (c *Client) DeleteIrFieldsConverter(id int64) error {
return c.DeleteIrFieldsConverters([]int64{id})
}
// DeleteIrFieldsConverters deletes existing ir.fields.converter records.
func (c *Client) DeleteIrFieldsConverters(ids []int64) error {
return c.Delete(IrFieldsConverterModel, ids)
}
// GetIrFieldsConverter gets ir.fields.converter existing record.
func (c *Client) GetIrFieldsConverter(id int64) (*IrFieldsConverter, error) {
ifcs, err := c.GetIrFieldsConverters([]int64{id})
if err != nil {
return nil, err
}
if ifcs != nil && len(*ifcs) > 0 {
return &((*ifcs)[0]), nil
}
return nil, fmt.Errorf("id %v of ir.fields.converter not found", id)
}
// GetIrFieldsConverters gets ir.fields.converter existing records.
func (c *Client) GetIrFieldsConverters(ids []int64) (*IrFieldsConverters, error) {
ifcs := &IrFieldsConverters{}
if err := c.Read(IrFieldsConverterModel, ids, nil, ifcs); err != nil {
return nil, err
}
return ifcs, nil
}
// FindIrFieldsConverter finds ir.fields.converter record by querying it with criteria.
func (c *Client) FindIrFieldsConverter(criteria *Criteria) (*IrFieldsConverter, error) {
ifcs := &IrFieldsConverters{}
if err := c.SearchRead(IrFieldsConverterModel, criteria, NewOptions().Limit(1), ifcs); err != nil {
return nil, err
}
if ifcs != nil && len(*ifcs) > 0 {
return &((*ifcs)[0]), nil
}
return nil, fmt.Errorf("no ir.fields.converter was found with criteria %v", criteria)
}
// FindIrFieldsConverters finds ir.fields.converter records by querying it
// and filtering it with criteria and options.
func (c *Client) FindIrFieldsConverters(criteria *Criteria, options *Options) (*IrFieldsConverters, error) {
ifcs := &IrFieldsConverters{}
if err := c.SearchRead(IrFieldsConverterModel, criteria, options, ifcs); err != nil {
return nil, err
}
return ifcs, nil
}
// FindIrFieldsConverterIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindIrFieldsConverterIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(IrFieldsConverterModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindIrFieldsConverterId finds record id by querying it with criteria.
func (c *Client) FindIrFieldsConverterId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(IrFieldsConverterModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no ir.fields.converter was found with criteria %v and options %v", criteria, options)
}