From 8859a4b340fe00e27dcc5512b0090c88610b242e Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Fri, 1 May 2020 12:57:14 +0200 Subject: [PATCH] [REF][UPD]Yaltik DSL : migration to coco finished --- yaltik_dsl/__init__.coco | 4 +- yaltik_dsl/__init__.py | 6 +-- yaltik_dsl/__manifest__.py | 5 ++- yaltik_dsl/odoo_dsl.coco | 66 ++++++++++++++++----------------- yaltik_dsl/odoo_dsl.py | 76 +++++++++++++++++++------------------- 5 files changed, 79 insertions(+), 78 deletions(-) diff --git a/yaltik_dsl/__init__.coco b/yaltik_dsl/__init__.coco index 99581b9..ee86a92 100644 --- a/yaltik_dsl/__init__.coco +++ b/yaltik_dsl/__init__.coco @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2019 Fabien Bourgeois +# Copyright 2019-2020 Fabien Bourgeois # # 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,4 +15,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from . import odoo +from . import odoo_dsl diff --git a/yaltik_dsl/__init__.py b/yaltik_dsl/__init__.py index b577fa5..c99635b 100644 --- a/yaltik_dsl/__init__.py +++ b/yaltik_dsl/__init__.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2 # -*- coding: utf-8 -*- -# __coconut_hash__ = 0xe22b9d74 +# __coconut_hash__ = 0x4a7a90c3 # Compiled with Coconut version 1.4.3 [Ernest Scribbler] @@ -21,7 +21,7 @@ from __coconut__ import _coconut, _coconut_MatchError, _coconut_igetitem, _cocon # -*- coding: utf-8 -*- -# Copyright 2019 Fabien Bourgeois +# Copyright 2019-2020 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -36,4 +36,4 @@ from __coconut__ import _coconut, _coconut_MatchError, _coconut_igetitem, _cocon # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from . import odoo +from . import odoo_dsl diff --git a/yaltik_dsl/__manifest__.py b/yaltik_dsl/__manifest__.py index fa8058b..a90ebb4 100644 --- a/yaltik_dsl/__manifest__.py +++ b/yaltik_dsl/__manifest__.py @@ -19,11 +19,12 @@ '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.2.4', + 'version': '10.0.0.3.0', 'category': 'Yaltik', 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', 'application': False, 'installable': True, - 'depends': ['base'] + 'depends': ['base'], + "external_dependencies": {'python' : ['typing']} } diff --git a/yaltik_dsl/odoo_dsl.coco b/yaltik_dsl/odoo_dsl.coco index 9536634..240dd14 100644 --- a/yaltik_dsl/odoo_dsl.coco +++ b/yaltik_dsl/odoo_dsl.coco @@ -34,13 +34,13 @@ def data(*args): # Aliases def function(*args) -> XMLDictElement = xmln('function', *args) -def record(*args) -> XMLDictElement = 'record' |> xmln$(?, *args) -def form(*args) -> XMLDictElement = 'form' |> xmln$ <*| args -def tree(*args) -> XMLDictElement = 'tree' |> xmln$ <*| args -def search(*args) -> XMLDictElement = 'search' |> xmln$ <*| args +def record(*args) -> XMLDictElement = xmln('record', *args) +def form(*args) -> XMLDictElement = xmln('form', *args) +def tree(*args) -> XMLDictElement = xmln('tree', *args) +def search(*args) -> XMLDictElement = xmln('search', *args) # Actions -def act_window(*args) -> XMLDictElement = 'act_window' |> xmln$ <*| args +def act_window(*args) -> XMLDictElement = xmln('act_window', *args) def act_window_model(model: Text, attrs: XMLAttrs) -> XMLDictElement: """ Build new act_window from model and args """ xmlid = '%s_view_action' % (('.', '_') |*> model.replace) @@ -49,8 +49,26 @@ def act_window_model(model: Text, attrs: XMLAttrs) -> XMLDictElement: {'id': xmlid, 'name': name, 'res_model': model} |> attrs_clone.update return act_window(attrs_clone) +def action_server_code(xmlid: Text, name: Text, modelref: Text, code: Text) -> XMLDictElement: + """ Server actions of type code """ + children = [name |> field_name, + ({'name': 'model_id', 'ref': modelref}, []) |*> field, + ({'name': 'state'}, ['code']) |*> field, + ({'name': 'code'}, [code]) |*> field] + return ({'id': xmlid, 'model': 'ir.actions.server'}, children) |*> record + +def client_action_multi(xmlid: Text, name: Text, model: Text, action: Text) -> XMLDictElement: + """ Client action multi (ir.values), with own xmlid, name, targeted model + and action """ + action = action |> "'ir.actions.server,%d'%{}".format + children = [name |> field_name, + {'name': 'key2', 'eval': "'client_action_multi'"} |> field, + {'name': 'model', 'eval': "'%s'" % model} |> field, + {'name': 'value', 'eval': action} |> field] + return ({'id': xmlid, 'model': 'ir.values'}, children) |*> record + # Menus -def menuitem(*args) -> XMLDictElement = 'menuitem' |> xmln$ <*| args +def menuitem(*args) -> XMLDictElement = xmln('menuitem', *args) def menuitem_model(model: Text, attrs: XMLAttrs) -> XMLDictElement: """ Build new menuitem from model and attrs """ model_und = ('.', '_') |*> model.replace @@ -61,18 +79,18 @@ def menuitem_model(model: Text, attrs: XMLAttrs) -> XMLDictElement: return menuitem(attrs_clone) # Form aliases -def group(*args) -> XMLDictElement = 'group' |> xmln$ <*| args -def header(*args) -> XMLDictElement = 'header' |> xmln$ <*| args -def footer(*args) -> XMLDictElement = 'footer' |> xmln$ <*| args -def sheet(*args) -> XMLDictElement = 'sheet' |> xmln$ <*| args -def button(*args) -> XMLDictElement = 'button' |> xmln$ <*| args -def p(*args) -> XMLDictElement = 'p' |> xmln$ <*| args -def xpath(*args) -> XMLDictElement = 'xpath' |> xmln$ <*| args +def group(*args) -> XMLDictElement = xmln('group', *args) +def header(*args) -> XMLDictElement = xmln('header', *args) +def footer(*args) -> XMLDictElement = xmln('footer', *args) +def sheet(*args) -> XMLDictElement = xmln('sheet', *args) +def button(*args) -> XMLDictElement = xmln('button', *args) +def p(*args) -> XMLDictElement = xmln('p', *args) +def xpath(*args) -> XMLDictElement = xmln('xpath', *args) def attribute(name: Text, value: Text) -> XMLDictElement: return ('attribute', {'name': name}, [value]) |*> xmln # Fields -def field(*args) -> XMLDictElement = 'field' |> xmln$ <*| args +def field(*args) -> XMLDictElement = xmln('field', *args) def field_name(name: Text) -> XMLDictElement = ({'name': 'name'}, [name]) |*> field def field_model(model: Text) -> XMLDictElement = ({'name': 'model'}, [model]) |*> field def field_inherit(xmlid: Text) -> XMLDictElement: @@ -80,7 +98,7 @@ def field_inherit(xmlid: Text) -> XMLDictElement: def field_arch(*args) -> XMLDictElement = {'name': 'arch', 'type': 'xml'} |> field$ <*| args # Search -def filter(*args) -> XMLDictElement = 'filter' |> xmln$ <*| args +def filter(*args) -> XMLDictElement = xmln('filter', *args) # Views def view(xmlid: Text, children: List) -> XMLDictElement: @@ -107,21 +125,3 @@ def view_inherit(filename: Text, model: Text, inherit: Text, arch: List) -> XMLD name = '%s Adaptations' % model_cap return view(xmlid, [name |> field_name, model |> field_model, inherit |> field_inherit, arch |> field_arch]) - -def action_server_code(xmlid: Text, name: Text, modelref: Text, code: Text) -> XMLDictElement: - """ Server actions of type code """ - children = [name |> field_name, - ({'name': 'model_id', 'ref': modelref}, []) |*> field, - ({'name': 'state'}, ['code']) |*> field, - ({'name': 'code'}, [code]) |*> field] - return ({'id': xmlid, 'model': 'ir.actions.server'}, children) |*> record - -def client_action_multi(xmlid: Text, name: Text, model: Text, action: Text) -> XMLDictElement: - """ Client action multi (ir.values), with own xmlid, name, targeted model - and action """ - action = action |> "'ir.actions.server,%d'%{}".format - children = [name |> field_name, - {'name': 'key2', 'eval': "'client_action_multi'"} |> field, - {'name': 'model', 'eval': "'%s'" % model} |> field, - {'name': 'value', 'eval': action} |> field] - return ({'id': xmlid, 'model': 'ir.values'}, children) |*> record diff --git a/yaltik_dsl/odoo_dsl.py b/yaltik_dsl/odoo_dsl.py index cdd5164..76dfec8 100644 --- a/yaltik_dsl/odoo_dsl.py +++ b/yaltik_dsl/odoo_dsl.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2 # -*- coding: utf-8 -*- -# __coconut_hash__ = 0x646b8885 +# __coconut_hash__ = 0x992b21a8 # Compiled with Coconut version 1.4.3 [Ernest Scribbler] @@ -69,21 +69,21 @@ def function(*args): return xmln('function', *args) def record(*args): # type: (...) -> XMLDictElement - return (_coconut_partial(xmln, {}, 1, *args))('record') + return xmln('record', *args) def form(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('form'))(*args) + return xmln('form', *args) def tree(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('tree'))(*args) + return xmln('tree', *args) def search(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('search'))(*args) + return xmln('search', *args) # Actions def act_window(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('act_window'))(*args) + return xmln('act_window', *args) def act_window_model(model, # type: Text attrs # type: XMLAttrs ): @@ -95,10 +95,32 @@ def act_window_model(model, # type: Text (attrs_clone.update)({'id': xmlid, 'name': name, 'res_model': model}) return act_window(attrs_clone) +def action_server_code(xmlid, # type: Text + name, # type: Text + modelref, # type: Text + code # type: Text + ): +# type: (...) -> XMLDictElement + """ Server actions of type code """ + children = [(field_name)(name), (field)(*({'name': 'model_id', 'ref': modelref}, [])), (field)(*({'name': 'state'}, ['code'])), (field)(*({'name': 'code'}, [code]))] + return (record)(*({'id': xmlid, 'model': 'ir.actions.server'}, children)) + +def client_action_multi(xmlid, # type: Text + name, # type: Text + model, # type: Text + action # type: Text + ): +# type: (...) -> XMLDictElement + """ Client action multi (ir.values), with own xmlid, name, targeted model + and action """ + action = ("'ir.actions.server,%d'%{}".format)(action) + children = [(field_name)(name), (field)({'name': 'key2', 'eval': "'client_action_multi'"}), (field)({'name': 'model', 'eval': "'%s'" % model}), (field)({'name': 'value', 'eval': action})] + return (record)(*({'id': xmlid, 'model': 'ir.values'}, children)) + # Menus def menuitem(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('menuitem'))(*args) + return xmln('menuitem', *args) def menuitem_model(model, # type: Text attrs # type: XMLAttrs ): @@ -114,25 +136,25 @@ def menuitem_model(model, # type: Text # Form aliases def group(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('group'))(*args) + return xmln('group', *args) def header(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('header'))(*args) + return xmln('header', *args) def footer(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('footer'))(*args) + return xmln('footer', *args) def sheet(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('sheet'))(*args) + return xmln('sheet', *args) def button(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('button'))(*args) + return xmln('button', *args) def p(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('p'))(*args) + return xmln('p', *args) def xpath(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('xpath'))(*args) + return xmln('xpath', *args) def attribute(name, # type: Text value # type: Text ): @@ -142,7 +164,7 @@ def attribute(name, # type: Text # Fields def field(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('field'))(*args) + return xmln('field', *args) def field_name(name # type: Text ): # type: (...) -> XMLDictElement @@ -162,7 +184,7 @@ def field_arch(*args): # Search def filter(*args): # type: (...) -> XMLDictElement - return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('filter'))(*args) + return xmln('filter', *args) # Views def view(xmlid, # type: Text @@ -205,25 +227,3 @@ def view_inherit(filename, # type: Text model_cap = ((' '.join)((list)(map(lambda _=None: _.capitalize(), (model.split)('.'))))) name = '%s Adaptations' % model_cap return view(xmlid, [(field_name)(name), (field_model)(model), (field_inherit)(inherit), (field_arch)(arch)]) - -def action_server_code(xmlid, # type: Text - name, # type: Text - modelref, # type: Text - code # type: Text - ): -# type: (...) -> XMLDictElement - """ Server actions of type code """ - children = [(field_name)(name), (field)(*({'name': 'model_id', 'ref': modelref}, [])), (field)(*({'name': 'state'}, ['code'])), (field)(*({'name': 'code'}, [code]))] - return (record)(*({'id': xmlid, 'model': 'ir.actions.server'}, children)) - -def client_action_multi(xmlid, # type: Text - name, # type: Text - model, # type: Text - action # type: Text - ): -# type: (...) -> XMLDictElement - """ Client action multi (ir.values), with own xmlid, name, targeted model - and action """ - action = ("'ir.actions.server,%d'%{}".format)(action) - children = [(field_name)(name), (field)({'name': 'key2', 'eval': "'client_action_multi'"}), (field)({'name': 'model', 'eval': "'%s'" % model}), (field)({'name': 'value', 'eval': action})] - return (record)(*({'id': xmlid, 'model': 'ir.values'}, children))