-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathcrm_lead2opportunity_partner.go
124 lines (108 loc) · 5.12 KB
/
crm_lead2opportunity_partner.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
package odoo
import (
"fmt"
)
// CrmLead2OpportunityPartner represents crm.lead2opportunity.partner model.
type CrmLead2OpportunityPartner struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Action *Selection `xmlrpc:"action,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 *Selection `xmlrpc:"name,omptempty"`
OpportunityIds *Relation `xmlrpc:"opportunity_ids,omptempty"`
PartnerId *Many2One `xmlrpc:"partner_id,omptempty"`
TeamId *Many2One `xmlrpc:"team_id,omptempty"`
UserId *Many2One `xmlrpc:"user_id,omptempty"`
WriteDate *Time `xmlrpc:"write_date,omptempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
}
// CrmLead2OpportunityPartners represents array of crm.lead2opportunity.partner model.
type CrmLead2OpportunityPartners []CrmLead2OpportunityPartner
// CrmLead2OpportunityPartnerModel is the odoo model name.
const CrmLead2OpportunityPartnerModel = "crm.lead2opportunity.partner"
// Many2One convert CrmLead2OpportunityPartner to *Many2One.
func (clp *CrmLead2OpportunityPartner) Many2One() *Many2One {
return NewMany2One(clp.Id.Get(), "")
}
// CreateCrmLead2OpportunityPartner creates a new crm.lead2opportunity.partner model and returns its id.
func (c *Client) CreateCrmLead2OpportunityPartner(clp *CrmLead2OpportunityPartner) (int64, error) {
return c.Create(CrmLead2OpportunityPartnerModel, clp)
}
// UpdateCrmLead2OpportunityPartner updates an existing crm.lead2opportunity.partner record.
func (c *Client) UpdateCrmLead2OpportunityPartner(clp *CrmLead2OpportunityPartner) error {
return c.UpdateCrmLead2OpportunityPartners([]int64{clp.Id.Get()}, clp)
}
// UpdateCrmLead2OpportunityPartners updates existing crm.lead2opportunity.partner records.
// All records (represented by ids) will be updated by clp values.
func (c *Client) UpdateCrmLead2OpportunityPartners(ids []int64, clp *CrmLead2OpportunityPartner) error {
return c.Update(CrmLead2OpportunityPartnerModel, ids, clp)
}
// DeleteCrmLead2OpportunityPartner deletes an existing crm.lead2opportunity.partner record.
func (c *Client) DeleteCrmLead2OpportunityPartner(id int64) error {
return c.DeleteCrmLead2OpportunityPartners([]int64{id})
}
// DeleteCrmLead2OpportunityPartners deletes existing crm.lead2opportunity.partner records.
func (c *Client) DeleteCrmLead2OpportunityPartners(ids []int64) error {
return c.Delete(CrmLead2OpportunityPartnerModel, ids)
}
// GetCrmLead2OpportunityPartner gets crm.lead2opportunity.partner existing record.
func (c *Client) GetCrmLead2OpportunityPartner(id int64) (*CrmLead2OpportunityPartner, error) {
clps, err := c.GetCrmLead2OpportunityPartners([]int64{id})
if err != nil {
return nil, err
}
if clps != nil && len(*clps) > 0 {
return &((*clps)[0]), nil
}
return nil, fmt.Errorf("id %v of crm.lead2opportunity.partner not found", id)
}
// GetCrmLead2OpportunityPartners gets crm.lead2opportunity.partner existing records.
func (c *Client) GetCrmLead2OpportunityPartners(ids []int64) (*CrmLead2OpportunityPartners, error) {
clps := &CrmLead2OpportunityPartners{}
if err := c.Read(CrmLead2OpportunityPartnerModel, ids, nil, clps); err != nil {
return nil, err
}
return clps, nil
}
// FindCrmLead2OpportunityPartner finds crm.lead2opportunity.partner record by querying it with criteria.
func (c *Client) FindCrmLead2OpportunityPartner(criteria *Criteria) (*CrmLead2OpportunityPartner, error) {
clps := &CrmLead2OpportunityPartners{}
if err := c.SearchRead(CrmLead2OpportunityPartnerModel, criteria, NewOptions().Limit(1), clps); err != nil {
return nil, err
}
if clps != nil && len(*clps) > 0 {
return &((*clps)[0]), nil
}
return nil, fmt.Errorf("no crm.lead2opportunity.partner was found with criteria %v", criteria)
}
// FindCrmLead2OpportunityPartners finds crm.lead2opportunity.partner records by querying it
// and filtering it with criteria and options.
func (c *Client) FindCrmLead2OpportunityPartners(criteria *Criteria, options *Options) (*CrmLead2OpportunityPartners, error) {
clps := &CrmLead2OpportunityPartners{}
if err := c.SearchRead(CrmLead2OpportunityPartnerModel, criteria, options, clps); err != nil {
return nil, err
}
return clps, nil
}
// FindCrmLead2OpportunityPartnerIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindCrmLead2OpportunityPartnerIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(CrmLead2OpportunityPartnerModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindCrmLead2OpportunityPartnerId finds record id by querying it with criteria.
func (c *Client) FindCrmLead2OpportunityPartnerId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(CrmLead2OpportunityPartnerModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no crm.lead2opportunity.partner was found with criteria %v and options %v", criteria, options)
}