[ADD]Odoo macros : new o-mod for self.env['model']

This commit is contained in:
Fabien BOURGEOIS 2021-02-17 19:00:58 +01:00
parent 24fe4e1cb3
commit ca9d06d1dc
1 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
;; -*- coding: utf-8 -*-
;;
;; Copyright 2019-2020 Fabien Bourgeois <fabien@yaltik.com>
;; Copyright 2019-2021 Fabien Bourgeois <fabien@yaltik.com>
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU Affero General Public License as
@ -15,7 +15,7 @@
;; You should have received a copy of the GNU Affero General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
" Odoo macros "
" Odoo macros and helpers "
(require [hy-odoo.xml [if-python2]])
(import [os [path]])
@ -31,6 +31,10 @@
value (if (string? value) f"'{value}'" value))
(return f"('{field}', '{op}', {value})")))
(defmacro o-mod [model-name]
"Odoo self.env model shortcut"
`(. self env [~model-name]))
(defmacro hydm [hy-domain]
"Generate Odoo domain from Hy like tuple domain"
(setv op (second hy-domain)