Hexya business application development framework

Overview

Build Status Go Report Card codecov godoc reference Gitter License

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

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

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

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

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

// 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:

<view id="base_view_users_form_simple_modif" model="User" priority="18">
    <form string="Users">
        <field name="image" readonly="0" widget='image'
               options='{"preview_image": "image_small"}'/>
        <h1>
            <field name="name" readonly="1"/>
        </h1>
        <button name="preference_change_password" type="object" string="Change password"/>
        <group name="preferences" col="4">
            <field name="lang" readonly="0"/>
            <field name="tz" widget="timezone_mismatch" options="{'tz_offset_field': 'tz_offset'}"
                   readonly="0"/>
            <field name="tz_offset" invisible="1"/>
            <field name="company_id" options="{'no_create': True}" readonly="0"
                   groups="base_group_multi_company"/>
        </group>
        <group string="Email Preferences">
            <field name="email" widget="email" readonly="0"/>
            <field name="signature" readonly="0"/>
        </group>
        <footer>
            <button name="preference_save" type="object" string="Save" class="btn-primary"/>
            <button name="preference_cancel" string="Cancel" special="cancel" class="btn-default"/>
        </footer>
    </form>
</view>

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.

<action id="base_action_res_users" 
        type="ir.actions.act_window" 
        name="Users" 
        model="User"
        view_id="base_view_users_tree" 
        search_view_id="base_view_users_search" 
        view_mode="tree,form,calendar"/>

<menuitem id="base_menu_action_users" 
          name="Users" 
          sequence="1" 
          action="base_action_res_users"
          parent="base_menu_users"/>

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:

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)
}
package B

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

func init() {
    h.User().AddFields(fields_User)
}
// 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:

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)
}
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)
    	})
}
// Anywhere else
email := h.User().NewSet(env).GetEmail("John")
fmt.Println(email)
// output: <[email protected]>

And it works also with views:

<!-- Package A -->
<view id="base_view_users_tree" model="User">
    <tree string="Users">
        <field name="Name"/>
        <field name="Login"/>
        <field name="Lang"/>
        <field name="LoginDate"/>
    </tree>
</view>
<!-- Package B -->
<view inherit_id="base_view_users_tree">
    <field name="Login" position="after">
        <field name="IsStaff"/>
    </field>
</view>

And the rendered view will be :

<tree string="Users">
    <field name="Name"/>
    <field name="Login"/>
    <field name="IsStaff"/>
    <field name="Lang"/>
    <field name="LoginDate"/>
