-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathir_qweb_field_selection.go
114 lines (98 loc) · 4.18 KB
/
ir_qweb_field_selection.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"
)
// IrQwebFieldSelection represents ir.qweb.field.selection model.
type IrQwebFieldSelection struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
}
// IrQwebFieldSelections represents array of ir.qweb.field.selection model.
type IrQwebFieldSelections []IrQwebFieldSelection
// IrQwebFieldSelectionModel is the odoo model name.
const IrQwebFieldSelectionModel = "ir.qweb.field.selection"
// Many2One convert IrQwebFieldSelection to *Many2One.
func (iqfs *IrQwebFieldSelection) Many2One() *Many2One {
return NewMany2One(iqfs.Id.Get(), "")
}
// CreateIrQwebFieldSelection creates a new ir.qweb.field.selection model and returns its id.
func (c *Client) CreateIrQwebFieldSelection(iqfs *IrQwebFieldSelection) (int64, error) {
return c.Create(IrQwebFieldSelectionModel, iqfs)
}
// UpdateIrQwebFieldSelection updates an existing ir.qweb.field.selection record.
func (c *Client) UpdateIrQwebFieldSelection(iqfs *IrQwebFieldSelection) error {
return c.UpdateIrQwebFieldSelections([]int64{iqfs.Id.Get()}, iqfs)
}
// UpdateIrQwebFieldSelections updates existing ir.qweb.field.selection records.
// All records (represented by ids) will be updated by iqfs values.
func (c *Client) UpdateIrQwebFieldSelections(ids []int64, iqfs *IrQwebFieldSelection) error {
return c.Update(IrQwebFieldSelectionModel, ids, iqfs)
}
// DeleteIrQwebFieldSelection deletes an existing ir.qweb.field.selection record.
func (c *Client) DeleteIrQwebFieldSelection(id int64) error {
return c.DeleteIrQwebFieldSelections([]int64{id})
}
// DeleteIrQwebFieldSelections deletes existing ir.qweb.field.selection records.
func (c *Client) DeleteIrQwebFieldSelections(ids []int64) error {
return c.Delete(IrQwebFieldSelectionModel, ids)
}
// GetIrQwebFieldSelection gets ir.qweb.field.selection existing record.
func (c *Client) GetIrQwebFieldSelection(id int64) (*IrQwebFieldSelection, error) {
iqfss, err := c.GetIrQwebFieldSelections([]int64{id})
if err != nil {
return nil, err
}
if iqfss != nil && len(*iqfss) > 0 {
return &((*iqfss)[0]), nil
}
return nil, fmt.Errorf("id %v of ir.qweb.field.selection not found", id)
}
// GetIrQwebFieldSelections gets ir.qweb.field.selection existing records.
func (c *Client) GetIrQwebFieldSelections(ids []int64) (*IrQwebFieldSelections, error) {
iqfss := &IrQwebFieldSelections{}
if err := c.Read(IrQwebFieldSelectionModel, ids, nil, iqfss); err != nil {
return nil, err
}
return iqfss, nil
}
// FindIrQwebFieldSelection finds ir.qweb.field.selection record by querying it with criteria.
func (c *Client) FindIrQwebFieldSelection(criteria *Criteria) (*IrQwebFieldSelection, error) {
iqfss := &IrQwebFieldSelections{}
if err := c.SearchRead(IrQwebFieldSelectionModel, criteria, NewOptions().Limit(1), iqfss); err != nil {
return nil, err
}
if iqfss != nil && len(*iqfss) > 0 {
return &((*iqfss)[0]), nil
}
return nil, fmt.Errorf("no ir.qweb.field.selection was found with criteria %v", criteria)
}
// FindIrQwebFieldSelections finds ir.qweb.field.selection records by querying it
// and filtering it with criteria and options.
func (c *Client) FindIrQwebFieldSelections(criteria *Criteria, options *Options) (*IrQwebFieldSelections, error) {
iqfss := &IrQwebFieldSelections{}
if err := c.SearchRead(IrQwebFieldSelectionModel, criteria, options, iqfss); err != nil {
return nil, err
}
return iqfss, nil
}
// FindIrQwebFieldSelectionIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindIrQwebFieldSelectionIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(IrQwebFieldSelectionModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindIrQwebFieldSelectionId finds record id by querying it with criteria.
func (c *Client) FindIrQwebFieldSelectionId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(IrQwebFieldSelectionModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no ir.qweb.field.selection was found with criteria %v and options %v", criteria, options)
}