model

package
v0.20.0-dev2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PartnerFields = []string{
	"name",
	"create_date",

	"category_id",
	"lang",
	"notify_email",
	"parent_id",
	"property_payment_term",

	"x_invoice_contact",
	"use_parent_address",

	"street",
	"street2",
	"city",
	"zip",
	"country_id",

	"email",
	"phone",
}

PartnerFields is the list of fields that are fetched for a partner.

Functions

func IsNotFound

func IsNotFound(err error) bool

Types

type InvoiceLineTaxID

type InvoiceLineTaxID struct {

	// ID represents the id of the VAT in an invoice
	ID int
	// contains filtered or unexported fields
}

InvoiceLineTaxID represents a VAT entry in an invoice line.

func (InvoiceLineTaxID) MarshalJSON

func (a InvoiceLineTaxID) MarshalJSON() ([]byte, error)

MarshalJSON handles serialization of InvoiceLineTaxID.

func (*InvoiceLineTaxID) UnmarshalJSON

func (a *InvoiceLineTaxID) UnmarshalJSON(b []byte) error

UnmarshalJSON handles deserialization of InvoiceLineTaxID.

type Nullable

type Nullable[T any] struct {
	Value T
	Valid bool
}

Nullable represents a nullable value. The Valid field is set if Odoo returns a value. Valid is unset if Odoo returns `false` or `null` in the response instead of the expected value.

func (Nullable[T]) MarshalJSON

func (t Nullable[T]) MarshalJSON() ([]byte, error)

func (*Nullable[T]) UnmarshalJSON

func (t *Nullable[T]) UnmarshalJSON(b []byte) error

type Odoo

type Odoo struct {
	// contains filtered or unexported fields
}

Odoo is the developer-friendly client.Client with strongly-typed models.

func NewOdoo

func NewOdoo(querier client.QueryExecutor) *Odoo

NewOdoo creates a new Odoo client.

func (Odoo) FetchPartnerByID

func (o Odoo) FetchPartnerByID(ctx context.Context, id int, domainFilters ...client.Filter) (Partner, error)

FetchPartnerByID searches for the partner by ID and returns the first entry in the result. If no result has been found, a not found error is returned.

func (Odoo) SearchPartners

func (o Odoo) SearchPartners(ctx context.Context, domainFilters []client.Filter) ([]Partner, error)

type OdooCompositeID

type OdooCompositeID struct {
	// Valid is true if the OdooCompositeID is not null.
	// Odoo returns false if a field is not set. Due to how json unmarshalling works,
	// and the lack of pass-by-reference in Go, we can't set the field to nil.
	// https://dave.cheney.net/2017/04/29/there-is-no-pass-by-reference-in-go
	Valid bool
	// ID is the data record identifier.
	ID int
	// Name is a human-readable description.
	Name string
}

OdooCompositeID represents a composite ID used in the Odoo API. It is a tuple of an ID and a name. The Valid field is set if Odoo returns a tuple. Valid is unset if Odoo returns `false` in the response instead of the expected tuple. This most likely means that the field is not set (== null).

func (OdooCompositeID) MarshalJSON

func (t OdooCompositeID) MarshalJSON() ([]byte, error)

MarshalJSON handles serialization of OdooCompositeID.

func (*OdooCompositeID) UnmarshalJSON

func (t *OdooCompositeID) UnmarshalJSON(b []byte) error

UnmarshalJSON handles deserialization of OdooCompositeID.

type Partner

type Partner struct {
	// ID is the data record identifier.
	ID int `json:"id,omitempty" yaml:"id,omitempty"`
	// Name is the display name of the partner.
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	// CreationTimestamp is the creation date of the partner.
	CreationTimestamp client.Date `json:"create_date,omitempty" yaml:"create_date,omitempty"`

	// CategoryID is the category of the partner.
	CategoryID []int `json:"category_id,omitempty" yaml:"category_id,omitempty"`
	// Lang is the language of the partner.
	Lang Nullable[string] `json:"lang,omitempty" yaml:"lang,omitempty"`
	// NotifyEmail is the email notification preference of the partner.
	NotifyEmail string `json:"notify_email,omitempty" yaml:"notify_email,omitempty"`
	// ParentID is set if a customer is a sub-account (payment contact, ...) of another customer (company) account.
	Parent OdooCompositeID `json:"parent_id,omitempty" yaml:"parent_id,omitempty"`
	// PaymentTerm holds the terms of payment for the partner.
	PaymentTerm OdooCompositeID `json:"property_payment_term,omitempty" yaml:"property_payment_term,omitempty"`

	// InvoiceContactName is the contact person for invoices.
	InvoiceContactName Nullable[string] `json:"x_invoice_contact,omitempty" yaml:"x_invoice_contact,omitempty"`
	// UseParentAddress is set if the partner uses the address of the parent partner.
	UseParentAddress bool `json:"use_parent_address,omitempty" yaml:"use_parent_address,omitempty"`

	// Street is the street address of the partner.
	Street Nullable[string] `json:"street,omitempty" yaml:"street,omitempty"`
	// Street2 is the second line of the street address of the partner.
	Street2 Nullable[string] `json:"street2,omitempty" yaml:"street2,omitempty"`
	// City is the city of the partner.
	City Nullable[string] `json:"city,omitempty" yaml:"city,omitempty"`
	// Zip is the zip code of the partner.
	Zip Nullable[string] `json:"zip,omitempty" yaml:"zip,omitempty"`
	// CountryID is the country of the partner.
	CountryID OdooCompositeID `json:"country_id,omitempty" yaml:"country_id,omitempty"`

	// EmailRaw is the email addresses of the partner, comma-separated.
	EmailRaw Nullable[string] `json:"email,omitempty" yaml:"email,omitempty"`
	// Phone is the phone number of the partner.
	Phone Nullable[string] `json:"phone,omitempty" yaml:"phone,omitempty"`
}

Partner represents a partner ("Customer") record in Odoo

func (Partner) Emails

func (p Partner) Emails() []string

func (*Partner) SetEmails

func (p *Partner) SetEmails(emails []string)

type PartnerList

type PartnerList struct {
	Items []Partner `json:"records"`
}

PartnerList holds the search results for Partner for deserialization

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL