Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hexya-erp/hexya

Hexya business application development framework
https://github.com/hexya-erp/hexya

business businessapp erp erp-framework go golang hexya

Last synced: 5 days ago
JSON representation

Hexya business application development framework

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.com/hexya-erp/hexya.svg?branch=master)](https://travis-ci.com/hexya-erp/hexya)
[![Go Report Card](https://goreportcard.com/badge/hexya-erp/hexya)](https://goreportcard.com/report/hexya-erp/hexya)
[![codecov](https://codecov.io/gh/hexya-erp/hexya/branch/master/graph/badge.svg)](https://codecov.io/gh/hexya-erp/hexya)
[![godoc reference](https://godoc.org/github.com/hexya-erp/hexya?status.png)](https://godoc.org/github.com/hexya-erp/hexya)
[![Gitter](https://badges.gitter.im/hexya-erp/community.svg)](https://gitter.im/hexya-erp/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

# Hexya

Hexya is an open source ERP and a business application development framework
written in Go.

This repository houses the business application development framework.
The ERP is built by integrating modules of the [Hexya Addons Project](https://github.com/hexya-addons)

## Features of the framework

The Hexya framework is designed to develop business applications quickly and safely.
It includes all needed components in a very opinionated way.

The examples below are here to give you a first idea of Hexya.

Head to the `/doc` directory and especially our [Tutorial](./doc/tutorial.adoc) if you want to start developing your business application with Hexya.

### ORM

Hexya includes a full-featured type safe ORM, including a type safe query builder.

Declare a model and add some fields
```go
var fields_User = map[string]models.FieldDefinition{
"Name": fields.Char{String: "Name", Help: "The user's username", Unique: true,
NoCopy: true, OnChange: h.User().Methods().OnChangeName()},
"Email": fields.Char{Help: "The user's email address", Size: 100, Index: true},
"Password": fields.Char{},
"IsStaff": fields.Boolean{String: "Is a Staff Member",
Help: "Set to true if this user is a member of staff"},
}

func init() {
models.NewModel("User")
h.User().AddFields(fields_User)
}
```

Use the ORM to create a record in the database with type-safe data
```go
newUser := h.User().Create(env, h.User().NewData().
SetName("John").
SetEmail("[email protected]").
SetIsStaff(true))
```

Search the database using the type-safe query builder and update records directly
```go
myUsers := h.User().Search(env,
q.User().Name().Contains("John").
And().Email().NotEquals("[email protected]"))
for _, myUser := range myUsers.Records() {
if myUser.IsStaff() {
myUser.SetEmail("[email protected]")
}
}
```

Add methods to the models
```go
// GetEmail returns the Email of the user with the given name
func user_GetEmail(rs m.UserSet, name string) string {
user := h.User().Search(env, q.User().Name().Equals("John")).Limit(1)
user.Sanitize() // Call other methods of the model
return user.Email() // If user is empty, then Email() will return the empty string
}

func init() {
h.User().NewMethod("GetEmail", user_GetEmail)
}
```

### Views

Define views of different types using a simple XML view definition and let the framework do the rendering:

```xml





















```

### Controllers

Most of the time, you do not need to declare controllers in Hexya.
Instead, declare an "Action" with the views you want and a menu to access it.
The framework will take care of the UI including rendering views, navigation, CRUD, etc.

```xml

```

### Iterative Definition and Modularity

Each part of the Hexya Framework is modular and follow the Iterative Definition concept.

This means that an object (for example a model class) can be defined in a module and then extended in place by dependent modules.
So any subsequent modification will be made on the original model and will be available for the whole application.

This makes it possible to customize the application by creating a new module with the new features without forking and still benefiting from upstream updates.

Example on models:
```go
package A

var fields_User = map[string]models.FieldDefinition{
"Name": fields.Char{String: "Name", Help: "The user's username", Unique: true,
NoCopy: true, OnChange: h.User().Methods().OnChangeName()},
"Email": fields.Char{Help: "The user's email address", Size: 100, Index: true},
"Password": fields.Char{},
"IsStaff": fields.Boolean{String: "Is a Staff Member",
Help: "Set to true if this user is a member of staff"},
}

func init() {
models.NewModel("User")
h.User().AddFields(fields_User)
}
```
```go
package B

var fields_User = map[string]models.FieldDefinition{
"Size": models.Float{},
}

func init() {
h.User().AddFields(fields_User)
}
```
```go
// Anywhere else
newUser := h.User().Create(env, h.User().NewData().
SetName("John").
SetEmail("[email protected]").
SetSize(185.7))
fmt.Println(newUser.Name())
// output : John
fmt.Println(newUser.Size())
// output : 185.7
```

Model methods can be extended too:

```go
package A

// GetEmail returns the Email of the user with the given name
func user_GetEmail(rs m.UserSet, name string) string {
user := h.User().Search(rs.Env(), q.User().Name().Equals(name)).Limit(1)
user.Sanitize()
return user.Email()
}

func init() {
h.User().NewMethod("GetEmail", user_GetEmail)
}
```
```go
package B

func init() {
h.User().Methods().GetEmail().Extend(
func(rs m.UserSet, name string) string {
res := rs.Super().GetEmail(name)
return fmt.Sprintf("<%s>", res)
})
}
```
```go
// Anywhere else
email := h.User().NewSet(env).GetEmail("John")
fmt.Println(email)
// output:
```

And it works also with views:
```xml






```
```xml



```
And the rendered view will be :
```xml





```
# Contributing

If you wish to contribute to HEXYA project, you can:
1. Suggest an improvement via opening an issue in this repository or related project addons
2. Proposing a pull request for a feature or bug fix
3. Helping with the documentation of this project.
4. Any other action that may help improve the project further such as marketing campaigns, promoting adoption etc.

For developers, we are always looking for developers to join our community and make the project feature rich. If you are interested in contributing to this project. You can join our [slack channel](https://join.slack.com/t/nuovaareadila-3id2004/shared_invite/zt-1kj6ncmas-TI4DTVaVvHfg1CFCoAm15Q). All issues and feature will be discussed here and approach or design issues addressed.

In addition, you can check the [Design guidelines](doc/design.adoc) and [contribution guide](doc/contribution.adoc) for further information.