-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathstock_location_path.go
131 lines (115 loc) · 4.94 KB
/
stock_location_path.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
127
128
129
130
131
package odoo
import (
"fmt"
)
// StockLocationPath represents stock.location.path model.
type StockLocationPath struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Active *Bool `xmlrpc:"active,omptempty"`
Auto *Selection `xmlrpc:"auto,omptempty"`
CompanyId *Many2One `xmlrpc:"company_id,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
Delay *Int `xmlrpc:"delay,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
LocationDestId *Many2One `xmlrpc:"location_dest_id,omptempty"`
LocationFromId *Many2One `xmlrpc:"location_from_id,omptempty"`
Name *String `xmlrpc:"name,omptempty"`
PickingTypeId *Many2One `xmlrpc:"picking_type_id,omptempty"`
Propagate *Bool `xmlrpc:"propagate,omptempty"`
RouteId *Many2One `xmlrpc:"route_id,omptempty"`
RouteSequence *Int `xmlrpc:"route_sequence,omptempty"`
Sequence *Int `xmlrpc:"sequence,omptempty"`
WarehouseId *Many2One `xmlrpc:"warehouse_id,omptempty"`
WriteDate *Time `xmlrpc:"write_date,omptempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}
// StockLocationPaths represents array of stock.location.path model.
type StockLocationPaths []StockLocationPath
// StockLocationPathModel is the odoo model name.
const StockLocationPathModel = "stock.location.path"
// Many2One convert StockLocationPath to *Many2One.
func (slp *StockLocationPath) Many2One() *Many2One {
return NewMany2One(slp.Id.Get(), "")
}
// CreateStockLocationPath creates a new stock.location.path model and returns its id.
func (c *Client) CreateStockLocationPath(slp *StockLocationPath) (int64, error) {
return c.Create(StockLocationPathModel, slp)
}
// UpdateStockLocationPath updates an existing stock.location.path record.
func (c *Client) UpdateStockLocationPath(slp *StockLocationPath) error {
return c.UpdateStockLocationPaths([]int64{slp.Id.Get()}, slp)
}
// UpdateStockLocationPaths updates existing stock.location.path records.
// All records (represented by ids) will be updated by slp values.
func (c *Client) UpdateStockLocationPaths(ids []int64, slp *StockLocationPath) error {
return c.Update(StockLocationPathModel, ids, slp)
}
// DeleteStockLocationPath deletes an existing stock.location.path record.
func (c *Client) DeleteStockLocationPath(id int64) error {
return c.DeleteStockLocationPaths([]int64{id})
}
// DeleteStockLocationPaths deletes existing stock.location.path records.
func (c *Client) DeleteStockLocationPaths(ids []int64) error {
return c.Delete(StockLocationPathModel, ids)
}
// GetStockLocationPath gets stock.location.path existing record.
func (c *Client) GetStockLocationPath(id int64) (*StockLocationPath, error) {
slps, err := c.GetStockLocationPaths([]int64{id})
if err != nil {
return nil, err
}
if slps != nil && len(*slps) > 0 {
return &((*slps)[0]), nil
}
return nil, fmt.Errorf("id %v of stock.location.path not found", id)
}
// GetStockLocationPaths gets stock.location.path existing records.
func (c *Client) GetStockLocationPaths(ids []int64) (*StockLocationPaths, error) {
slps := &StockLocationPaths{}
if err := c.Read(StockLocationPathModel, ids, nil, slps); err != nil {
return nil, err
}
return slps, nil
}
// FindStockLocationPath finds stock.location.path record by querying it with criteria.
func (c *Client) FindStockLocationPath(criteria *Criteria) (*StockLocationPath, error) {
slps := &StockLocationPaths{}
if err := c.SearchRead(StockLocationPathModel, criteria, NewOptions().Limit(1), slps); err != nil {
return nil, err
}
if slps != nil && len(*slps) > 0 {
return &((*slps)[0]), nil
}
return nil, fmt.Errorf("no stock.location.path was found with criteria %v", criteria)
}
// FindStockLocationPaths finds stock.location.path records by querying it
// and filtering it with criteria and options.
func (c *Client) FindStockLocationPaths(criteria *Criteria, options *Options) (*StockLocationPaths, error) {
slps := &StockLocationPaths{}
if err := c.SearchRead(StockLocationPathModel, criteria, options, slps); err != nil {
return nil, err
}
return slps, nil
}
// FindStockLocationPathIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindStockLocationPathIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(StockLocationPathModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindStockLocationPathId finds record id by querying it with criteria.
func (c *Client) FindStockLocationPathId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(StockLocationPathModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no stock.location.path was found with criteria %v and options %v", criteria, options)
}