[IMP]Yaltik DSL v16 : act_window deprecated

This commit is contained in:
Fabien BOURGEOIS 2023-06-13 18:43:17 +02:00
parent e678fac46e
commit f6982b7d16
2 changed files with 13 additions and 4 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': '16.0.0.5.5',
'version': '16.0.0.5.6',
'category': 'Yaltik',
'author': 'Fabien Bourgeois',
'license': 'AGPL-3',

View File

@ -39,14 +39,23 @@ tree = lambda *args: xmln('tree', *args)
search = lambda *args: xmln('search', *args)
# Actions
act_window = lambda *args: xmln('act_window', *args)
def act_window_model(model, attrs):
""" Build new act_window from model and args """
xmlid = '%s_view_action' % (model.replace('.', '_'))
name = '%s Action' % ' '.join(map(lambda w: w.capitalize(), model.split('.')))
attrs_clone = attrs.copy() # Avoid side-effect
attrs_clone.update({'id': xmlid, 'name': name, 'res_model': model})
return act_window(attrs_clone)
attrs_clone.update(
{'name': name, 'res_model': model, 'type': 'ir.actions.act_window'}
)
children = []
for key, val in attrs_clone.items():
if key.endswith('_id'):
children.append(field({'name': key, 'ref': val}))
elif key == 'sequence':
children.append(field({'name': key, 'eval': val}))
else:
children.append(field({'name': key}, [val]))
return record({'id': xmlid, 'model': 'ir.actions.act_window'}, children)
def action_server_code(xmlid, name, modelref, code):
""" Server actions of type code """