[REF][UPD]Yaltik DSL : migration to coco finished
This commit is contained in:
parent
c0c1427fce
commit
8859a4b340
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2019 Fabien Bourgeois <fabien@yaltik.com>
|
# Copyright 2019-2020 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# 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
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from . import odoo
|
from . import odoo_dsl
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# __coconut_hash__ = 0xe22b9d74
|
# __coconut_hash__ = 0x4a7a90c3
|
||||||
|
|
||||||
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
# 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 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2019 Fabien Bourgeois <fabien@yaltik.com>
|
# Copyright 2019-2020 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# 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
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from . import odoo
|
from . import odoo_dsl
|
||||||
|
@ -19,11 +19,12 @@
|
|||||||
'name': 'Yaltik Odoo DSL base module and fns',
|
'name': 'Yaltik Odoo DSL base module and fns',
|
||||||
'summary': 'Yaltik Odoo Domain Specific Language base module and functions',
|
'summary': 'Yaltik Odoo Domain Specific Language base module and functions',
|
||||||
'description': """ 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',
|
'category': 'Yaltik',
|
||||||
'author': 'Fabien Bourgeois',
|
'author': 'Fabien Bourgeois',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'application': False,
|
'application': False,
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'depends': ['base']
|
'depends': ['base'],
|
||||||
|
"external_dependencies": {'python' : ['typing']}
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,13 @@ def data(*args):
|
|||||||
|
|
||||||
# Aliases
|
# Aliases
|
||||||
def function(*args) -> XMLDictElement = xmln('function', *args)
|
def function(*args) -> XMLDictElement = xmln('function', *args)
|
||||||
def record(*args) -> XMLDictElement = 'record' |> xmln$(?, *args)
|
def record(*args) -> XMLDictElement = xmln('record', *args)
|
||||||
def form(*args) -> XMLDictElement = 'form' |> xmln$ <*| args
|
def form(*args) -> XMLDictElement = xmln('form', *args)
|
||||||
def tree(*args) -> XMLDictElement = 'tree' |> xmln$ <*| args
|
def tree(*args) -> XMLDictElement = xmln('tree', *args)
|
||||||
def search(*args) -> XMLDictElement = 'search' |> xmln$ <*| args
|
def search(*args) -> XMLDictElement = xmln('search', *args)
|
||||||
|
|
||||||
# Actions
|
# 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:
|
def act_window_model(model: Text, attrs: XMLAttrs) -> XMLDictElement:
|
||||||
""" Build new act_window from model and args """
|
""" Build new act_window from model and args """
|
||||||
xmlid = '%s_view_action' % (('.', '_') |*> model.replace)
|
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
|
{'id': xmlid, 'name': name, 'res_model': model} |> attrs_clone.update
|
||||||
return act_window(attrs_clone)
|
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
|
# Menus
|
||||||
def menuitem(*args) -> XMLDictElement = 'menuitem' |> xmln$ <*| args
|
def menuitem(*args) -> XMLDictElement = xmln('menuitem', *args)
|
||||||
def menuitem_model(model: Text, attrs: XMLAttrs) -> XMLDictElement:
|
def menuitem_model(model: Text, attrs: XMLAttrs) -> XMLDictElement:
|
||||||
""" Build new menuitem from model and attrs """
|
""" Build new menuitem from model and attrs """
|
||||||
model_und = ('.', '_') |*> model.replace
|
model_und = ('.', '_') |*> model.replace
|
||||||
@ -61,18 +79,18 @@ def menuitem_model(model: Text, attrs: XMLAttrs) -> XMLDictElement:
|
|||||||
return menuitem(attrs_clone)
|
return menuitem(attrs_clone)
|
||||||
|
|
||||||
# Form aliases
|
# Form aliases
|
||||||
def group(*args) -> XMLDictElement = 'group' |> xmln$ <*| args
|
def group(*args) -> XMLDictElement = xmln('group', *args)
|
||||||
def header(*args) -> XMLDictElement = 'header' |> xmln$ <*| args
|
def header(*args) -> XMLDictElement = xmln('header', *args)
|
||||||
def footer(*args) -> XMLDictElement = 'footer' |> xmln$ <*| args
|
def footer(*args) -> XMLDictElement = xmln('footer', *args)
|
||||||
def sheet(*args) -> XMLDictElement = 'sheet' |> xmln$ <*| args
|
def sheet(*args) -> XMLDictElement = xmln('sheet', *args)
|
||||||
def button(*args) -> XMLDictElement = 'button' |> xmln$ <*| args
|
def button(*args) -> XMLDictElement = xmln('button', *args)
|
||||||
def p(*args) -> XMLDictElement = 'p' |> xmln$ <*| args
|
def p(*args) -> XMLDictElement = xmln('p', *args)
|
||||||
def xpath(*args) -> XMLDictElement = 'xpath' |> xmln$ <*| args
|
def xpath(*args) -> XMLDictElement = xmln('xpath', *args)
|
||||||
def attribute(name: Text, value: Text) -> XMLDictElement:
|
def attribute(name: Text, value: Text) -> XMLDictElement:
|
||||||
return ('attribute', {'name': name}, [value]) |*> xmln
|
return ('attribute', {'name': name}, [value]) |*> xmln
|
||||||
|
|
||||||
# Fields
|
# 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_name(name: Text) -> XMLDictElement = ({'name': 'name'}, [name]) |*> field
|
||||||
def field_model(model: Text) -> XMLDictElement = ({'name': 'model'}, [model]) |*> field
|
def field_model(model: Text) -> XMLDictElement = ({'name': 'model'}, [model]) |*> field
|
||||||
def field_inherit(xmlid: Text) -> XMLDictElement:
|
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
|
def field_arch(*args) -> XMLDictElement = {'name': 'arch', 'type': 'xml'} |> field$ <*| args
|
||||||
|
|
||||||
# Search
|
# Search
|
||||||
def filter(*args) -> XMLDictElement = 'filter' |> xmln$ <*| args
|
def filter(*args) -> XMLDictElement = xmln('filter', *args)
|
||||||
|
|
||||||
# Views
|
# Views
|
||||||
def view(xmlid: Text, children: List) -> XMLDictElement:
|
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
|
name = '%s Adaptations' % model_cap
|
||||||
return view(xmlid, [name |> field_name, model |> field_model,
|
return view(xmlid, [name |> field_name, model |> field_model,
|
||||||
inherit |> field_inherit, arch |> field_arch])
|
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
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# __coconut_hash__ = 0x646b8885
|
# __coconut_hash__ = 0x992b21a8
|
||||||
|
|
||||||
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
# Compiled with Coconut version 1.4.3 [Ernest Scribbler]
|
||||||
|
|
||||||
@ -69,21 +69,21 @@ def function(*args):
|
|||||||
return xmln('function', *args)
|
return xmln('function', *args)
|
||||||
def record(*args):
|
def record(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return (_coconut_partial(xmln, {}, 1, *args))('record')
|
return xmln('record', *args)
|
||||||
def form(*args):
|
def form(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('form'))(*args)
|
return xmln('form', *args)
|
||||||
def tree(*args):
|
def tree(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('tree'))(*args)
|
return xmln('tree', *args)
|
||||||
def search(*args):
|
def search(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('search'))(*args)
|
return xmln('search', *args)
|
||||||
|
|
||||||
# Actions
|
# Actions
|
||||||
def act_window(*args):
|
def act_window(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# 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
|
def act_window_model(model, # type: Text
|
||||||
attrs # type: XMLAttrs
|
attrs # type: XMLAttrs
|
||||||
):
|
):
|
||||||
@ -95,10 +95,32 @@ def act_window_model(model, # type: Text
|
|||||||
(attrs_clone.update)({'id': xmlid, 'name': name, 'res_model': model})
|
(attrs_clone.update)({'id': xmlid, 'name': name, 'res_model': model})
|
||||||
return act_window(attrs_clone)
|
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
|
# Menus
|
||||||
def menuitem(*args):
|
def menuitem(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('menuitem'))(*args)
|
return xmln('menuitem', *args)
|
||||||
def menuitem_model(model, # type: Text
|
def menuitem_model(model, # type: Text
|
||||||
attrs # type: XMLAttrs
|
attrs # type: XMLAttrs
|
||||||
):
|
):
|
||||||
@ -114,25 +136,25 @@ def menuitem_model(model, # type: Text
|
|||||||
# Form aliases
|
# Form aliases
|
||||||
def group(*args):
|
def group(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('group'))(*args)
|
return xmln('group', *args)
|
||||||
def header(*args):
|
def header(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('header'))(*args)
|
return xmln('header', *args)
|
||||||
def footer(*args):
|
def footer(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('footer'))(*args)
|
return xmln('footer', *args)
|
||||||
def sheet(*args):
|
def sheet(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('sheet'))(*args)
|
return xmln('sheet', *args)
|
||||||
def button(*args):
|
def button(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('button'))(*args)
|
return xmln('button', *args)
|
||||||
def p(*args):
|
def p(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('p'))(*args)
|
return xmln('p', *args)
|
||||||
def xpath(*args):
|
def xpath(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('xpath'))(*args)
|
return xmln('xpath', *args)
|
||||||
def attribute(name, # type: Text
|
def attribute(name, # type: Text
|
||||||
value # type: Text
|
value # type: Text
|
||||||
):
|
):
|
||||||
@ -142,7 +164,7 @@ def attribute(name, # type: Text
|
|||||||
# Fields
|
# Fields
|
||||||
def field(*args):
|
def field(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('field'))(*args)
|
return xmln('field', *args)
|
||||||
def field_name(name # type: Text
|
def field_name(name # type: Text
|
||||||
):
|
):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
@ -162,7 +184,7 @@ def field_arch(*args):
|
|||||||
# Search
|
# Search
|
||||||
def filter(*args):
|
def filter(*args):
|
||||||
# type: (...) -> XMLDictElement
|
# type: (...) -> XMLDictElement
|
||||||
return ((_coconut.functools.partial(_coconut.functools.partial, xmln))('filter'))(*args)
|
return xmln('filter', *args)
|
||||||
|
|
||||||
# Views
|
# Views
|
||||||
def view(xmlid, # type: Text
|
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)('.')))))
|
model_cap = ((' '.join)((list)(map(lambda _=None: _.capitalize(), (model.split)('.')))))
|
||||||
name = '%s Adaptations' % model_cap
|
name = '%s Adaptations' % model_cap
|
||||||
return view(xmlid, [(field_name)(name), (field_model)(model), (field_inherit)(inherit), (field_arch)(arch)])
|
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))
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user