[ADD]Hy Odoo additions
* Add strdm helper to build domain string from hy style tuple ; * Add ox-act-window-action to shortcut ; * Add ox menuitems functions. *
This commit is contained in:
parent
f4db225ccc
commit
5927560259
@ -20,6 +20,16 @@
|
|||||||
(import [os [path]])
|
(import [os [path]])
|
||||||
(import [hy-odoo.xml [xmlroot xmln]])
|
(import [hy-odoo.xml [xmlroot xmln]])
|
||||||
|
|
||||||
|
; Global helpers
|
||||||
|
|
||||||
|
(defn strdm [hy-domain]
|
||||||
|
"Generate Odoo domain from Hy like tuple domain"
|
||||||
|
(do
|
||||||
|
(setv (, op field value) hy-domain
|
||||||
|
field (mangle field)
|
||||||
|
value (if (string? value) f"'{value}'" value))
|
||||||
|
(return f"('{field}', '{op}', {value})")))
|
||||||
|
|
||||||
; XML helpers functions and macros
|
; XML helpers functions and macros
|
||||||
|
|
||||||
(defn ox-odoo [&rest args] (xmlroot (xmln "odoo" {} #*args)))
|
(defn ox-odoo [&rest args] (xmlroot (xmln "odoo" {} #*args)))
|
||||||
@ -29,6 +39,22 @@
|
|||||||
(defn ox-tree [&rest args] (xmln "tree" #*args))
|
(defn ox-tree [&rest args] (xmln "tree" #*args))
|
||||||
(defn ox-search [&rest args] (xmln "search" #*args))
|
(defn ox-search [&rest args] (xmln "search" #*args))
|
||||||
(defn ox-act-window [&rest args] (xmln "act_window" #*args))
|
(defn ox-act-window [&rest args] (xmln "act_window" #*args))
|
||||||
|
(defn ox-act-window-action [model attrs]
|
||||||
|
" Build new act_window from model and args"
|
||||||
|
(setv model_und (.replace model "." "_")
|
||||||
|
model_cap (.join " " (lfor w (.split model ".") (.capitalize w)))
|
||||||
|
xmlid f"{model_und}_view_action"
|
||||||
|
name f"{model_cap} Action")
|
||||||
|
(.update attrs {"id" xmlid "name" name "res_model" model})
|
||||||
|
(ox-act-window attrs))
|
||||||
|
(defn ox-menuitem [&rest args] (xmln "menuitem" #*args))
|
||||||
|
(defn ox-menuitem-model [model attrs]
|
||||||
|
" Build new menuitem from model and attrs"
|
||||||
|
(setv model_und (.replace model "." "_")
|
||||||
|
actionid f"{model_und}_view_action"
|
||||||
|
xmlid f"{model_und}_menu")
|
||||||
|
(.update attrs {"id" xmlid "action" actionid})
|
||||||
|
(ox-menuitem attrs))
|
||||||
(defn ox-group [&rest args] (xmln "group" #*args))
|
(defn ox-group [&rest args] (xmln "group" #*args))
|
||||||
(defn ox-header [&rest args] (xmln "header" #*args))
|
(defn ox-header [&rest args] (xmln "header" #*args))
|
||||||
(defn ox-footer [&rest args] (xmln "footer" #*args))
|
(defn ox-footer [&rest args] (xmln "footer" #*args))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user