forked from skilld-labs/go-odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathres_partner.go
220 lines (206 loc) · 12.4 KB
/
res_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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
package odoo
import (
"fmt"
)
// ResPartner represents res.partner model
type ResPartner struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
Active *Bool `xmlrpc:"active,omptempty"`
ActivityDateDeadline *Time `xmlrpc:"activity_date_deadline,omptempty"`
ActivityIds *Relation `xmlrpc:"activity_ids,omptempty"`
ActivityState *Selection `xmlrpc:"activity_state,omptempty"`
ActivitySummary *String `xmlrpc:"activity_summary,omptempty"`
ActivityTypeId *Many2One `xmlrpc:"activity_type_id,omptempty"`
ActivityUserId *Many2One `xmlrpc:"activity_user_id,omptempty"`
BankAccountCount *Int `xmlrpc:"bank_account_count,omptempty"`
BankIds *Relation `xmlrpc:"bank_ids,omptempty"`
Barcode *String `xmlrpc:"barcode,omptempty"`
CalendarLastNotifAck *Time `xmlrpc:"calendar_last_notif_ack,omptempty"`
CategoryId *Relation `xmlrpc:"category_id,omptempty"`
ChannelIds *Relation `xmlrpc:"channel_ids,omptempty"`
ChildIds *Relation `xmlrpc:"child_ids,omptempty"`
City *String `xmlrpc:"city,omptempty"`
Color *Int `xmlrpc:"color,omptempty"`
Comment *String `xmlrpc:"comment,omptempty"`
CommercialCompanyName *String `xmlrpc:"commercial_company_name,omptempty"`
CommercialPartnerCountryId *Many2One `xmlrpc:"commercial_partner_country_id,omptempty"`
CommercialPartnerId *Many2One `xmlrpc:"commercial_partner_id,omptempty"`
CompanyId *Many2One `xmlrpc:"company_id,omptempty"`
CompanyName *String `xmlrpc:"company_name,omptempty"`
CompanyType *Selection `xmlrpc:"company_type,omptempty"`
ContactAddress *String `xmlrpc:"contact_address,omptempty"`
ContractIds *Relation `xmlrpc:"contract_ids,omptempty"`
ContractsCount *Int `xmlrpc:"contracts_count,omptempty"`
CountryId *Many2One `xmlrpc:"country_id,omptempty"`
CreateDate *Time `xmlrpc:"create_date,omptempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"`
Credit *Float `xmlrpc:"credit,omptempty"`
CreditLimit *Float `xmlrpc:"credit_limit,omptempty"`
CurrencyId *Many2One `xmlrpc:"currency_id,omptempty"`
Customer *Bool `xmlrpc:"customer,omptempty"`
Date *Time `xmlrpc:"date,omptempty"`
Debit *Float `xmlrpc:"debit,omptempty"`
DebitLimit *Float `xmlrpc:"debit_limit,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Email *String `xmlrpc:"email,omptempty"`
EmailFormatted *String `xmlrpc:"email_formatted,omptempty"`
Employee *Bool `xmlrpc:"employee,omptempty"`
Function *String `xmlrpc:"function,omptempty"`
HasUnreconciledEntries *Bool `xmlrpc:"has_unreconciled_entries,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
ImStatus *String `xmlrpc:"im_status,omptempty"`
Image *String `xmlrpc:"image,omptempty"`
ImageMedium *String `xmlrpc:"image_medium,omptempty"`
ImageSmall *String `xmlrpc:"image_small,omptempty"`
IndustryId *Many2One `xmlrpc:"industry_id,omptempty"`
InvoiceIds *Relation `xmlrpc:"invoice_ids,omptempty"`
InvoiceWarn *Selection `xmlrpc:"invoice_warn,omptempty"`
InvoiceWarnMsg *String `xmlrpc:"invoice_warn_msg,omptempty"`
IsCompany *Bool `xmlrpc:"is_company,omptempty"`
JournalItemCount *Int `xmlrpc:"journal_item_count,omptempty"`
Lang *Selection `xmlrpc:"lang,omptempty"`
LastTimeEntriesChecked *Time `xmlrpc:"last_time_entries_checked,omptempty"`
MachineCompanyName *String `xmlrpc:"machine_company_name,omptempty"`
MeetingCount *Int `xmlrpc:"meeting_count,omptempty"`
MeetingIds *Relation `xmlrpc:"meeting_ids,omptempty"`
MessageBounce *Int `xmlrpc:"message_bounce,omptempty"`
MessageChannelIds *Relation `xmlrpc:"message_channel_ids,omptempty"`
MessageFollowerIds *Relation `xmlrpc:"message_follower_ids,omptempty"`
MessageIds *Relation `xmlrpc:"message_ids,omptempty"`
MessageIsFollower *Bool `xmlrpc:"message_is_follower,omptempty"`
MessageLastPost *Time `xmlrpc:"message_last_post,omptempty"`
MessageNeedaction *Bool `xmlrpc:"message_needaction,omptempty"`
MessageNeedactionCounter *Int `xmlrpc:"message_needaction_counter,omptempty"`
MessagePartnerIds *Relation `xmlrpc:"message_partner_ids,omptempty"`
MessageUnread *Bool `xmlrpc:"message_unread,omptempty"`
MessageUnreadCounter *Int `xmlrpc:"message_unread_counter,omptempty"`
Mobile *String `xmlrpc:"mobile,omptempty"`
Name *String `xmlrpc:"name,omptempty"`
OpportunityCount *Int `xmlrpc:"opportunity_count,omptempty"`
OpportunityIds *Relation `xmlrpc:"opportunity_ids,omptempty"`
OptOut *Bool `xmlrpc:"opt_out,omptempty"`
ParentId *Many2One `xmlrpc:"parent_id,omptempty"`
ParentName *String `xmlrpc:"parent_name,omptempty"`
PartnerShare *Bool `xmlrpc:"partner_share,omptempty"`
PaymentTokenCount *Int `xmlrpc:"payment_token_count,omptempty"`
PaymentTokenIds *Relation `xmlrpc:"payment_token_ids,omptempty"`
Phone *String `xmlrpc:"phone,omptempty"`
PickingWarn *Selection `xmlrpc:"picking_warn,omptempty"`
PickingWarnMsg *String `xmlrpc:"picking_warn_msg,omptempty"`
PropertyAccountPayableId *Many2One `xmlrpc:"property_account_payable_id,omptempty"`
PropertyAccountPositionId *Many2One `xmlrpc:"property_account_position_id,omptempty"`
PropertyAccountReceivableId *Many2One `xmlrpc:"property_account_receivable_id,omptempty"`
PropertyAutosalesConfig *Many2One `xmlrpc:"property_autosales_config,omptempty"`
PropertyPaymentTermId *Many2One `xmlrpc:"property_payment_term_id,omptempty"`
PropertyProductPricelist *Many2One `xmlrpc:"property_product_pricelist,omptempty"`
PropertyPurchaseCurrencyId *Many2One `xmlrpc:"property_purchase_currency_id,omptempty"`
PropertyStockCustomer *Many2One `xmlrpc:"property_stock_customer,omptempty"`
PropertyStockSupplier *Many2One `xmlrpc:"property_stock_supplier,omptempty"`
PropertySupplierPaymentTermId *Many2One `xmlrpc:"property_supplier_payment_term_id,omptempty"`
PurchaseOrderCount *Int `xmlrpc:"purchase_order_count,omptempty"`
PurchaseWarn *Selection `xmlrpc:"purchase_warn,omptempty"`
PurchaseWarnMsg *String `xmlrpc:"purchase_warn_msg,omptempty"`
Ref *String `xmlrpc:"ref,omptempty"`
RefCompanyIds *Relation `xmlrpc:"ref_company_ids,omptempty"`
SaleOrderCount *Int `xmlrpc:"sale_order_count,omptempty"`
SaleOrderIds *Relation `xmlrpc:"sale_order_ids,omptempty"`
SaleWarn *Selection `xmlrpc:"sale_warn,omptempty"`
SaleWarnMsg *String `xmlrpc:"sale_warn_msg,omptempty"`
Self *Many2One `xmlrpc:"self,omptempty"`
SignupExpiration *Time `xmlrpc:"signup_expiration,omptempty"`
SignupToken *String `xmlrpc:"signup_token,omptempty"`
SignupType *String `xmlrpc:"signup_type,omptempty"`
SignupUrl *String `xmlrpc:"signup_url,omptempty"`
SignupValid *Bool `xmlrpc:"signup_valid,omptempty"`
Siret *String `xmlrpc:"siret,omptempty"`
StateId *Many2One `xmlrpc:"state_id,omptempty"`
Street *String `xmlrpc:"street,omptempty"`
Street2 *String `xmlrpc:"street2,omptempty"`
Supplier *Bool `xmlrpc:"supplier,omptempty"`
SupplierInvoiceCount *Int `xmlrpc:"supplier_invoice_count,omptempty"`
TaskCount *Int `xmlrpc:"task_count,omptempty"`
TaskIds *Relation `xmlrpc:"task_ids,omptempty"`
TeamId *Many2One `xmlrpc:"team_id,omptempty"`
Title *Many2One `xmlrpc:"title,omptempty"`
TotalInvoiced *Float `xmlrpc:"total_invoiced,omptempty"`
Trust *Selection `xmlrpc:"trust,omptempty"`
Type *Selection `xmlrpc:"type,omptempty"`
Tz *Selection `xmlrpc:"tz,omptempty"`
TzOffset *String `xmlrpc:"tz_offset,omptempty"`
UserId *Many2One `xmlrpc:"user_id,omptempty"`
UserIds *Relation `xmlrpc:"user_ids,omptempty"`
Vat *String `xmlrpc:"vat,omptempty"`
Website *String `xmlrpc:"website,omptempty"`
WebsiteMessageIds *Relation `xmlrpc:"website_message_ids,omptempty"`
WriteDate *Time `xmlrpc:"write_date,omptempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"`
Zip *String `xmlrpc:"zip,omptempty"`
}
// ResPartners represents array of res.partner model
type ResPartners []ResPartner
// ResPartnerModel is the odoo model name
const ResPartnerModel = "res.partner"
// Many2One convert ResPartner to *Many2One.
func (rp *ResPartner) Many2One() *Many2One {
return NewMany2One(rp.Id.Get(), "")
}
// CreateResPartner creates a new res.partner model and returns its id.
func (c *Client) CreateResPartner(rp *ResPartner) (int64, error) {
return c.Create(ResPartnerModel, rp)
}
// UpdateResPartner updates an existing res.partner record.
func (c *Client) UpdateResPartner(rp *ResPartner) error {
return c.UpdateResPartners([]int64{rp.Id.Get()}, rp)
}
// UpdateResPartners updates existing res.partner records.
// All records (represented by ids) will be updated by rp values.
func (c *Client) UpdateResPartners(ids []int64, rp *ResPartner) error {
return c.Update(ResPartnerModel, ids, rp)
}
// DeleteResPartner deletes an existing res.partner record.
func (c *Client) DeleteResPartner(id int64) error {
return c.DeleteResPartners([]int64{id})
}
// DeleteResPartners deletes existing res.partner records.
func (c *Client) DeleteResPartners(ids []int64) error {
return c.Delete(ResPartnerModel, ids)
}
// GetResPartner gets res.partner existing record.
func (c *Client) GetResPartner(id int64) (*ResPartner, error) {
rps, err := c.GetResPartners([]int64{id})
if err != nil {
return nil, err
}
if rps != nil && len(*rps) > 0 {
return &((*rps)[0]), nil
}
return nil, fmt.Errorf("id %v of %s not found", id, ResPartnerModel)
}
// GetResPartners gets res.partner existing records.
func (c *Client) GetResPartners(ids []int64) (*ResPartners, error) {
rps := &ResPartners{}
if err := c.Read(ResPartnerModel, ids, nil, rps); err != nil {
return nil, err
}
return rps, nil
}
// FindResPartner finds res.partner record by querying it with criteria
func (c *Client) FindResPartner(criteria *Criteria) (*ResPartner, error) {
rps := &ResPartners{}
if err := c.SearchRead(ResPartnerModel, criteria, NewOptions().Limit(1), rps); err != nil {
return nil, err
}
if rps != nil && len(*rps) > 0 {
return &((*rps)[0]), nil
}
return nil, fmt.Errorf("res.partner was not found")
}
// FindResPartners finds res.partner records by querying it
// and filtering it with criteria and options.
func (c *Client) FindResPartners(criteria *Criteria, options *Options) (*ResPartners, error) {
rps := &ResPartners{}
if err := c.SearchRead(ResPartnerModel, criteria, options, rps); err != nil {
return nil, err
}
return rps, nil
}