-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added custom models + add the possibility to Find one record of a mod…
…el with Criteria
- Loading branch information
Showing
16 changed files
with
1,254 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package odoo | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// AccountAnalyticLine represents account.analytic.line model | ||
type AccountAnalyticLine struct { | ||
LastUpdate *Time `xmlrpc:"__last_update,omptempty"` | ||
AccountId *Many2One `xmlrpc:"account_id,omptempty"` | ||
Amount *Float `xmlrpc:"amount,omptempty"` | ||
AmountCurrency *Float `xmlrpc:"amount_currency,omptempty"` | ||
AnalyticAmountCurrency *Float `xmlrpc:"analytic_amount_currency,omptempty"` | ||
Code *String `xmlrpc:"code,omptempty"` | ||
CompanyCurrencyId *Many2One `xmlrpc:"company_currency_id,omptempty"` | ||
CompanyId *Many2One `xmlrpc:"company_id,omptempty"` | ||
CreateDate *Time `xmlrpc:"create_date,omptempty"` | ||
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"` | ||
CurrencyId *Many2One `xmlrpc:"currency_id,omptempty"` | ||
Date *Time `xmlrpc:"date,omptempty"` | ||
DepartmentId *Many2One `xmlrpc:"department_id,omptempty"` | ||
DisplayName *String `xmlrpc:"display_name,omptempty"` | ||
EmployeeId *Many2One `xmlrpc:"employee_id,omptempty"` | ||
GeneralAccountId *Many2One `xmlrpc:"general_account_id,omptempty"` | ||
HolidayId *Many2One `xmlrpc:"holiday_id,omptempty"` | ||
Id *Int `xmlrpc:"id,omptempty"` | ||
MoveId *Many2One `xmlrpc:"move_id,omptempty"` | ||
Name *String `xmlrpc:"name,omptempty"` | ||
PartnerId *Many2One `xmlrpc:"partner_id,omptempty"` | ||
ProductId *Many2One `xmlrpc:"product_id,omptempty"` | ||
ProductUomId *Many2One `xmlrpc:"product_uom_id,omptempty"` | ||
ProjectId *Many2One `xmlrpc:"project_id,omptempty"` | ||
Ref *String `xmlrpc:"ref,omptempty"` | ||
SoLine *Many2One `xmlrpc:"so_line,omptempty"` | ||
TagIds *Relation `xmlrpc:"tag_ids,omptempty"` | ||
TaskId *Many2One `xmlrpc:"task_id,omptempty"` | ||
TimesheetInvoiceId *Many2One `xmlrpc:"timesheet_invoice_id,omptempty"` | ||
TimesheetInvoiceType *Selection `xmlrpc:"timesheet_invoice_type,omptempty"` | ||
TimesheetRevenue *Float `xmlrpc:"timesheet_revenue,omptempty"` | ||
UnitAmount *Float `xmlrpc:"unit_amount,omptempty"` | ||
UserId *Many2One `xmlrpc:"user_id,omptempty"` | ||
WriteDate *Time `xmlrpc:"write_date,omptempty"` | ||
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"` | ||
} | ||
|
||
// AccountAnalyticLines represents array of account.analytic.line model | ||
type AccountAnalyticLines []AccountAnalyticLine | ||
|
||
// AccountAnalyticLineModel is the odoo model name | ||
const AccountAnalyticLineModel = "account.analytic.line" | ||
|
||
// CreateAccountAnalyticLine creates a new account.analytic.line model and returns its id. | ||
func (c *Client) CreateAccountAnalyticLine(aal *AccountAnalyticLine) (int64, error) { | ||
return c.Create(AccountAnalyticLineModel, aal) | ||
} | ||
|
||
// UpdateAccountAnalyticLine updates an existing account.analytic.line record. | ||
func (c *Client) UpdateAccountAnalyticLine(aal *AccountAnalyticLine) error { | ||
return c.UpdateAccountAnalyticLines([]int64{aal.Id.Get()}, aal) | ||
} | ||
|
||
// UpdateAccountAnalyticLines updates existing account.analytic.line records. | ||
// All records (represented by ids) will be updated by aal values. | ||
func (c *Client) UpdateAccountAnalyticLines(ids []int64, aal *AccountAnalyticLine) error { | ||
return c.Update(AccountAnalyticLineModel, ids, aal) | ||
} | ||
|
||
// DeleteAccountAnalyticLine deletes an existing account.analytic.line record. | ||
func (c *Client) DeleteAccountAnalyticLine(id int64) error { | ||
return c.DeleteAccountAnalyticLines([]int64{id}) | ||
} | ||
|
||
// DeleteAccountAnalyticLines deletes existing account.analytic.line records. | ||
func (c *Client) DeleteAccountAnalyticLines(ids []int64) error { | ||
return c.Delete(AccountAnalyticLineModel, ids) | ||
} | ||
|
||
// GetAccountAnalyticLine gets account.analytic.line existing record. | ||
func (c *Client) GetAccountAnalyticLine(id int64) (*AccountAnalyticLine, error) { | ||
aals, err := c.GetAccountAnalyticLines([]int64{id}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if aals != nil && len(*aals) > 0 { | ||
return &((*aals)[0]), nil | ||
} | ||
return nil, fmt.Errorf("id %v of %s not found", id, AccountAnalyticLineModel) | ||
} | ||
|
||
// GetAccountAnalyticLines gets account.analytic.line existing records. | ||
func (c *Client) GetAccountAnalyticLines(ids []int64) (*AccountAnalyticLines, error) { | ||
aals := &AccountAnalyticLines{} | ||
if err := c.Read(AccountAnalyticLineModel, ids, nil, aals); err != nil { | ||
return nil, err | ||
} | ||
return aals, nil | ||
} | ||
|
||
// FindAccountAnalyticLine finds account.analytic.line record by querying it with criteria | ||
func (c *Client) FindAccountAnalyticLine(criteria *Criteria) (*AccountAnalyticLine, error) { | ||
aals := &AccountAnalyticLines{} | ||
if err := c.SearchRead(AccountAnalyticLineModel, criteria, NewOptions().Limit(1), aals); err != nil { | ||
return nil, err | ||
} | ||
if aals != nil && len(*aals) > 0 { | ||
return &((*aals)[0]), nil | ||
} | ||
return nil, fmt.Errorf("account.analytic.line was not found") | ||
} | ||
|
||
// FindAccountAnalyticLines finds account.analytic.line records by querying it | ||
// and filtering it with criteria and options. | ||
func (c *Client) FindAccountAnalyticLines(criteria *Criteria, options *Options) (*AccountAnalyticLines, error) { | ||
aals := &AccountAnalyticLines{} | ||
if err := c.SearchRead(AccountAnalyticLineModel, criteria, options, aals); err != nil { | ||
return nil, err | ||
} | ||
return aals, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
package odoo | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// AccountInvoice represents account.invoice model | ||
type AccountInvoice struct { | ||
LastUpdate *Time `xmlrpc:"__last_update,omptempty"` | ||
AccessToken *String `xmlrpc:"access_token,omptempty"` | ||
AccountId *Many2One `xmlrpc:"account_id,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"` | ||
AmountTax *Float `xmlrpc:"amount_tax,omptempty"` | ||
AmountTotal *Float `xmlrpc:"amount_total,omptempty"` | ||
AmountTotalCompanySigned *Float `xmlrpc:"amount_total_company_signed,omptempty"` | ||
AmountTotalSigned *Float `xmlrpc:"amount_total_signed,omptempty"` | ||
AmountUntaxed *Float `xmlrpc:"amount_untaxed,omptempty"` | ||
AmountUntaxedSigned *Float `xmlrpc:"amount_untaxed_signed,omptempty"` | ||
CampaignId *Many2One `xmlrpc:"campaign_id,omptempty"` | ||
CashRoundingId *Many2One `xmlrpc:"cash_rounding_id,omptempty"` | ||
Comment *String `xmlrpc:"comment,omptempty"` | ||
CommercialPartnerId *Many2One `xmlrpc:"commercial_partner_id,omptempty"` | ||
CompanyCurrencyId *Many2One `xmlrpc:"company_currency_id,omptempty"` | ||
CompanyId *Many2One `xmlrpc:"company_id,omptempty"` | ||
CreateDate *Time `xmlrpc:"create_date,omptempty"` | ||
CreateUid *Many2One `xmlrpc:"create_uid,omptempty"` | ||
CurrencyId *Many2One `xmlrpc:"currency_id,omptempty"` | ||
Date *Time `xmlrpc:"date,omptempty"` | ||
DateDue *Time `xmlrpc:"date_due,omptempty"` | ||
DateInvoice *Time `xmlrpc:"date_invoice,omptempty"` | ||
DisplayName *String `xmlrpc:"display_name,omptempty"` | ||
FiscalPositionId *Many2One `xmlrpc:"fiscal_position_id,omptempty"` | ||
HasOutstanding *Bool `xmlrpc:"has_outstanding,omptempty"` | ||
Id *Int `xmlrpc:"id,omptempty"` | ||
InNote *String `xmlrpc:"in_note,omptempty"` | ||
IncotermsId *Many2One `xmlrpc:"incoterms_id,omptempty"` | ||
InvoiceLineIds *Relation `xmlrpc:"invoice_line_ids,omptempty"` | ||
JournalId *Many2One `xmlrpc:"journal_id,omptempty"` | ||
MachineInvoice *Bool `xmlrpc:"machine_invoice,omptempty"` | ||
MachineInvoiceTitle *String `xmlrpc:"machine_invoice_title,omptempty"` | ||
MachinePurchaseOrder *String `xmlrpc:"machine_purchase_order,omptempty"` | ||
MediumId *Many2One `xmlrpc:"medium_id,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"` | ||
MoveId *Many2One `xmlrpc:"move_id,omptempty"` | ||
MoveName *String `xmlrpc:"move_name,omptempty"` | ||
Name *String `xmlrpc:"name,omptempty"` | ||
Number *String `xmlrpc:"number,omptempty"` | ||
Origin *String `xmlrpc:"origin,omptempty"` | ||
OutNote *String `xmlrpc:"out_note,omptempty"` | ||
OutstandingCreditsDebitsWidget *String `xmlrpc:"outstanding_credits_debits_widget,omptempty"` | ||
PartnerBankId *Many2One `xmlrpc:"partner_bank_id,omptempty"` | ||
PartnerId *Many2One `xmlrpc:"partner_id,omptempty"` | ||
PartnerShippingId *Many2One `xmlrpc:"partner_shipping_id,omptempty"` | ||
PaymentIds *Relation `xmlrpc:"payment_ids,omptempty"` | ||
PaymentMoveLineIds *Relation `xmlrpc:"payment_move_line_ids,omptempty"` | ||
PaymentTermId *Many2One `xmlrpc:"payment_term_id,omptempty"` | ||
PaymentsWidget *String `xmlrpc:"payments_widget,omptempty"` | ||
PortalUrl *String `xmlrpc:"portal_url,omptempty"` | ||
PurchaseId *Many2One `xmlrpc:"purchase_id,omptempty"` | ||
QuantityTotal *Float `xmlrpc:"quantity_total,omptempty"` | ||
Reconciled *Bool `xmlrpc:"reconciled,omptempty"` | ||
Reference *String `xmlrpc:"reference,omptempty"` | ||
ReferenceType *Selection `xmlrpc:"reference_type,omptempty"` | ||
RefundInvoiceId *Many2One `xmlrpc:"refund_invoice_id,omptempty"` | ||
RefundInvoiceIds *Relation `xmlrpc:"refund_invoice_ids,omptempty"` | ||
Residual *Float `xmlrpc:"residual,omptempty"` | ||
ResidualCompanySigned *Float `xmlrpc:"residual_company_signed,omptempty"` | ||
ResidualSigned *Float `xmlrpc:"residual_signed,omptempty"` | ||
Sent *Bool `xmlrpc:"sent,omptempty"` | ||
SequenceNumberNext *String `xmlrpc:"sequence_number_next,omptempty"` | ||
SequenceNumberNextPrefix *String `xmlrpc:"sequence_number_next_prefix,omptempty"` | ||
SourceId *Many2One `xmlrpc:"source_id,omptempty"` | ||
State *Selection `xmlrpc:"state,omptempty"` | ||
TaxLineIds *Relation `xmlrpc:"tax_line_ids,omptempty"` | ||
TeamId *Many2One `xmlrpc:"team_id,omptempty"` | ||
TimesheetCount *Int `xmlrpc:"timesheet_count,omptempty"` | ||
TimesheetIds *Relation `xmlrpc:"timesheet_ids,omptempty"` | ||
Type *Selection `xmlrpc:"type,omptempty"` | ||
UserId *Many2One `xmlrpc:"user_id,omptempty"` | ||
WebsiteMessageIds *Relation `xmlrpc:"website_message_ids,omptempty"` | ||
WriteDate *Time `xmlrpc:"write_date,omptempty"` | ||
WriteUid *Many2One `xmlrpc:"write_uid,omptempty"` | ||
} | ||
|
||
// AccountInvoices represents array of account.invoice model | ||
type AccountInvoices []AccountInvoice | ||
|
||
// AccountInvoiceModel is the odoo model name | ||
const AccountInvoiceModel = "account.invoice" | ||
|
||
// CreateAccountInvoice creates a new account.invoice model and returns its id. | ||
func (c *Client) CreateAccountInvoice(ai *AccountInvoice) (int64, error) { | ||
return c.Create(AccountInvoiceModel, ai) | ||
} | ||
|
||
// UpdateAccountInvoice updates an existing account.invoice record. | ||
func (c *Client) UpdateAccountInvoice(ai *AccountInvoice) error { | ||
return c.UpdateAccountInvoices([]int64{ai.Id.Get()}, ai) | ||
} | ||
|
||
// UpdateAccountInvoices updates existing account.invoice records. | ||
// All records (represented by ids) will be updated by ai values. | ||
func (c *Client) UpdateAccountInvoices(ids []int64, ai *AccountInvoice) error { | ||
return c.Update(AccountInvoiceModel, ids, ai) | ||
} | ||
|
||
// DeleteAccountInvoice deletes an existing account.invoice record. | ||
func (c *Client) DeleteAccountInvoice(id int64) error { | ||
return c.DeleteAccountInvoices([]int64{id}) | ||
} | ||
|
||
// DeleteAccountInvoices deletes existing account.invoice records. | ||
func (c *Client) DeleteAccountInvoices(ids []int64) error { | ||
return c.Delete(AccountInvoiceModel, ids) | ||
} | ||
|
||
// GetAccountInvoice gets account.invoice existing record. | ||
func (c *Client) GetAccountInvoice(id int64) (*AccountInvoice, error) { | ||
ais, err := c.GetAccountInvoices([]int64{id}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if ais != nil && len(*ais) > 0 { | ||
return &((*ais)[0]), nil | ||
} | ||
return nil, fmt.Errorf("id %v of %s not found", id, AccountInvoiceModel) | ||
} | ||
|
||
// GetAccountInvoices gets account.invoice existing records. | ||
func (c *Client) GetAccountInvoices(ids []int64) (*AccountInvoices, error) { | ||
ais := &AccountInvoices{} | ||
if err := c.Read(AccountInvoiceModel, ids, nil, ais); err != nil { | ||
return nil, err | ||
} | ||
return ais, nil | ||
} | ||
|
||
// FindAccountInvoice finds account.invoice record by querying it with criteria | ||
func (c *Client) FindAccountInvoice(criteria *Criteria) (*AccountInvoice, error) { | ||
ais := &AccountInvoices{} | ||
if err := c.SearchRead(AccountInvoiceModel, criteria, NewOptions().Limit(1), ais); err != nil { | ||
return nil, err | ||
} | ||
if ais != nil && len(*ais) > 0 { | ||
return &((*ais)[0]), nil | ||
} | ||
return nil, fmt.Errorf("account.invoice was not found") | ||
} | ||
|
||
// FindAccountInvoices finds account.invoice records by querying it | ||
// and filtering it with criteria and options. | ||
func (c *Client) FindAccountInvoices(criteria *Criteria, options *Options) (*AccountInvoices, error) { | ||
ais := &AccountInvoices{} | ||
if err := c.SearchRead(AccountInvoiceModel, criteria, options, ais); err != nil { | ||
return nil, err | ||
} | ||
return ais, nil | ||
} |
Oops, something went wrong.