forked from skilld-labs/go-odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
barcodes_barcode_events_mixin.go
115 lines (99 loc) · 4.52 KB
/
barcodes_barcode_events_mixin.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
package odoo
import (
"fmt"
)
// BarcodesBarcodeEventsMixin represents barcodes.barcode_events_mixin model.
type BarcodesBarcodeEventsMixin struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
BarcodeScanned *String `xmlrpc:"_barcode_scanned,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
}
// BarcodesBarcodeEventsMixins represents array of barcodes.barcode_events_mixin model.
type BarcodesBarcodeEventsMixins []BarcodesBarcodeEventsMixin
// BarcodesBarcodeEventsMixinModel is the odoo model name.
const BarcodesBarcodeEventsMixinModel = "barcodes.barcode_events_mixin"
// Many2One convert BarcodesBarcodeEventsMixin to *Many2One.
func (bb *BarcodesBarcodeEventsMixin) Many2One() *Many2One {
return NewMany2One(bb.Id.Get(), "")
}
// CreateBarcodesBarcodeEventsMixin creates a new barcodes.barcode_events_mixin model and returns its id.
func (c *Client) CreateBarcodesBarcodeEventsMixin(bb *BarcodesBarcodeEventsMixin) (int64, error) {
return c.Create(BarcodesBarcodeEventsMixinModel, bb)
}
// UpdateBarcodesBarcodeEventsMixin updates an existing barcodes.barcode_events_mixin record.
func (c *Client) UpdateBarcodesBarcodeEventsMixin(bb *BarcodesBarcodeEventsMixin) error {
return c.UpdateBarcodesBarcodeEventsMixins([]int64{bb.Id.Get()}, bb)
}
// UpdateBarcodesBarcodeEventsMixins updates existing barcodes.barcode_events_mixin records.
// All records (represented by ids) will be updated by bb values.
func (c *Client) UpdateBarcodesBarcodeEventsMixins(ids []int64, bb *BarcodesBarcodeEventsMixin) error {
return c.Update(BarcodesBarcodeEventsMixinModel, ids, bb)
}
// DeleteBarcodesBarcodeEventsMixin deletes an existing barcodes.barcode_events_mixin record.
func (c *Client) DeleteBarcodesBarcodeEventsMixin(id int64) error {
return c.DeleteBarcodesBarcodeEventsMixins([]int64{id})
}
// DeleteBarcodesBarcodeEventsMixins deletes existing barcodes.barcode_events_mixin records.
func (c *Client) DeleteBarcodesBarcodeEventsMixins(ids []int64) error {
return c.Delete(BarcodesBarcodeEventsMixinModel, ids)
}
// GetBarcodesBarcodeEventsMixin gets barcodes.barcode_events_mixin existing record.
func (c *Client) GetBarcodesBarcodeEventsMixin(id int64) (*BarcodesBarcodeEventsMixin, error) {
bbs, err := c.GetBarcodesBarcodeEventsMixins([]int64{id})
if err != nil {
return nil, err
}
if bbs != nil && len(*bbs) > 0 {
return &((*bbs)[0]), nil
}
return nil, fmt.Errorf("id %v of barcodes.barcode_events_mixin not found", id)
}
// GetBarcodesBarcodeEventsMixins gets barcodes.barcode_events_mixin existing records.
func (c *Client) GetBarcodesBarcodeEventsMixins(ids []int64) (*BarcodesBarcodeEventsMixins, error) {
bbs := &BarcodesBarcodeEventsMixins{}
if err := c.Read(BarcodesBarcodeEventsMixinModel, ids, nil, bbs); err != nil {
return nil, err
}
return bbs, nil
}
// FindBarcodesBarcodeEventsMixin finds barcodes.barcode_events_mixin record by querying it with criteria.
func (c *Client) FindBarcodesBarcodeEventsMixin(criteria *Criteria) (*BarcodesBarcodeEventsMixin, error) {
bbs := &BarcodesBarcodeEventsMixins{}
if err := c.SearchRead(BarcodesBarcodeEventsMixinModel, criteria, NewOptions().Limit(1), bbs); err != nil {
return nil, err
}
if bbs != nil && len(*bbs) > 0 {
return &((*bbs)[0]), nil
}
return nil, fmt.Errorf("barcodes.barcode_events_mixin was not found")
}
// FindBarcodesBarcodeEventsMixins finds barcodes.barcode_events_mixin records by querying it
// and filtering it with criteria and options.
func (c *Client) FindBarcodesBarcodeEventsMixins(criteria *Criteria, options *Options) (*BarcodesBarcodeEventsMixins, error) {
bbs := &BarcodesBarcodeEventsMixins{}
if err := c.SearchRead(BarcodesBarcodeEventsMixinModel, criteria, options, bbs); err != nil {
return nil, err
}
return bbs, nil
}
// FindBarcodesBarcodeEventsMixinIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindBarcodesBarcodeEventsMixinIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(BarcodesBarcodeEventsMixinModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindBarcodesBarcodeEventsMixinId finds record id by querying it with criteria.
func (c *Client) FindBarcodesBarcodeEventsMixinId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(BarcodesBarcodeEventsMixinModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("barcodes.barcode_events_mixin was not found")
}