[IMP]API Break : no ox- forced namespace anymore
This commit is contained in:
parent
82e5f1990d
commit
4744b46ba8
100
hy_odoo/odoo.hy
100
hy_odoo/odoo.hy
@ -39,37 +39,37 @@
|
|||||||
|
|
||||||
; XML helpers functions and macros
|
; XML helpers functions and macros
|
||||||
|
|
||||||
(defn ox-odoo [&rest args] (xmlroot (xmln "odoo" {} #*args)))
|
(defn odoo [&rest args] (xmlroot (xmln "odoo" {} #*args)))
|
||||||
(defn ox-data [&rest args] (xmln "data" {} #*args))
|
(defn data [&rest args] (xmln "data" {} #*args))
|
||||||
(defn ox-record [&rest args] (xmln "record" #*args))
|
(defn record [&rest args] (xmln "record" #*args))
|
||||||
(defn ox-form [&rest args] (xmln "form" #*args))
|
(defn form [&rest args] (xmln "form" #*args))
|
||||||
(defn ox-tree [&rest args] (xmln "tree" #*args))
|
(defn tree [&rest args] (xmln "tree" #*args))
|
||||||
(defn ox-search [&rest args] (xmln "search" #*args))
|
(defn search [&rest args] (xmln "search" #*args))
|
||||||
(defn ox-act-window [&rest args] (xmln "act_window" #*args))
|
(defn act-window [&rest args] (xmln "act_window" #*args))
|
||||||
(defn ox-act-window-model [model attrs]
|
(defn act-window-model [model attrs]
|
||||||
" Build new act_window from model and args"
|
" Build new act_window from model and args"
|
||||||
(setv model_und (.replace model "." "_")
|
(setv model_und (.replace model "." "_")
|
||||||
model_cap (.join " " (lfor w (.split model ".") (.capitalize w)))
|
model_cap (.join " " (lfor w (.split model ".") (.capitalize w)))
|
||||||
xmlid f"{model_und}_view_action"
|
xmlid f"{model_und}_view_action"
|
||||||
name f"{model_cap} Action")
|
name f"{model_cap} Action")
|
||||||
(.update attrs {"id" xmlid "name" name "res_model" model})
|
(.update attrs {"id" xmlid "name" name "res_model" model})
|
||||||
(ox-act-window attrs))
|
(act-window attrs))
|
||||||
(defn ox-menuitem [&rest args] (xmln "menuitem" #*args))
|
(defn menuitem [&rest args] (xmln "menuitem" #*args))
|
||||||
(defn ox-menuitem-model [model attrs]
|
(defn menuitem-model [model attrs]
|
||||||
" Build new menuitem from model and attrs"
|
" Build new menuitem from model and attrs"
|
||||||
(setv model_und (.replace model "." "_")
|
(setv model_und (.replace model "." "_")
|
||||||
actionid f"{model_und}_view_action"
|
actionid f"{model_und}_view_action"
|
||||||
xmlid f"{model_und}_menu")
|
xmlid f"{model_und}_menu")
|
||||||
(.update attrs {"id" xmlid "action" actionid})
|
(.update attrs {"id" xmlid "action" actionid})
|
||||||
(ox-menuitem attrs))
|
(menuitem attrs))
|
||||||
(defn ox-group [&rest args] (xmln "group" #*args))
|
(defn group [&rest args] (xmln "group" #*args))
|
||||||
(defn ox-header [&rest args] (xmln "header" #*args))
|
(defn header [&rest args] (xmln "header" #*args))
|
||||||
(defn ox-footer [&rest args] (xmln "footer" #*args))
|
(defn footer [&rest args] (xmln "footer" #*args))
|
||||||
(defn ox-sheet [&rest args] (xmln "sheet" #*args))
|
(defn sheet [&rest args] (xmln "sheet" #*args))
|
||||||
(defn ox-button [&rest args] (xmln "button" #*args))
|
(defn button [&rest args] (xmln "button" #*args))
|
||||||
(defn ox-p [&rest args] (xmln "p" #*args))
|
(defn p [&rest args] (xmln "p" #*args))
|
||||||
(defn ox-field [&rest args]
|
(defn field [&rest args]
|
||||||
"Special ox-field allowing mangling name attribute"
|
"Special field allowing mangling name attribute"
|
||||||
(setv attrs (nth args 0))
|
(setv attrs (nth args 0))
|
||||||
(when (and (instance? dict attrs) (in "name" attrs))
|
(when (and (instance? dict attrs) (in "name" attrs))
|
||||||
(assoc attrs "name" (mangle (get attrs "name")))
|
(assoc attrs "name" (mangle (get attrs "name")))
|
||||||
@ -78,55 +78,55 @@
|
|||||||
(setv args (tuple args)))
|
(setv args (tuple args)))
|
||||||
(xmln "field" #*args))
|
(xmln "field" #*args))
|
||||||
|
|
||||||
(defn ox-field-name [name] (ox-field {"name" "name"} [name]))
|
(defn field-name [name] (field {"name" "name"} [name]))
|
||||||
(defn ox-field-model [model] (ox-field {"name" "model"} [model]))
|
(defn field-model [model] (field {"name" "model"} [model]))
|
||||||
(defn ox-field-inherit [xmlid] (ox-field {"name" "inherit_id" "ref" xmlid} []))
|
(defn field-inherit [xmlid] (field {"name" "inherit_id" "ref" xmlid} []))
|
||||||
(defn ox-field-arch [&rest args] (ox-field {"name" "arch" "type" "xml"} #*args))
|
(defn field-arch [&rest args] (field {"name" "arch" "type" "xml"} #*args))
|
||||||
|
|
||||||
|
|
||||||
(defn ox-view [xmlid children] (ox-record {"id" xmlid "model" "ir.ui.view"} children))
|
(defn view [xmlid children] (record {"id" xmlid "model" "ir.ui.view"} children))
|
||||||
(defn ox-view-def [xmlid name model arch]
|
(defn view-def [xmlid name model arch]
|
||||||
"View and first fields simplification with record xmlid, name, targeted model"
|
"View and first fields simplification with record xmlid, name, targeted model"
|
||||||
(ox-view xmlid
|
(view xmlid
|
||||||
[(ox-field-name name)
|
[(field-name name)
|
||||||
(ox-field-model model)
|
(field-model model)
|
||||||
(ox-field-arch arch)]))
|
(field-arch arch)]))
|
||||||
(defn ox-view-new[view_type model arch]
|
(defn view-new[view_type model arch]
|
||||||
"View : new view definition, based on type (form, tree, ...) and model ID"
|
"View : new view definition, based on type (form, tree, ...) and model ID"
|
||||||
(setv model_und (.replace model "." "_")
|
(setv model_und (.replace model "." "_")
|
||||||
model_cap (.join " " (lfor w (.split model ".") (.capitalize w)))
|
model_cap (.join " " (lfor w (.split model ".") (.capitalize w)))
|
||||||
xmlid f"{model_und}_view_{view_type}"
|
xmlid f"{model_und}_view_{view_type}"
|
||||||
name f"{model_cap} {(.capitalize view_type)}")
|
name f"{model_cap} {(.capitalize view_type)}")
|
||||||
(ox-view-def :xmlid xmlid :name name :model model :arch arch))
|
(view-def :xmlid xmlid :name name :model model :arch arch))
|
||||||
(defn ox-view-inherit [name model inherit arch]
|
(defn view-inherit [name model inherit arch]
|
||||||
"Inherited View simplification with name of the record, xmlid for model and
|
"Inherited View simplification with name of the record, xmlid for model and
|
||||||
inherited view"
|
inherited view"
|
||||||
(setv module (get (.split __name__ ".") 2)
|
(setv module (get (.split __name__ ".") 2)
|
||||||
inherited (get (.split inherit ".") 1)
|
inherited (get (.split inherit ".") 1)
|
||||||
xmlid f"{inherited}_inherit_{module}")
|
xmlid f"{inherited}_inherit_{module}")
|
||||||
(ox-view xmlid
|
(view xmlid
|
||||||
[(ox-field-name name)
|
[(field-name name)
|
||||||
(ox-field-model model)
|
(field-model model)
|
||||||
(ox-field-inherit inherit)
|
(field-inherit inherit)
|
||||||
(ox-field-arch arch)]))
|
(field-arch arch)]))
|
||||||
|
|
||||||
(defn ox-actions-server-code [xmlid name modelref code]
|
(defn actions-server-code [xmlid name modelref code]
|
||||||
"Server actions of type code"
|
"Server actions of type code"
|
||||||
(ox-record {"id" xmlid "model" "ir.actions.server"}
|
(record {"id" xmlid "model" "ir.actions.server"}
|
||||||
[(ox-field-name name)
|
[(field-name name)
|
||||||
(ox-field {"name" "model_id" "ref" modelref} [])
|
(field {"name" "model_id" "ref" modelref} [])
|
||||||
(ox-field {"name" "state"} ["code"])
|
(field {"name" "state"} ["code"])
|
||||||
(ox-field {"name" "code"} [code])]))
|
(field {"name" "code"} [code])]))
|
||||||
|
|
||||||
(defn ox-client-action-multi [xmlid name model action]
|
(defn client-action-multi [xmlid name model action]
|
||||||
"Client action multi (ir.values), with own xmlid, name, targeted model and
|
"Client action multi (ir.values), with own xmlid, name, targeted model and
|
||||||
action"
|
action"
|
||||||
(setv action f"'ir.actions.server,%d'%{action}")
|
(setv action f"'ir.actions.server,%d'%{action}")
|
||||||
(ox-record {"id" xmlid "model" "ir.values"}
|
(record {"id" xmlid "model" "ir.values"}
|
||||||
[(ox-field-name name)
|
[(field-name name)
|
||||||
(ox-field {"name" "key2" "eval" "'client_action_multi'"} [])
|
(field {"name" "key2" "eval" "'client_action_multi'"} [])
|
||||||
(ox-field {"name" "model" "eval" (+ "'" model "'")} [])
|
(field {"name" "model" "eval" (+ "'" model "'")} [])
|
||||||
(ox-field {"name" "value" "eval" action})]))
|
(field {"name" "value" "eval" action})]))
|
||||||
|
|
||||||
; Odoo Backend macros
|
; Odoo Backend macros
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user