Skip to content

Commit 1ada708

Browse files
author
Antoine Huret
committed
added crm.lead and crm.lead.tag models
1 parent 0404e29 commit 1ada708

File tree

3 files changed

+267
-0
lines changed

3 files changed

+267
-0
lines changed

crm_lead.go

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
package odoo
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// CrmLead represents crm.lead model
8+
type CrmLead struct {
9+
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
10+
Active *Bool `xmlrpc:"active,omptempty"`
11+
ActivityDateDeadline *Time `xmlrpc:"activity_date_deadline,omptempty"`
12+
ActivityIds *Relation `xmlrpc:"activity_ids,omptempty"`
13+
ActivityState *Selection `xmlrpc:"activity_state,omptempty"`
14+
ActivitySummary *String `xmlrpc:"activity_summary,omptempty"`
15+
ActivityTypeId *Many2One `xmlrpc:"activity_type_id,omptempty"`
16+
ActivityUserId *Many2One `xmlrpc:"activity_user_id,omptempty"`
17+
CampaignId *Many2One `xmlrpc:"campaign_id,omptempty"`
18+
City *String `xmlrpc:"city,omptempty"`
19+
Color *Int `xmlrpc:"color,omptempty"`
20+
CompanyCurrency *Many2One `xmlrpc:"company_currency,omptempty"`
21+
CompanyId *Many2One `xmlrpc:"company_id,omptempty"`
22+
ContactName *String `xmlrpc:"contact_name,omptempty"`
23+
CountryId *Many2One `xmlrpc:"country_id,omptempty"`
24+
CreateDate *Time `xmlrpc:"create_date,omptempty"`
25+
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
26+
DateActionLast *Time `xmlrpc:"date_action_last,omptempty"`
27+
DateClosed *Time `xmlrpc:"date_closed,omptempty"`
28+
DateConversion *Time `xmlrpc:"date_conversion,omptempty"`
29+
DateDeadline *Time `xmlrpc:"date_deadline,omptempty"`
30+
DateLastStageUpdate *Time `xmlrpc:"date_last_stage_update,omptempty"`
31+
DateOpen *Time `xmlrpc:"date_open,omptempty"`
32+
DayClose *Float `xmlrpc:"day_close,omptempty"`
33+
DayOpen *Float `xmlrpc:"day_open,omptempty"`
34+
Description *String `xmlrpc:"description,omptempty"`
35+
DisplayName *String `xmlrpc:"display_name,omptempty"`
36+
EmailCc *String `xmlrpc:"email_cc,omptempty"`
37+
EmailFrom *String `xmlrpc:"email_from,omptempty"`
38+
Function *String `xmlrpc:"function,omptempty"`
39+
Id *Int `xmlrpc:"id,omptempty"`
40+
KanbanState *Selection `xmlrpc:"kanban_state,omptempty"`
41+
LostReason *Many2One `xmlrpc:"lost_reason,omptempty"`
42+
MachineLeadName *String `xmlrpc:"machine_lead_name,omptempty"`
43+
MediumId *Many2One `xmlrpc:"medium_id,omptempty"`
44+
MeetingCount *Int `xmlrpc:"meeting_count,omptempty"`
45+
MessageBounce *Int `xmlrpc:"message_bounce,omptempty"`
46+
MessageChannelIds *Relation `xmlrpc:"message_channel_ids,omptempty"`
47+
MessageFollowerIds *Relation `xmlrpc:"message_follower_ids,omptempty"`
48+
MessageIds *Relation `xmlrpc:"message_ids,omptempty"`
49+
MessageIsFollower *Bool `xmlrpc:"message_is_follower,omptempty"`
50+
MessageLastPost *Time `xmlrpc:"message_last_post,omptempty"`
51+
MessageNeedaction *Bool `xmlrpc:"message_needaction,omptempty"`
52+
MessageNeedactionCounter *Int `xmlrpc:"message_needaction_counter,omptempty"`
53+
MessagePartnerIds *Relation `xmlrpc:"message_partner_ids,omptempty"`
54+
MessageUnread *Bool `xmlrpc:"message_unread,omptempty"`
55+
MessageUnreadCounter *Int `xmlrpc:"message_unread_counter,omptempty"`
56+
Mobile *String `xmlrpc:"mobile,omptempty"`
57+
Name *String `xmlrpc:"name,omptempty"`
58+
OptOut *Bool `xmlrpc:"opt_out,omptempty"`
59+
OrderIds *Relation `xmlrpc:"order_ids,omptempty"`
60+
PartnerAddressEmail *String `xmlrpc:"partner_address_email,omptempty"`
61+
PartnerAddressName *String `xmlrpc:"partner_address_name,omptempty"`
62+
PartnerId *Many2One `xmlrpc:"partner_id,omptempty"`
63+
PartnerName *String `xmlrpc:"partner_name,omptempty"`
64+
Phone *String `xmlrpc:"phone,omptempty"`
65+
PlannedRevenue *Float `xmlrpc:"planned_revenue,omptempty"`
66+
Priority *Selection `xmlrpc:"priority,omptempty"`
67+
Probability *Float `xmlrpc:"probability,omptempty"`
68+
Referred *String `xmlrpc:"referred,omptempty"`
69+
SaleAmountTotal *Float `xmlrpc:"sale_amount_total,omptempty"`
70+
SaleNumber *Int `xmlrpc:"sale_number,omptempty"`
71+
SourceId *Many2One `xmlrpc:"source_id,omptempty"`
72+
StageId *Many2One `xmlrpc:"stage_id,omptempty"`
73+
StateId *Many2One `xmlrpc:"state_id,omptempty"`
74+
Street *String `xmlrpc:"street,omptempty"`
75+
Street2 *String `xmlrpc:"street2,omptempty"`
76+
TagIds *Relation `xmlrpc:"tag_ids,omptempty"`
77+
TeamId *Many2One `xmlrpc:"team_id,omptempty"`
78+
Title *Many2One `xmlrpc:"title,omptempty"`
79+
Type *Selection `xmlrpc:"type,omptempty"`
80+
UserEmail *String `xmlrpc:"user_email,omptempty"`
81+
UserId *Many2One `xmlrpc:"user_id,omptempty"`
82+
UserLogin *String `xmlrpc:"user_login,omptempty"`
83+
Website *String `xmlrpc:"website,omptempty"`
84+
WebsiteMessageIds *Relation `xmlrpc:"website_message_ids,omptempty"`
85+
WriteDate *Time `xmlrpc:"write_date,omptempty"`
86+
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
87+
Zip *String `xmlrpc:"zip,omptempty"`
88+
}
89+
90+
// CrmLeads represents array of crm.lead model
91+
type CrmLeads []CrmLead
92+
93+
// CrmLeadModel is the odoo model name
94+
const CrmLeadModel = "crm.lead"
95+
96+
// Many2One convert CrmLead to *Many2One.
97+
func (cl *CrmLead) Many2One() *Many2One {
98+
return NewMany2One(cl.Id.Get(), "")
99+
}
100+
101+
// CreateCrmLead creates a new crm.lead model and returns its id.
102+
func (c *Client) CreateCrmLead(cl *CrmLead) (int64, error) {
103+
return c.Create(CrmLeadModel, cl)
104+
}
105+
106+
// UpdateCrmLead updates an existing crm.lead record.
107+
func (c *Client) UpdateCrmLead(cl *CrmLead) error {
108+
return c.UpdateCrmLeads([]int64{cl.Id.Get()}, cl)
109+
}
110+
111+
// UpdateCrmLeads updates existing crm.lead records.
112+
// All records (represented by ids) will be updated by cl values.
113+
func (c *Client) UpdateCrmLeads(ids []int64, cl *CrmLead) error {
114+
return c.Update(CrmLeadModel, ids, cl)
115+
}
116+
117+
// DeleteCrmLead deletes an existing crm.lead record.
118+
func (c *Client) DeleteCrmLead(id int64) error {
119+
return c.DeleteCrmLeads([]int64{id})
120+
}
121+
122+
// DeleteCrmLeads deletes existing crm.lead records.
123+
func (c *Client) DeleteCrmLeads(ids []int64) error {
124+
return c.Delete(CrmLeadModel, ids)
125+
}
126+
127+
// GetCrmLead gets crm.lead existing record.
128+
func (c *Client) GetCrmLead(id int64) (*CrmLead, error) {
129+
cls, err := c.GetCrmLeads([]int64{id})
130+
if err != nil {
131+
return nil, err
132+
}
133+
if cls != nil && len(*cls) > 0 {
134+
return &((*cls)[0]), nil
135+
}
136+
return nil, fmt.Errorf("id %v of %s not found", id, CrmLeadModel)
137+
}
138+
139+
// GetCrmLeads gets crm.lead existing records.
140+
func (c *Client) GetCrmLeads(ids []int64) (*CrmLeads, error) {
141+
cls := &CrmLeads{}
142+
if err := c.Read(CrmLeadModel, ids, nil, cls); err != nil {
143+
return nil, err
144+
}
145+
return cls, nil
146+
}
147+
148+
// FindCrmLead finds crm.lead record by querying it with criteria
149+
func (c *Client) FindCrmLead(criteria *Criteria) (*CrmLead, error) {
150+
cls := &CrmLeads{}
151+
if err := c.SearchRead(CrmLeadModel, criteria, NewOptions().Limit(1), cls); err != nil {
152+
return nil, err
153+
}
154+
if cls != nil && len(*cls) > 0 {
155+
return &((*cls)[0]), nil
156+
}
157+
return nil, fmt.Errorf("crm.lead was not found")
158+
}
159+
160+
// FindCrmLeads finds crm.lead records by querying it
161+
// and filtering it with criteria and options.
162+
func (c *Client) FindCrmLeads(criteria *Criteria, options *Options) (*CrmLeads, error) {
163+
cls := &CrmLeads{}
164+
if err := c.SearchRead(CrmLeadModel, criteria, options, cls); err != nil {
165+
return nil, err
166+
}
167+
return cls, nil
168+
}

