[IMP]Yaltik DSL : Odoo DSL avoid side effect on attributes

This commit is contained in:
Fabien BOURGEOIS 2020-05-01 00:07:01 +02:00
parent 170aa6a86e
commit 9d1ab3dc6c
1 changed files with 6 additions and 4 deletions

View File

@ -45,8 +45,9 @@ def act_window_model(model: Text, attrs: XMLAttrs) -> XMLDictElement:
""" Build new act_window from model and args """
xmlid = '%s_view_action' % (('.', '_') |*> model.replace)
name = '%s Action' % ('.' |> model.split |> map$(-> _.capitalize()) |> list |> ' '.join)
{'id': xmlid, 'name': name, 'res_model': model} |> attrs.update
return act_window(attrs)
attrs_clone = attrs.copy() # Avoid side-effect
{'id': xmlid, 'name': name, 'res_model': model} |> attrs_clone.update
return act_window(attrs_clone)
# Menus
def menuitem(*args) -> XMLDictElement = 'menuitem' |> xmln$ <*| args
@ -55,8 +56,9 @@ def menuitem_model(model: Text, attrs: XMLAttrs) -> XMLDictElement:
model_und = ('.', '_') |*> model.replace
xmlid = '%s_menu' % model_und
actionid = '%s_view_action' % model_und
{'id': xmlid, 'action': actionid} |> attrs.update
return menuitem(attrs)
attrs_clone = attrs.copy() # Avoid side-effect
{'id': xmlid, 'action': actionid} |> attrs_clone.update
return menuitem(attrs_clone)
# Form aliases
def group(*args) -> XMLDictElement = 'group' |> xmln$ <*| args