model

package
v0.33.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const PartnerModel = "res.partner"

PartnerModel is the name of the Odoo model for partners.

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",

	"x_control_api_meta_status",
}

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

Functions

func IsNotFound

func IsNotFound(err error) bool

Types

type CategoryIDs added in v0.23.0

type CategoryIDs []int

func (CategoryIDs) MarshalJSON added in v0.23.0

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

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 NewNullable added in v0.23.0

func NewNullable[T any](v T) Nullable[T]

NewNullable creates a new Nullable[T] with the given 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) CreatePartner added in v0.23.0

func (o Odoo) CreatePartner(ctx context.Context, p Partner) (id int, err error)

func (Odoo) DeletePartner added in v0.26.0

func (o Odoo) DeletePartner(ctx context.Context, ids []int) error

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)

func (Odoo) UpdateRawPartner added in v0.23.0

func (o Odoo) UpdateRawPartner(ctx context.Context, ids []int, raw any) 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 NewCompositeID added in v0.23.0

func NewCompositeID(id int, name string) OdooCompositeID

NewCompositeID creates a new, valid OdooCompositeID.

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 CategoryIDs `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"`

	// Inflight allows detecting half-finished creates.
	Inflight Nullable[string] `json:"x_control_api_inflight,omitempty" yaml:"x_control_api_inflight,omitempty"`

	// Status allows storing status conditions
	Status Nullable[string] `json:"x_control_api_meta_status,omitempty" yaml:"x_control_api_meta_status,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