crm_lead_tag.go

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package odoo
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
// CrmLeadTag represents crm.lead.tag model
8+
type CrmLeadTag struct {
9+
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
10+
Color *Int `xmlrpc:"color,omptempty"`
11+
CreateDate *Time `xmlrpc:"create_date,omptempty"`
12+
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
13+
DisplayName *String `xmlrpc:"display_name,omptempty"`
14+
Id *Int `xmlrpc:"id,omptempty"`
15+
Name *String `xmlrpc:"name,omptempty"`
16+
WriteDate *Time `xmlrpc:"write_date,omptempty"`
17+
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
18+
}
19+
20+
// CrmLeadTags represents array of crm.lead.tag model
21+
type CrmLeadTags []CrmLeadTag
22+
23+
// CrmLeadTagModel is the odoo model name
24+
const CrmLeadTagModel = "crm.lead.tag"
25+
26+
// Many2One convert CrmLeadTag to *Many2One.
27+
func (clt *CrmLeadTag) Many2One() *Many2One {
28+
return NewMany2One(clt.Id.Get(), "")
29+
}
30+
31+
// CreateCrmLeadTag creates a new crm.lead.tag model and returns its id.
32+
func (c *Client) CreateCrmLeadTag(clt *CrmLeadTag) (int64, error) {
33+
return c.Create(CrmLeadTagModel, clt)
34+
}
35+
36+
// UpdateCrmLeadTag updates an existing crm.lead.tag record.
37+
func (c *Client) UpdateCrmLeadTag(clt *CrmLeadTag) error {
38+
return c.UpdateCrmLeadTags([]int64{clt.Id.Get()}, clt)
39+
}
40+
41+
// UpdateCrmLeadTags updates existing crm.lead.tag records.
42+
// All records (represented by ids) will be updated by clt values.
43+
func (c *Client) UpdateCrmLeadTags(ids []int64, clt *CrmLeadTag) error {
44+
return c.Update(CrmLeadTagModel, ids, clt)
45+
}
46+
47+
// DeleteCrmLeadTag deletes an existing crm.lead.tag record.
48+
func (c *Client) DeleteCrmLeadTag(id int64) error {
49+
return c.DeleteCrmLeadTags([]int64{id})
50+
}
51+
52+
// DeleteCrmLeadTags deletes existing crm.lead.tag records.
53+
func (c *Client) DeleteCrmLeadTags(ids []int64) error {
54+
return c.Delete(CrmLeadTagModel, ids)
55+
}
56+
57+
// GetCrmLeadTag gets crm.lead.tag existing record.
58+
func (c *Client) GetCrmLeadTag(id int64) (*CrmLeadTag, error) {
59+
clts, err := c.GetCrmLeadTags([]int64{id})
60+
if err != nil {
61+
return nil, err
62+
}
63+
if clts != nil && len(*clts) > 0 {
64+
return &((*clts)[0]), nil
65+
}
66+
return nil, fmt.Errorf("id %v of %s not found", id, CrmLeadTagModel)
67+
}
68+
69+
// GetCrmLeadTags gets crm.lead.tag existing records.
70+
func (c *Client) GetCrmLeadTags(ids []int64) (*CrmLeadTags, error) {
71+
clts := &CrmLeadTags{}
72+
if err := c.Read(CrmLeadTagModel, ids, nil, clts); err != nil {
73+
return nil, err
74+
}
75+
return clts, nil
76+
}
77+
78+
// FindCrmLeadTag finds crm.lead.tag record by querying it with criteria
79+
func (c *Client) FindCrmLeadTag(criteria *Criteria) (*CrmLeadTag, error) {
80+
clts := &CrmLeadTags{}
81+
if err := c.SearchRead(CrmLeadTagModel, criteria, NewOptions().Limit(1), clts); err != nil {
82+
return nil, err
83+
}
84+
if clts != nil && len(*clts) > 0 {
85+
return &((*clts)[0]), nil
86+
}
87+
return nil, fmt.Errorf("crm.lead.tag was not found")
88+
}
89+
90+
// FindCrmLeadTags finds crm.lead.tag records by querying it
91+
// and filtering it with criteria and options.
92+
func (c *Client) FindCrmLeadTags(criteria *Criteria, options *Options) (*CrmLeadTags, error) {
93+
clts := &CrmLeadTags{}
94+
if err := c.SearchRead(CrmLeadTagModel, criteria, options, clts); err != nil {
95+
return nil, err
96+
}
97+
return clts, nil
98+
}

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
1919
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
2020
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
2121
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
22+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2223
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
2324
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
2425
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=

0 commit comments

Comments
 (0)