-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathir_logging.go
126 lines (110 loc) · 4.01 KB
/
ir_logging.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
package odoo
import (
"fmt"
)
// IrLogging represents ir.logging model.
type IrLogging struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Int `xmlrpc:"create_uid,omptempty"`
Dbname *String `xmlrpc:"dbname,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Func *String `xmlrpc:"func,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
Level *String `xmlrpc:"level,omptempty"`
Line *String `xmlrpc:"line,omptempty"`
Message *String `xmlrpc:"message,omptempty"`
Name *String `xmlrpc:"name,omptempty"`
Path *String `xmlrpc:"path,omptempty"`
Type *Selection `xmlrpc:"type,omptempty"`
WriteDate *Time `xmlrpc:"write_date,omptempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}
// IrLoggings represents array of ir.logging model.
type IrLoggings []IrLogging
// IrLoggingModel is the odoo model name.
const IrLoggingModel = "ir.logging"
// Many2One convert IrLogging to *Many2One.
func (il *IrLogging) Many2One() *Many2One {
return NewMany2One(il.Id.Get(), "")
}
// CreateIrLogging creates a new ir.logging model and returns its id.
func (c *Client) CreateIrLogging(il *IrLogging) (int64, error) {
return c.Create(IrLoggingModel, il)
}
// UpdateIrLogging updates an existing ir.logging record.
func (c *Client) UpdateIrLogging(il *IrLogging) error {
return c.UpdateIrLoggings([]int64{il.Id.Get()}, il)
}
// UpdateIrLoggings updates existing ir.logging records.
// All records (represented by ids) will be updated by il values.
func (c *Client) UpdateIrLoggings(ids []int64, il *IrLogging) error {
return c.Update(IrLoggingModel, ids, il)
}
// DeleteIrLogging deletes an existing ir.logging record.
func (c *Client) DeleteIrLogging(id int64) error {
return c.DeleteIrLoggings([]int64{id})
}
// DeleteIrLoggings deletes existing ir.logging records.
func (c *Client) DeleteIrLoggings(ids []int64) error {
return c.Delete(IrLoggingModel, ids)
}
// GetIrLogging gets ir.logging existing record.
func (c *Client) GetIrLogging(id int64) (*IrLogging, error) {
ils, err := c.GetIrLoggings([]int64{id})
if err != nil {
return nil, err
}
if ils != nil && len(*ils) > 0 {
return &((*ils)[0]), nil
}
return nil, fmt.Errorf("id %v of ir.logging not found", id)
}
// GetIrLoggings gets ir.logging existing records.
func (c *Client) GetIrLoggings(ids []int64) (*IrLoggings, error) {
ils := &IrLoggings{}
if err := c.Read(IrLoggingModel, ids, nil, ils); err != nil {
return nil, err
}
return ils, nil
}
// FindIrLogging finds ir.logging record by querying it with criteria.
func (c *Client) FindIrLogging(criteria *Criteria) (*IrLogging, error) {
ils := &IrLoggings{}
if err := c.SearchRead(IrLoggingModel, criteria, NewOptions().Limit(1), ils); err != nil {
return nil, err
}
if ils != nil && len(*ils) > 0 {
return &((*ils)[0]), nil
}
return nil, fmt.Errorf("no ir.logging was found with criteria %v", criteria)
}
// FindIrLoggings finds ir.logging records by querying it
// and filtering it with criteria and options.
func (c *Client) FindIrLoggings(criteria *Criteria, options *Options) (*IrLoggings, error) {
ils := &IrLoggings{}
if err := c.SearchRead(IrLoggingModel, criteria, options, ils); err != nil {
return nil, err
}
return ils, nil
}
// FindIrLoggingIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindIrLoggingIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(IrLoggingModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindIrLoggingId finds record id by querying it with criteria.
func (c *Client) FindIrLoggingId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(IrLoggingModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no ir.logging was found with criteria %v and options %v", criteria, options)
}