Created
February 17, 2021 19:18
-
-
Save ray-odoo/f9f4fdba3b9e5bf3784eba6f503f79f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Available variables: | |
# - env: Odoo Environment on which the action is triggered | |
# - model: Odoo Model of the record on which the action is triggered; is a void recordset | |
# - record: record on which the action is triggered; may be void | |
# - records: recordset of all records on which the action is triggered in multi-mode; may be void | |
# - time, datetime, dateutil, timezone: useful Python libraries | |
# - log: log(message, level='info'): logging function to record debug information in ir.logging table | |
# - UserError: Warning Exception to use with raise | |
# To return an action, assign: action = {...} | |
env['ir.ui.view'].search([('name','=','Studio Scripted View - Customization Form View')]).unlink() | |
env['ir.model'].search([('model','=','x_custom.change')]).unlink() | |
env['ir.ui.menu'].search([('name','=','Custom')]).unlink() | |
env['ir.actions.act_window'].search([('res_model','=','x_custom.change')]).unlink() | |
custom_model_id = env['ir.model'].create({ | |
'name': 'Customizations', | |
'model': 'x_custom.change', | |
}) | |
custom_field_id = env['ir.model.fields'].create({ | |
'name': 'x_model', | |
'field_description': 'Model', | |
'model_id': custom_model_id.id, | |
'ttype': 'reference', | |
'copied': False, | |
}) | |
env['ir.model.access'].create({ | |
'name': 'x_custom.change', | |
'model_id': custom_model_id.id, | |
'group_id': env.ref('base.group_user').id, | |
'perm_read': True, | |
'perm_write': True, | |
'perm_create': True, | |
'perm_unlink': True, | |
}) | |
custom_action_id = env['ir.actions.act_window'].create({ | |
'name': 'Customizations', | |
'res_model': 'x_custom.change', | |
}) | |
custom_menu_id = env['ir.ui.menu'].create({ | |
'name': 'Custom', | |
'sequence': 499, | |
'web_icon': 'website_partner,static/description/icon.png', | |
'action': 'ir.actions.act_window,' + str(custom_action_id.id), | |
}) | |
custom_view_id = env['ir.ui.view'].create({ | |
'name': 'Studio Scripted View - Customization Form View', | |
'type': 'form', | |
'model': 'x_custom.change', | |
'arch_base': ''' | |
<form> | |
<sheet> | |
<group> | |
<field name="x_name"/> | |
<field name="x_model" required="1"/> | |
</group> | |
</sheet> | |
</form> | |
''' | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment