actions

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 13 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootStrap

func BootStrap()

BootStrap actions. This function must be called prior to any access to the actions Registry.

func LoadFromEtree

func LoadFromEtree(element *etree.Element)

LoadFromEtree reads the action given etree.Element, creates or updates the action and adds it to the action registry if it not already.

Types

type Action

type Action struct {
	ID           int64                  `json:"id" xml:"-"`
	XMLID        string                 `json:"xmlid" xml:"id,attr"`
	Type         ActionType             `json:"type" xml:"type,attr"`
	Name         string                 `json:"name" xml:"name,attr"`
	Model        string                 `json:"res_model" xml:"model,attr"`
	ResID        int64                  `json:"res_id" xml:"res_id,attr"`
	Method       string                 `json:"method" xml:"method,attr"`
	Groups       []string               `json:"groups_id" xml:"groups,attr"`
	Domain       string                 `json:"domain" xml:"domain,attr"`
	HelpXML      actionHelp             `json:"-" xml:"help"`
	Help         string                 `json:"help" xml:"-"`
	SearchView   views.ViewRef          `json:"search_view_id" xml:"search_view_id,attr"`
	SrcModel     string                 `json:"src_model" xml:"src_model,attr"`
	Usage        string                 `json:"usage" xml:"usage,attr"`
	Views        []views.ViewTuple      `json:"views" xml:"view"`
	View         views.ViewRef          `json:"view_id" xml:"view_id,attr"`
	AutoRefresh  bool                   `json:"auto_refresh" xml:"auto_refresh,attr"`
	ManualSearch bool                   `json:"-" xml:"-"`
	ActViewType  ActionViewType         `json:"-" xml:"view_type"`
	ViewMode     string                 `json:"view_mode" xml:"view_mode,attr"`
	Multi        bool                   `json:"multi" xml:"multi,attr"`
	Target       string                 `json:"target" xml:"target,attr"`
	AutoSearch   bool                   `json:"auto_search" xml:"auto_search,attr"`
	Filter       bool                   `json:"filter" xml:"filter,attr"`
	Limit        int64                  `json:"limit" xml:"limit,attr"`
	Context      *types.Context         `json:"context" xml:"context,attr"`
	Flags        map[string]interface{} `json:"flags"`
	Tag          string                 `json:"tag"`
	ReportName   string                 `json:"report_name"`
	ReportType   string                 `json:"report_type"`
	ReportFile   string                 `json:"report_file"`
	Data         map[string]interface{} `json:"data"`
	// contains filtered or unexported fields
}

A Action is the definition of an action. Actions define the behavior of the system in response to user requests.

func (Action) ActionString added in v0.1.0

func (a Action) ActionString() ActionString

ActionString returns the ActionString associated with this action.

func (*Action) Sanitize

func (a *Action) Sanitize()

Sanitize makes the necessary updates to action definitions. It is good practice to call Sanitize before sending an action to the client.

func (Action) TranslatedName

func (a Action) TranslatedName(lang string) string

TranslatedName returns the translated name of this action in the given language

type ActionRef

type ActionRef [2]string

ActionRef is an array of two strings representing an action: - The first one is the ID of the action - The second one is the name of the action

func MakeActionRef

func MakeActionRef(id string) ActionRef

MakeActionRef creates an ActionRef from an action id

func (ActionRef) ID

func (ar ActionRef) ID() string

ID returns the ID of the current action reference

func (ActionRef) IsNull

func (ar ActionRef) IsNull() bool

IsNull returns true if this ActionRef references no action

func (ActionRef) MarshalJSON

func (ar ActionRef) MarshalJSON() ([]byte, error)

MarshalJSON is the JSON marshalling method of ActionRef It marshals empty ActionRef into null instead of ["", ""].

func (ActionRef) Name

func (ar ActionRef) Name() string

Name returns the name of the current action reference

func (*ActionRef) Scan

func (ar *ActionRef) Scan(src interface{}) error

Scan fetches the name of our action from the ID stored in the database to fill the ActionRef.

func (*ActionRef) UnmarshalJSON added in v0.1.0

func (ar *ActionRef) UnmarshalJSON(data []byte) error

UnmarshalJSON for ActionRef. Unmarshals false as an empty ActionRef

func (ActionRef) Value

func (ar ActionRef) Value() (driver.Value, error)

Value extracts ID of our ActionRef for storing in the database.

type ActionString added in v0.1.0

type ActionString struct {
	Type string
	ID   int64
}

An ActionString is the concatenation of the action type and its ID e.g. ir.actions.act_window,76

func (ActionString) MarshalJSON added in v0.1.0

func (as ActionString) MarshalJSON() ([]byte, error)

MarshalJSON for the actionString type. Marshals to false if the action string is empty

type ActionType

type ActionType string

An ActionType defines the type of action

const (
	ActionActWindow   ActionType = "ir.actions.act_window"
	ActionURL         ActionType = "ir.actions.act_url"
	ActionServer      ActionType = "ir.actions.server"
	ActionReport      ActionType = "ir.actions.report"
	ActionClient      ActionType = "ir.actions.client"
	ActionCloseWindow ActionType = "ir.actions.act_window_close"
)

Action types

type ActionViewType

type ActionViewType string

ActionViewType defines the type of view of an action

const (
	ActionViewTypeForm ActionViewType = "form"
	ActionViewTypeTree ActionViewType = "tree"
)

Action view types

type Collection

type Collection struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

A Collection is a collection of actions

var Registry *Collection

Registry is the action collection of the application

func NewCollection

func NewCollection() *Collection

NewCollection returns a pointer to a new Collection instance

func (*Collection) Add

func (ar *Collection) Add(a *Action)

Add adds the given action to our Collection

func (*Collection) GetActionLinksForModel

func (ar *Collection) GetActionLinksForModel(modelName string) []*Action

GetActionLinksForModel returns the list of linked actions for the model with the given name

func (*Collection) GetAll

func (ar *Collection) GetAll() []*Action

GetAll returns a list of all actions of this Collection. Actions are returned in an arbitrary order

func (*Collection) GetByID added in v0.1.2

func (ar *Collection) GetByID(id int64) (*Action, bool)

GetByID returns the Action with the given id

func (*Collection) GetByXMLID added in v0.1.0

func (ar *Collection) GetByXMLID(id string) (*Action, bool)

GetByXMLID returns the Action with the given xmlid

func (*Collection) LoadFromEtree

func (ar *Collection) LoadFromEtree(element *etree.Element)

LoadFromEtree reads the action given etree.Element, creates or updates the action and adds it to the given Collection if it not already.

func (*Collection) MustGetById

func (ar *Collection) MustGetById(id int64) *Action

MustGetById returns the Action with the given id It panics if the id is not found in the action registry

func (*Collection) MustGetByXMLID added in v0.1.0

func (ar *Collection) MustGetByXMLID(id string) *Action

MustGetByXMLID returns the Action with the given xmlid It panics if the id is not found in the action registry

Jump to

Keyboard shortcuts

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