forked from skilld-labs/go-odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathres_partner_category.go
104 lines (90 loc) · 3.88 KB
/
res_partner_category.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
package odoo
import (
"fmt"
)
// ResPartnerCategory represents res.partner.category model
type ResPartnerCategory struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Active *Bool `xmlrpc:"active,omptempty"`
ChildIds *Relation `xmlrpc:"child_ids,omptempty"`
Color *Int `xmlrpc:"color,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
Name *String `xmlrpc:"name,omptempty"`
ParentId *Many2One `xmlrpc:"parent_id,omptempty"`
ParentLeft *Int `xmlrpc:"parent_left,omptempty"`
ParentRight *Int `xmlrpc:"parent_right,omptempty"`
PartnerIds *Relation `xmlrpc:"partner_ids,omptempty"`
WriteDate *Time `xmlrpc:"write_date,omptempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}
// ResPartnerCategorys represents array of res.partner.category model
type ResPartnerCategorys []ResPartnerCategory
// ResPartnerCategoryModel is the odoo model name
const ResPartnerCategoryModel = "res.partner.category"
// Many2One convert ResPartnerCategory to *Many2One.
func (rpc *ResPartnerCategory) Many2One() *Many2One {
return NewMany2One(rpc.Id.Get(), "")
}
// CreateResPartnerCategory creates a new res.partner.category model and returns its id.
func (c *Client) CreateResPartnerCategory(rpc *ResPartnerCategory) (int64, error) {
return c.Create(ResPartnerCategoryModel, rpc)
}
// UpdateResPartnerCategory updates an existing res.partner.category record.
func (c *Client) UpdateResPartnerCategory(rpc *ResPartnerCategory) error {
return c.UpdateResPartnerCategorys([]int64{rpc.Id.Get()}, rpc)
}
// UpdateResPartnerCategorys updates existing res.partner.category records.
// All records (represented by ids) will be updated by rpc values.
func (c *Client) UpdateResPartnerCategorys(ids []int64, rpc *ResPartnerCategory) error {
return c.Update(ResPartnerCategoryModel, ids, rpc)
}
// DeleteResPartnerCategory deletes an existing res.partner.category record.
func (c *Client) DeleteResPartnerCategory(id int64) error {
return c.DeleteResPartnerCategorys([]int64{id})
}
// DeleteResPartnerCategorys deletes existing res.partner.category records.
func (c *Client) DeleteResPartnerCategorys(ids []int64) error {
return c.Delete(ResPartnerCategoryModel, ids)
}
// GetResPartnerCategory gets res.partner.category existing record.
func (c *Client) GetResPartnerCategory(id int64) (*ResPartnerCategory, error) {
rpcs, err := c.GetResPartnerCategorys([]int64{id})
if err != nil {
return nil, err
}
if rpcs != nil && len(*rpcs) > 0 {
return &((*rpcs)[0]), nil
}
return nil, fmt.Errorf("id %v of %s not found", id, ResPartnerCategoryModel)
}
// GetResPartnerCategorys gets res.partner.category existing records.
func (c *Client) GetResPartnerCategorys(ids []int64) (*ResPartnerCategorys, error) {
rpcs := &ResPartnerCategorys{}
if err := c.Read(ResPartnerCategoryModel, ids, nil, rpcs); err != nil {
return nil, err
}
return rpcs, nil
}
// FindResPartnerCategory finds res.partner.category record by querying it with criteria
func (c *Client) FindResPartnerCategory(criteria *Criteria) (*ResPartnerCategory, error) {
rpcs := &ResPartnerCategorys{}
if err := c.SearchRead(ResPartnerCategoryModel, criteria, NewOptions().Limit(1), rpcs); err != nil {
return nil, err
}
if rpcs != nil && len(*rpcs) > 0 {
return &((*rpcs)[0]), nil
}
return nil, fmt.Errorf("res.partner.category was not found")
}
// FindResPartnerCategorys finds res.partner.category records by querying it
// and filtering it with criteria and options.
func (c *Client) FindResPartnerCategorys(criteria *Criteria, options *Options) (*ResPartnerCategorys, error) {
rpcs := &ResPartnerCategorys{}
if err := c.SearchRead(ResPartnerCategoryModel, criteria, options, rpcs); err != nil {
return nil, err
}
return rpcs, nil
}