-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathir_qweb.go
114 lines (98 loc) · 3.19 KB
/
ir_qweb.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"
)
// IrQweb represents ir.qweb model.
type IrQweb struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
}
// IrQwebs represents array of ir.qweb model.
type IrQwebs []IrQweb
// IrQwebModel is the odoo model name.
const IrQwebModel = "ir.qweb"
// Many2One convert IrQweb to *Many2One.
func (iq *IrQweb) Many2One() *Many2One {
return NewMany2One(iq.Id.Get(), "")
}
// CreateIrQweb creates a new ir.qweb model and returns its id.
func (c *Client) CreateIrQweb(iq *IrQweb) (int64, error) {
return c.Create(IrQwebModel, iq)
}
// UpdateIrQweb updates an existing ir.qweb record.
func (c *Client) UpdateIrQweb(iq *IrQweb) error {
return c.UpdateIrQwebs([]int64{iq.Id.Get()}, iq)
}
// UpdateIrQwebs updates existing ir.qweb records.
// All records (represented by ids) will be updated by iq values.
func (c *Client) UpdateIrQwebs(ids []int64, iq *IrQweb) error {
return c.Update(IrQwebModel, ids, iq)
}
// DeleteIrQweb deletes an existing ir.qweb record.
func (c *Client) DeleteIrQweb(id int64) error {
return c.DeleteIrQwebs([]int64{id})
}
// DeleteIrQwebs deletes existing ir.qweb records.
func (c *Client) DeleteIrQwebs(ids []int64) error {
return c.Delete(IrQwebModel, ids)
}
// GetIrQweb gets ir.qweb existing record.
func (c *Client) GetIrQweb(id int64) (*IrQweb, error) {
iqs, err := c.GetIrQwebs([]int64{id})
if err != nil {
return nil, err
}
if iqs != nil && len(*iqs) > 0 {
return &((*iqs)[0]), nil
}
return nil, fmt.Errorf("id %v of ir.qweb not found", id)
}
// GetIrQwebs gets ir.qweb existing records.
func (c *Client) GetIrQwebs(ids []int64) (*IrQwebs, error) {
iqs := &IrQwebs{}
if err := c.Read(IrQwebModel, ids, nil, iqs); err != nil {
return nil, err
}
return iqs, nil
}
// FindIrQweb finds ir.qweb record by querying it with criteria.
func (c *Client) FindIrQweb(criteria *Criteria) (*IrQweb, error) {
iqs := &IrQwebs{}
if err := c.SearchRead(IrQwebModel, criteria, NewOptions().Limit(1), iqs); err != nil {
return nil, err
}
if iqs != nil && len(*iqs) > 0 {
return &((*iqs)[0]), nil
}
return nil, fmt.Errorf("no ir.qweb was found with criteria %v", criteria)
}
// FindIrQwebs finds ir.qweb records by querying it
// and filtering it with criteria and options.
func (c *Client) FindIrQwebs(criteria *Criteria, options *Options) (*IrQwebs, error) {
iqs := &IrQwebs{}
if err := c.SearchRead(IrQwebModel, criteria, options, iqs); err != nil {
return nil, err
}
return iqs, nil
}
// FindIrQwebIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindIrQwebIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(IrQwebModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindIrQwebId finds record id by querying it with criteria.
func (c *Client) FindIrQwebId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(IrQwebModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no ir.qweb was found with criteria %v and options %v", criteria, options)
}