diff --git a/hy_base/odoo.hy b/hy_base/odoo.hy index 6c98967..f2aa17e 100644 --- a/hy_base/odoo.hy +++ b/hy_base/odoo.hy @@ -48,3 +48,12 @@ (defmacro field-model [model] `(field {"name" "model"} [~model])) (defmacro field-inherit [xmlid] `(field {"name" "inherit_id" "ref" ~xmlid} [])) (defmacro field-arch [&rest args] `(field {"name" "arch" "type" "xml"} ~@args)) + +(defmacro xml-write [filename tree] + "Write XML file according to filename and given tree" + `(do + (import [os [path]]) + (setv elementtree ~tree) + (setv output (.tostring ET elementtree)) + (setv fpath (+ (.dirname path (.abspath path __file__)) "/" ~filename)) + (with [f (open fpath "w")] (.write f output))))