[IMP]Odoo : new XML nodes, improve view inherit macro, attempt for _translate...

But Odoo black magic, does not work with AST and so Hy...
This commit is contained in:
Fabien BOURGEOIS 2020-04-25 16:51:54 +02:00
parent bb5c3a8cb8
commit 811c166f90
1 changed files with 15 additions and 8 deletions

View File

@ -68,6 +68,9 @@
(defn sheet [&rest args] (xmln "sheet" #*args)) (defn sheet [&rest args] (xmln "sheet" #*args))
(defn button [&rest args] (xmln "button" #*args)) (defn button [&rest args] (xmln "button" #*args))
(defn p [&rest args] (xmln "p" #*args)) (defn p [&rest args] (xmln "p" #*args))
(defn xpath [&rest args] (xmln "xpath" #*args))
(defn attribute [name value] (xmln "attribute" {"name" name} [value]))
(defn field [&rest args] (defn field [&rest args]
"Special field allowing mangling name attribute" "Special field allowing mangling name attribute"
(setv attrs (nth args 0)) (setv attrs (nth args 0))
@ -98,17 +101,19 @@
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)}")
(view-def :xmlid xmlid :name name :model model :arch arch)) (view-def :xmlid xmlid :name name :model model :arch arch))
(defn view-inherit [name model inherit arch] (defn view-inherit [filename 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 filename ".") 2)
inherited (get (.split inherit ".") 1) inherited (get (.split inherit ".") 1)
xmlid f"{inherited}_inherit_{module}") xmlid f"{inherited}_inherit_{module}"
(view xmlid model_cap (.join " " (lfor w (.split model ".") (.capitalize w)))
[(field-name name) name f"{model_cap} Adaptations")
(field-model model) (view xmlid
(field-inherit inherit) [(field-name name)
(field-arch arch)])) (field-model model)
(field-inherit inherit)
(field-arch arch)]))
(defn 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"
@ -145,6 +150,8 @@
(setv fn-name f"_compute_{(mangle fname)}") (setv fn-name f"_compute_{(mangle fname)}")
`(setv ~fname (~@body :compute ~fn-name))) `(setv ~fname (~@body :compute ~fn-name)))
(defmacro __ [sentence] `((py "_") ~sentence))
; Migrations ; Migrations
(defn generate-fn-name [filepath] (defn generate-fn-name [filepath]