</tree>
Comments
  • Generate error, pool killed

    Generate error, pool killed

    I try install the hexya on ubuntu vps. The hexya command "hexya generate" returns a error:

    Generating pool...Killed

    Someone know why this error show up and the hexya don't complete the generating process?

    opened by labneco 6
  • import error

    import error

    Fetching https://golang.org/x/text/transform?go-get=1 https fetch failed: Get https://golang.org/x/text/transform?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. package golang.org/x/text/transform: unrecognized import path "golang.org/x/text/transform" (https fetch: Get https://golang.org/x/text/transform?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) Fetching https://golang.org/x/text/unicode/norm?go-get=1 https fetch failed: Get https://golang.org/x/text/unicode/norm?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. package golang.org/x/text/unicode/norm: unrecognized import path "golang.org/x/text/unicode/norm" (https fetch: Get https://golang.org/x/text/unicode/norm?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) Fetching https://golang.org/x/tools/go/loader?go-get=1 https fetch failed: Get https://golang.org/x/tools/go/loader?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. package golang.org/x/tools/go/loader: unrecognized import path "golang.org/x/tools/go/loader" (https fetch: Get https://golang.org/x/tools/go/loader?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

    opened by hzmsrv 5
  • Binary executable deploy?

    Binary executable deploy?

    We can not deploy hexya as binary executable when invoke hexya server (because of calling cleanModuleSymlinks/createModuleSymlinks ). IMHO, cleanModuleSymlinks/createModuleSymlinks should be call when invoke hexya generate

    enhancement 
    opened by halybang 4
  • hexya updatedb failed

    hexya updatedb failed

    I'm trying to install hexya demo project, with follwoing step hexya installed fine less installed fine git clone https://github.com/hexya-erp/hexya-demo.git cd hexya-demo hexya generate . -c ./hexya.toml

    All work fine until "hexya updatedb -c ./hexya.toml" I got following errors :

    Please wait, Hexya is starting ... #github.com/hexya-erp/pool/q/account_account_tag pool/q/account_account_tag/account_account_tag.go:118:28: undefined: models.NewFieldName pool/q/account_account_tag/account_account_tag.go:125:28: undefined: models.NewFieldName .... many similar error about models.NewFieldName

    the postgres db is up and running, here are my hexya.toml configuration,

    Modules = [
        "github.com/hexya-addons/account"
    ]
    LogStdout = true
    #LogFile = ""
    LogLevel = "info"
    Debug = true
    Demo = true
    DataDir = "./hexya-datadir"
    
    [DB]
    Driver = "postgres"
    Host = "localhost"
    Port = 5432
    User = "dbuser"
    Password = "dbuserpass"
    Name = "hexya"
    SSLMode = false
    #SSLCert = ""
    #SSLKey = ""
    #SSLCA = ""
    
    [Server]
    Languages = ["all"]
    #Interface = ""
    Port = 8080
    Domain = "localhost"
    #Certificate = ""
    #PrivateKey = ""
    

    It seems models.NewFieldName not imported correctly ?

    opened by bandirsen 2
  • Undefined: strutils.IsInStringSlice

    Undefined: strutils.IsInStringSlice

    Windows 10x64, PostgreSQL 11 on updatedb on hexya-demo got this errors:

    $ hexya updatedb -o
    Please wait, Hexya is starting ...
    # github.com/hexya-addons/web/scripts
    C:\Go\workspace\pkg\mod\github.com\hexya-addons\[email protected]\scripts\i18nUpdate.go:146:7: undefined: strutils.IsInStringSlice
    # github.com/hexya-erp/pool/m
    pool\m\account_account_tag.go:234:31: undefined: h
    pool\m\account_tax.go:281:22: undefined: h
    pool\m\account_tax.go:283:43: undefined: h
    pool\m\account_tax.go:309:31: undefined: h
    pool\m\account_tax.go:317:18: undefined: h
    pool\m\account_tax.go:347:22: undefined: h
    pool\m\account_tax.go:349:21: undefined: h
    pool\m\account_tax.go:351:27: undefined: h
    pool\m\account_tax.go:379:31: undefined: h
    pool\m\account_tax_group.go:225:31: undefined: h
    pool\m\account_tax.go:379:31: too many errors
    
    opened by Nemo08 2
  • Some enhancement

    Some enhancement

    -Support JSON data type as PostgreSQL (native support), -Support PostgreSQL extensions (I want to use some extensions like timeseridb ...) -Modules Pre_Init function: Some modules need to setup some params before hexya start, but after read configuration. If module call setup code inside module-init functions, it can not read/parse config. If call in module-Post_Init function, the server already started, so modules can not register new route (for gin). For exam: I want to register an OAuth handler (http://host:post/auth/:provider), using params(path/ClientID/SecrectID) from config file.

    enhancement 
    opened by halybang 2
  • Support Casbin as the authorization backend

    Support Casbin as the authorization backend

    Hi, Casbin is an authorization library that supports models like ACL, RBAC, ABAC.

    Related to RBAC, Casbin has several advantages:

    1. roles can be cascaded, aka roles can have roles.
    2. support resource roles, so users have their roles and resource have their roles too. role = group here.
    3. the permission assignments (or policy in Casbin's language) can be persisted in files or database (MySQL and Cassandra).

    And you can even customize your own access control model, for example, mix RBAC and ABAC together by using roles and attributes at the same time. It's very flexible.

    Casbin can provide more flexibility and security than the current ACL. I can make PR if needed. Let me know if there's any question:) Thanks.

    opened by hsluoyz 2
  • browser access error

    browser access error

    1.when access the server at http://172.16.16.17:8080, browser having error...information

    SyntaxError: expected expression, got '<'

    http://172.16.16.17:8080/web/webclient/locale/en_US:4 Traceback:

    2、using login and password loging web ,will having information Traceback: TypeError: Cannot read property 'getBoundingClientRect' of undefined at computeFloatOuterWidthWithMargins (http://172.16.16.17:8080/static/web/src/js/core/dom.js:551:27) at _adapt (http://172.16.16.17:8080/static/web/src/js/core/dom.js:540:35) at Object.initAutoMoreMenu (http://172.16.16.17:8080/static/web/src/js/core/dom.js:474:9) at http://172.16.16.17:8080/static/web/src/js/chrome/menu.js:72:17 at async Promise.all (index 2) at async Promise.all (index 0)

    opened by lihong12500 1
  •  hexya generate did not work completely in ubuntu, but windows and mac is ok.

    hexya generate did not work completely in ubuntu, but windows and mac is ok.

    hexya generate did not work completely. go mod is correct (in particular the 'replace' directive), but the pool package is not generated as it should.

    hexya generate .
    
    module github.com/myusername/myhexyaproject
    
    go 1.14
    
    replace github.com/hexya-erp/pool v1.0.2 => /home/gleke/hexya/myproject/pool
    
    require (
            github.com/hexya-addons/web v0.1.7
            github.com/hexya-erp/hexya v0.1.7
            github.com/spf13/cobra v0.0.5
    )
    
    pool
    
    [email protected]:~/hexya/myproject$ cd pool
    [email protected]:~/hexya/myproject/pool$ ls
    go.mod  h  m  q
    [email protected]:~/hexya/myproject/pool$ 
    go.mod
    
    // This file is autogenerated by hexya-generate
    // DO NOT MODIFY THIS FILE - ANY CHANGES WILL BE OVERWRITTEN
    
    module github.com/hexya-erp/pool
    [email protected]:~/hexya/myproject/pool$ cd h
    [email protected]:~/hexya/myproject/pool/h$ ls
    temp.go
    [email protected]:~/hexya/myproject/pool/h$ cd m
    temp.go
    
    // This file is autogenerated by hexya-generate
    // DO NOT MODIFY THIS FILE - ANY CHANGES WILL BE OVERWRITTEN
    
    package h
    

    hexya generate did not work completely in ubuntu, but windows and mac is ok.

    func loadProgram(targetPaths []string) ([]*packages.Package, error) {
    	conf := packages.Config{
    		Mode: packages.LoadAllSyntax,
    	}
    	fmt.Println("loadProgram()------------")
    	fmt.Println(targetPaths)
    	fmt.Println(conf)
    	packs, err := packages.Load(&conf, targetPaths...)
    	fmt.Println(packs)
    	return packs, err
    }
    

    log in windows

    c:\hexya-demo>hexya generate .
    Hexya Generate
            --------------
    Modules paths:
     - github.com/hexya-addons/web
    1/5 - Loading program...loadProgram()------------
    [github.com/hexya-addons/web]
    {991 <nil> <nil>  [] [] <nil> <nil> false map[]}
    [github.com/hexya-addons/web]
    [github.com/hexya-addons/web]
    

    log in ubuntu

    [email protected]:~/mytest$ hexya generate .
    Hexya Generate
    	--------------
    Modules paths:
     - github.com/hexya-addons/web
    1/5 - Loading program...loadProgram()------------
    [github.com/hexya-addons/web]
    {991 <nil> <nil>  [] [] <nil> <nil> false map[]}
    [command-line-arguments]
    [command-line-arguments]
    Ok
    

    packages.Load return is [command-line-arguments] in ubuntu,why?

    opened by gleke 7
  • You must call hexya module new from a project directory

    You must call hexya module new from a project directory

    Hi,

    I'm getting the following error "You must call hexya module new from a project directory" when running the "hexya module new openacademy" from the tutorial. Windows 10, Go 1.15.6

    Issue is in cmd/module.go:78 c := exec.Command("go", "list", "-f", "'{{ .Name }}")

    Fixing the .Name like this works for me c := exec.Command("go", "list", "-f", "'{{.Name}}'")

    Which is equivalent to this go list -f '{{.Name}}'

    opened by felipechang 2
  • Config File

    Config File "hexya" Not Found

    hexya server -o Config File "hexya" Not Found in "[/etc/hexya /home/gleke/.hexya /home/gleke/hexya]"

    the configuration file needs to be created by yourself?

    opened by gleke 14
Owner
Hexya
Hexya is an open source ERP and a business application development framework
Hexya
QOR is a set of libraries written in Go that abstracts common features needed for business applications, CMSs, and E-commerce systems.

QOR English Chat Room: 中文聊天室: For security issues, please send us an email to [email protected] and give us time to respond BEFORE posting as an iss

QOR 5.1k Dec 2, 2022
GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang.

GoFrame English | 简体中文 GoFrame is a modular, powerful, high-performance and enterprise-class application development framework of Golang. If you're a

GoFrame 8.6k Nov 29, 2022
GoFarm is an Application Development Framework for especially Backend Developer with Golang

What is GoFarm GoFarm is an Application Development Framework for especially Backend Developer with Golang. Our goal is to develop easier, standardize

Alvin Leonardo 2 Dec 9, 2021
Goal is a toolkit for high productivity web development in Go language in the spirit of Revel Framework that is built around the concept of code generation.

Goal Goal is a set of tools for high productivity web development in Go language. Goal, being mostly inspired by Revel Framework and its discussions,

null 88 Sep 27, 2021
go-zero is a web and rpc framework written in Go. It's born to ensure the stability of the busy sites with resilient design. Builtin goctl greatly improves the development productivity.

go-zero English | 简体中文 0. what is go-zero go-zero is a web and rpc framework that with lots of engineering practices builtin. It’s born to ensure the

好未来技术 21.7k Dec 2, 2022
Roche is a Code Generator and Web Framework, makes web development super concise with Go, CleanArch

It is still under development, so please do not use it. We plan to release v.1.0.0 in the summer. roche is a web framework optimized for microservice

Riita 14 Sep 19, 2022
based on go lang build WEB development framework for go lang beginners .

based on go lang build WEB development framework for go lang beginners .

zhenfan.yu 1 Oct 31, 2021
hiboot is a high performance web and cli application framework with dependency injection support

Hiboot - web/cli application framework About Hiboot is a cloud native web and cli application framework written in Go. Hiboot is not trying to reinven

hidevops.io 179 Nov 20, 2022
Mango is a modular web-application framework for Go, inspired by Rack, and PEP333.

Mango Mango is a modular web-application framework for Go, inspired by Rack and PEP333. Note: Not actively maintained. Overview Mango is most of all a

Paul Bellamy 371 Nov 17, 2022
A powerful go web framework for highly scalable and resource efficient web application

webfr A powerful go web framework for highly scalable and resource efficient web application Installation: go get -u github.com/krishpranav/webfr Exa

Krisna Pranav 13 Nov 28, 2021
A powerful go web framework for highly scalable and resource efficient web application

A powerful go web framework for highly scalable and resource efficient web application

null 22 Oct 3, 2022
A web application framework with complete functions and good scalability

English | 中文 Abuout Goravel Goravel is a web application framework with complete

null 29 Nov 28, 2022
Rapid Web Development w/ Go

Buffalo A Go web development eco-system, designed to make your project easier. Buffalo helps you to generate a web project that already has everything

Buffalo - The Go Web Eco-System 7.3k Dec 1, 2022
Simple Janet web development platform in Go, à la PHP

Spinnerette Simple Janet web development platform in Go, à la PHP Building make This will handle pulling submodules, building Janet, and then building

Steven vanZyl 11 Dec 3, 2022
Boilerplate API template includes all the common packages and setup used for API development in this Company

Boilerplate API Boilerplate API template includes all the common packages and setup used for API development in this Company. Development Copy .env.ex

null 11 Feb 19, 2022
Flamingo Framework and Core Library. Flamingo is a go based framework for pluggable web projects. It is used to build scalable and maintainable (web)applications.

Flamingo Framework Flamingo is a web framework based on Go. It is designed to build pluggable and maintainable web projects. It is production ready, f

Flamingo 329 Dec 5, 2022
Golanger Web Framework is a lightweight framework for writing web applications in Go.

/* Copyright 2013 Golanger.com. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except

golanger 298 Nov 14, 2022
The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework.

jin About The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework. If thi

null 8 Jul 14, 2022
laravel for golang,goal,fullstack framework,api framework

laravel for golang,goal,fullstack framework,api framework

桥边红药 17 Feb 24, 2022