-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathpublisher_warranty_contract.go
114 lines (98 loc) · 4.45 KB
/
publisher_warranty_contract.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"
)
// PublisherWarrantyContract represents publisher_warranty.contract model.
type PublisherWarrantyContract struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
}
// PublisherWarrantyContracts represents array of publisher_warranty.contract model.
type PublisherWarrantyContracts []PublisherWarrantyContract
// PublisherWarrantyContractModel is the odoo model name.
const PublisherWarrantyContractModel = "publisher_warranty.contract"
// Many2One convert PublisherWarrantyContract to *Many2One.
func (pc *PublisherWarrantyContract) Many2One() *Many2One {
return NewMany2One(pc.Id.Get(), "")
}
// CreatePublisherWarrantyContract creates a new publisher_warranty.contract model and returns its id.
func (c *Client) CreatePublisherWarrantyContract(pc *PublisherWarrantyContract) (int64, error) {
return c.Create(PublisherWarrantyContractModel, pc)
}
// UpdatePublisherWarrantyContract updates an existing publisher_warranty.contract record.
func (c *Client) UpdatePublisherWarrantyContract(pc *PublisherWarrantyContract) error {
return c.UpdatePublisherWarrantyContracts([]int64{pc.Id.Get()}, pc)
}
// UpdatePublisherWarrantyContracts updates existing publisher_warranty.contract records.
// All records (represented by ids) will be updated by pc values.
func (c *Client) UpdatePublisherWarrantyContracts(ids []int64, pc *PublisherWarrantyContract) error {
return c.Update(PublisherWarrantyContractModel, ids, pc)
}
// DeletePublisherWarrantyContract deletes an existing publisher_warranty.contract record.
func (c *Client) DeletePublisherWarrantyContract(id int64) error {
return c.DeletePublisherWarrantyContracts([]int64{id})
}
// DeletePublisherWarrantyContracts deletes existing publisher_warranty.contract records.
func (c *Client) DeletePublisherWarrantyContracts(ids []int64) error {
return c.Delete(PublisherWarrantyContractModel, ids)
}
// GetPublisherWarrantyContract gets publisher_warranty.contract existing record.
func (c *Client) GetPublisherWarrantyContract(id int64) (*PublisherWarrantyContract, error) {
pcs, err := c.GetPublisherWarrantyContracts([]int64{id})
if err != nil {
return nil, err
}
if pcs != nil && len(*pcs) > 0 {
return &((*pcs)[0]), nil
}
return nil, fmt.Errorf("id %v of publisher_warranty.contract not found", id)
}
// GetPublisherWarrantyContracts gets publisher_warranty.contract existing records.
func (c *Client) GetPublisherWarrantyContracts(ids []int64) (*PublisherWarrantyContracts, error) {
pcs := &PublisherWarrantyContracts{}
if err := c.Read(PublisherWarrantyContractModel, ids, nil, pcs); err != nil {
return nil, err
}
return pcs, nil
}
// FindPublisherWarrantyContract finds publisher_warranty.contract record by querying it with criteria.
func (c *Client) FindPublisherWarrantyContract(criteria *Criteria) (*PublisherWarrantyContract, error) {
pcs := &PublisherWarrantyContracts{}
if err := c.SearchRead(PublisherWarrantyContractModel, criteria, NewOptions().Limit(1), pcs); err != nil {
return nil, err
}
if pcs != nil && len(*pcs) > 0 {
return &((*pcs)[0]), nil
}
return nil, fmt.Errorf("no publisher_warranty.contract was found with criteria %v", criteria)
}
// FindPublisherWarrantyContracts finds publisher_warranty.contract records by querying it
// and filtering it with criteria and options.
func (c *Client) FindPublisherWarrantyContracts(criteria *Criteria, options *Options) (*PublisherWarrantyContracts, error) {
pcs := &PublisherWarrantyContracts{}
if err := c.SearchRead(PublisherWarrantyContractModel, criteria, options, pcs); err != nil {
return nil, err
}
return pcs, nil
}
// FindPublisherWarrantyContractIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindPublisherWarrantyContractIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(PublisherWarrantyContractModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindPublisherWarrantyContractId finds record id by querying it with criteria.
func (c *Client) FindPublisherWarrantyContractId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(PublisherWarrantyContractModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no publisher_warranty.contract was found with criteria %v and options %v", criteria, options)
}