[ADD]Yaltik DSL : add filter_yes_no

This commit is contained in:
Fabien BOURGEOIS 2022-11-25 22:54:46 +01:00
parent 2cab9fe8f9
commit bc6f8797c4
3 changed files with 23 additions and 2 deletions

View File

@ -19,7 +19,7 @@
'name': 'Yaltik Odoo DSL base module and fns',
'summary': 'Yaltik Odoo Domain Specific Language base module and functions',
'description': """ Yaltik Odoo Domain Specific Language base module and functions """,
'version': '10.0.0.5.1',
'version': '10.0.0.5.2',
'category': 'Yaltik',
'author': 'Fabien Bourgeois',
'license': 'AGPL-3',

View File

@ -100,6 +100,17 @@ field_arch = lambda *args: field({'name': 'arch', 'type': 'xml'}, *args)
filter = lambda *args: xmln('filter', *args)
separator = lambda *args: xmln('separator', *args)
def filter_yes_no(field, str_yes=False, str_no=False):
""" Double filter for boolean : True and False """
res = []
if str_yes:
res.append(filter({'name': f'{field}_yes', 'string': str_yes,
'domain': f"[('{field}', '=', True)]"}))
if str_no:
res.append(filter({'name': f'{field}_no', 'string': str_no,
'domain': f"[('{field}', '=', False)]"}))
return res
# Views
view = lambda xmlid, children: record({'id': xmlid, 'model': 'ir.ui.view'}, children)

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# __coconut_hash__ = 0x8b091192
# __coconut_hash__ = 0x863a7289
# Compiled with Coconut version 2.1.1 [The Spanish Inquisition]
@ -137,7 +137,17 @@ field_arch = lambda *args: field({'name': 'arch', 'type': 'xml'}, *args)
filter = lambda *args: xmln('filter', *args)
separator = lambda *args: xmln('separator', *args)
def filter_yes_no(field, str_yes=False, str_no=False):
""" Double filter for boolean : True and False """
res = []
if str_yes:
res.append(filter({'name': '{_coconut_format_0}_yes'.format(_coconut_format_0=(field)), 'string': str_yes, 'domain': "[('{_coconut_format_0}', '=', True)]".format(_coconut_format_0=(field))}))
if str_no:
res.append(filter({'name': '{_coconut_format_0}_no'.format(_coconut_format_0=(field)), 'string': str_no, 'domain': "[('{_coconut_format_0}', '=', False)]".format(_coconut_format_0=(field))}))
return res
# Views
view = lambda xmlid, children: record({'id': xmlid, 'model': 'ir.ui.view'}, children)
def view_def(xmlid, name, model, arch):