From e5446dde374ebc5063dcc35a8df4e971ab4d3d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 26 Sep 2012 19:38:20 +0200 Subject: [PATCH] Allow to use XML file for views issue70 --- CHANGELOG | 1 + MANIFEST.in | 3 + doc/topics/views/index.rst | 20 +- setup.py | 6 +- trytond/backend/mysql/init.sql | 2 +- trytond/backend/postgresql/init.sql | 2 +- trytond/backend/sqlite/init.sql | 2 +- trytond/ir/action.xml | 271 +----------------- trytond/ir/attachment.xml | 45 +-- trytond/ir/cron.xml | 48 +--- trytond/ir/export.xml | 21 +- trytond/ir/lang.xml | 39 +-- trytond/ir/model.xml | 163 +---------- trytond/ir/module/module.xml | 122 +------- trytond/ir/property.xml | 23 +- trytond/ir/rule.xml | 68 +---- trytond/ir/sequence.xml | 84 +----- trytond/ir/translation.xml | 109 +------ trytond/ir/trigger.xml | 47 +-- trytond/ir/ui/icon.xml | 26 +- trytond/ir/ui/menu.xml | 38 +-- trytond/ir/ui/view.py | 45 ++- trytond/ir/ui/view.xml | 124 +------- trytond/ir/view/action_act_window_form.xml | 39 +++ trytond/ir/view/action_act_window_list.xml | 8 + .../ir/view/action_act_window_view_form.xml | 11 + .../ir/view/action_act_window_view_list.xml | 8 + .../ir/view/action_act_window_view_list2.xml | 7 + trytond/ir/view/action_form.xml | 23 ++ trytond/ir/view/action_keyword_form.xml | 12 + trytond/ir/view/action_keyword_list.xml | 8 + trytond/ir/view/action_list.xml | 7 + trytond/ir/view/action_report_form.xml | 40 +++ trytond/ir/view/action_report_list.xml | 10 + trytond/ir/view/action_url_form.xml | 23 ++ trytond/ir/view/action_url_list.xml | 8 + trytond/ir/view/action_wizard_form.xml | 30 ++ trytond/ir/view/action_wizard_list.xml | 8 + trytond/ir/view/attachment_form.xml | 30 ++ trytond/ir/view/attachment_list.xml | 11 + trytond/ir/view/cron_form.xml | 31 ++ trytond/ir/view/cron_list.xml | 13 + trytond/ir/view/export_form.xml | 10 + trytond/ir/view/export_list.xml | 7 + trytond/ir/view/icon_view_form.xml | 13 + trytond/ir/view/icon_view_list.xml | 9 + trytond/ir/view/lang_form.xml | 25 ++ trytond/ir/view/lang_list.xml | 10 + trytond/ir/view/model_access_form.xml | 20 ++ trytond/ir/view/model_access_list.xml | 11 + trytond/ir/view/model_button_form.xml | 10 + trytond/ir/view/model_button_list.xml | 7 + trytond/ir/view/model_field_access_form.xml | 20 ++ trytond/ir/view/model_field_access_list.xml | 11 + trytond/ir/view/model_field_form.xml | 19 ++ trytond/ir/view/model_field_list.xml | 11 + trytond/ir/view/model_form.xml | 14 + trytond/ir/view/model_list.xml | 9 + .../model_print_model_graph_start_form.xml | 9 + .../view/module_config_wizard_first_form.xml | 10 + .../view/module_config_wizard_item_list.xml | 8 + .../view/module_config_wizard_other_form.xml | 8 + trytond/ir/view/module_dependency_form.xml | 12 + trytond/ir/view/module_dependency_list.xml | 8 + trytond/ir/view/module_form.xml | 20 ++ .../view/module_install_upgrade_done_form.xml | 9 + .../module_install_upgrade_start_form.xml | 16 ++ trytond/ir/view/module_list.xml | 13 + trytond/ir/view/property_form.xml | 11 + trytond/ir/view/property_list.xml | 8 + trytond/ir/view/rule_form.xml | 11 + trytond/ir/view/rule_group_form.xml | 28 ++ trytond/ir/view/rule_group_list.xml | 13 + trytond/ir/view/rule_list.xml | 8 + trytond/ir/view/sequence_form.xml | 43 +++ trytond/ir/view/sequence_list.xml | 9 + trytond/ir/view/sequence_type_form.xml | 9 + trytond/ir/view/sequence_type_list.xml | 7 + .../ir/view/translation_clean_start_form.xml | 8 + .../view/translation_clean_succeed_form.xml | 8 + .../view/translation_export_result_form.xml | 7 + .../ir/view/translation_export_start_form.xml | 9 + trytond/ir/view/translation_form.xml | 23 ++ trytond/ir/view/translation_list.xml | 13 + .../translation_set_report_start_form.xml | 8 + .../translation_set_report_succeed_form.xml | 8 + .../ir/view/translation_update_start_form.xml | 7 + trytond/ir/view/trigger_form.xml | 31 ++ trytond/ir/view/trigger_list.xml | 12 + trytond/ir/view/ui_menu_form.xml | 20 ++ trytond/ir/view/ui_menu_list.xml | 6 + trytond/ir/view/ui_menu_tree.xml | 6 + trytond/ir/view/ui_view_form.xml | 24 ++ trytond/ir/view/ui_view_list.xml | 11 + trytond/ir/view/ui_view_sc_board.xml | 6 + trytond/ir/view/ui_view_sc_form.xml | 15 + trytond/ir/view/ui_view_sc_list.xml | 8 + .../view/ui_view_tree_expanded_state_form.xml | 15 + .../view/ui_view_tree_expanded_state_list.xml | 9 + trytond/ir/view/ui_view_tree_width_form.xml | 13 + trytond/ir/view/ui_view_tree_width_list.xml | 9 + trytond/model/modelview.py | 83 +++--- trytond/monitor.py | 14 + trytond/res/group.xml | 28 +- trytond/res/ir.xml | 12 +- trytond/res/request.xml | 137 +-------- trytond/res/user.xml | 122 +------- trytond/res/view/group_form.xml | 18 ++ trytond/res/view/group_list.xml | 6 + trytond/res/view/request_form.xml | 40 +++ trytond/res/view/request_history_form.xml | 21 ++ trytond/res/view/request_history_list.xml | 11 + trytond/res/view/request_link_form.xml | 11 + trytond/res/view/request_link_list.xml | 7 + trytond/res/view/request_list.xml | 15 + trytond/res/view/request_reference_form.xml | 9 + trytond/res/view/request_reference_list.xml | 7 + trytond/res/view/sequence_type_form.xml | 10 + trytond/res/view/user_config_start_form.xml | 14 + trytond/res/view/user_form.xml | 36 +++ trytond/res/view/user_form_preferences.xml | 31 ++ trytond/res/view/user_list.xml | 9 + trytond/res/view/user_warning_form.xml | 12 + trytond/res/view/user_warning_tree.xml | 8 + trytond/webdav/view/attachment_form.xml | 16 ++ trytond/webdav/view/collection_form.xml | 14 + trytond/webdav/view/collection_list.xml | 7 + trytond/webdav/view/collection_tree.xml | 9 + trytond/webdav/view/share_form.xml | 23 ++ trytond/webdav/view/share_list.xml | 8 + trytond/webdav/webdav.xml | 89 +----- 131 files changed, 1628 insertions(+), 1577 deletions(-) create mode 100644 trytond/ir/view/action_act_window_form.xml create mode 100644 trytond/ir/view/action_act_window_list.xml create mode 100644 trytond/ir/view/action_act_window_view_form.xml create mode 100644 trytond/ir/view/action_act_window_view_list.xml create mode 100644 trytond/ir/view/action_act_window_view_list2.xml create mode 100644 trytond/ir/view/action_form.xml create mode 100644 trytond/ir/view/action_keyword_form.xml create mode 100644 trytond/ir/view/action_keyword_list.xml create mode 100644 trytond/ir/view/action_list.xml create mode 100644 trytond/ir/view/action_report_form.xml create mode 100644 trytond/ir/view/action_report_list.xml create mode 100644 trytond/ir/view/action_url_form.xml create mode 100644 trytond/ir/view/action_url_list.xml create mode 100644 trytond/ir/view/action_wizard_form.xml create mode 100644 trytond/ir/view/action_wizard_list.xml create mode 100644 trytond/ir/view/attachment_form.xml create mode 100644 trytond/ir/view/attachment_list.xml create mode 100644 trytond/ir/view/cron_form.xml create mode 100644 trytond/ir/view/cron_list.xml create mode 100644 trytond/ir/view/export_form.xml create mode 100644 trytond/ir/view/export_list.xml create mode 100644 trytond/ir/view/icon_view_form.xml create mode 100644 trytond/ir/view/icon_view_list.xml create mode 100644 trytond/ir/view/lang_form.xml create mode 100644 trytond/ir/view/lang_list.xml create mode 100644 trytond/ir/view/model_access_form.xml create mode 100644 trytond/ir/view/model_access_list.xml create mode 100644 trytond/ir/view/model_button_form.xml create mode 100644 trytond/ir/view/model_button_list.xml create mode 100644 trytond/ir/view/model_field_access_form.xml create mode 100644 trytond/ir/view/model_field_access_list.xml create mode 100644 trytond/ir/view/model_field_form.xml create mode 100644 trytond/ir/view/model_field_list.xml create mode 100644 trytond/ir/view/model_form.xml create mode 100644 trytond/ir/view/model_list.xml create mode 100644 trytond/ir/view/model_print_model_graph_start_form.xml create mode 100644 trytond/ir/view/module_config_wizard_first_form.xml create mode 100644 trytond/ir/view/module_config_wizard_item_list.xml create mode 100644 trytond/ir/view/module_config_wizard_other_form.xml create mode 100644 trytond/ir/view/module_dependency_form.xml create mode 100644 trytond/ir/view/module_dependency_list.xml create mode 100644 trytond/ir/view/module_form.xml create mode 100644 trytond/ir/view/module_install_upgrade_done_form.xml create mode 100644 trytond/ir/view/module_install_upgrade_start_form.xml create mode 100644 trytond/ir/view/module_list.xml create mode 100644 trytond/ir/view/property_form.xml create mode 100644 trytond/ir/view/property_list.xml create mode 100644 trytond/ir/view/rule_form.xml create mode 100644 trytond/ir/view/rule_group_form.xml create mode 100644 trytond/ir/view/rule_group_list.xml create mode 100644 trytond/ir/view/rule_list.xml create mode 100644 trytond/ir/view/sequence_form.xml create mode 100644 trytond/ir/view/sequence_list.xml create mode 100644 trytond/ir/view/sequence_type_form.xml create mode 100644 trytond/ir/view/sequence_type_list.xml create mode 100644 trytond/ir/view/translation_clean_start_form.xml create mode 100644 trytond/ir/view/translation_clean_succeed_form.xml create mode 100644 trytond/ir/view/translation_export_result_form.xml create mode 100644 trytond/ir/view/translation_export_start_form.xml create mode 100644 trytond/ir/view/translation_form.xml create mode 100644 trytond/ir/view/translation_list.xml create mode 100644 trytond/ir/view/translation_set_report_start_form.xml create mode 100644 trytond/ir/view/translation_set_report_succeed_form.xml create mode 100644 trytond/ir/view/translation_update_start_form.xml create mode 100644 trytond/ir/view/trigger_form.xml create mode 100644 trytond/ir/view/trigger_list.xml create mode 100644 trytond/ir/view/ui_menu_form.xml create mode 100644 trytond/ir/view/ui_menu_list.xml create mode 100644 trytond/ir/view/ui_menu_tree.xml create mode 100644 trytond/ir/view/ui_view_form.xml create mode 100644 trytond/ir/view/ui_view_list.xml create mode 100644 trytond/ir/view/ui_view_sc_board.xml create mode 100644 trytond/ir/view/ui_view_sc_form.xml create mode 100644 trytond/ir/view/ui_view_sc_list.xml create mode 100644 trytond/ir/view/ui_view_tree_expanded_state_form.xml create mode 100644 trytond/ir/view/ui_view_tree_expanded_state_list.xml create mode 100644 trytond/ir/view/ui_view_tree_width_form.xml create mode 100644 trytond/ir/view/ui_view_tree_width_list.xml create mode 100644 trytond/res/view/group_form.xml create mode 100644 trytond/res/view/group_list.xml create mode 100644 trytond/res/view/request_form.xml create mode 100644 trytond/res/view/request_history_form.xml create mode 100644 trytond/res/view/request_history_list.xml create mode 100644 trytond/res/view/request_link_form.xml create mode 100644 trytond/res/view/request_link_list.xml create mode 100644 trytond/res/view/request_list.xml create mode 100644 trytond/res/view/request_reference_form.xml create mode 100644 trytond/res/view/request_reference_list.xml create mode 100644 trytond/res/view/sequence_type_form.xml create mode 100644 trytond/res/view/user_config_start_form.xml create mode 100644 trytond/res/view/user_form.xml create mode 100644 trytond/res/view/user_form_preferences.xml create mode 100644 trytond/res/view/user_list.xml create mode 100644 trytond/res/view/user_warning_form.xml create mode 100644 trytond/res/view/user_warning_tree.xml create mode 100644 trytond/webdav/view/attachment_form.xml create mode 100644 trytond/webdav/view/collection_form.xml create mode 100644 trytond/webdav/view/collection_list.xml create mode 100644 trytond/webdav/view/collection_tree.xml create mode 100644 trytond/webdav/view/share_form.xml create mode 100644 trytond/webdav/view/share_list.xml diff --git a/CHANGELOG b/CHANGELOG index d0d6849f3d..4f884f08ff 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Allow to use XML file for views * Add RPC definition * Repace BrowseRecord by Model instance * Replace Cache decorator by a simple LRU Cache diff --git a/MANIFEST.in b/MANIFEST.in index 5dd29adf4f..cd0aa79aa3 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -12,6 +12,7 @@ include etc/* include trytond/backend/*/init.sql include trytond/ir/tryton.cfg include trytond/ir/*.xml +include trytond/ir/view/*.xml include trytond/ir/locale/*.po include trytond/ir/module/*.xml include trytond/ir/ui/*.xml @@ -20,9 +21,11 @@ include trytond/ir/ui/*.rnc include trytond/ir/ui/icons/*.svg include trytond/res/tryton.cfg include trytond/res/*.xml +include trytond/res/view/*.xml include trytond/res/locale/*.po include trytond/test/tryton.cfg include trytond/test/*.xml include trytond/webdav/tryton.cfg include trytond/webdav/*.xml +include trytond/webdav/view/*.xml include trytond/webdav/locale/*.po diff --git a/doc/topics/views/index.rst b/doc/topics/views/index.rst index 5c6e663a0f..f0b773ef40 100644 --- a/doc/topics/views/index.rst +++ b/doc/topics/views/index.rst @@ -4,15 +4,17 @@ Views ===== -The views are used to display records of an object to the user. +The views are used to display records of an :class:`ModelView +` to the user. -In Tryton, objects can have several views. An `action` opens a window and -defines which view to show. +In Tryton, :class:`ModelView ` can have several views. +An `action` opens a window and defines which view to show. -The views are built from XML that is stored in the databases with the object -ir.ui.view. +The views are built from XML that is stored in the `view` directory of the +module or in the databases thanks to the model ir.ui.view. -So generally, they are defined in xml files with this kind of xml: +So generally, they are defined in xml files with this kind of xml where name is +the name of the XML file in the `view` directory: .. highlight:: xml @@ -23,11 +25,7 @@ So generally, they are defined in xml files with this kind of xml: type name - - - + view_name diff --git a/setup.py b/setup.py index f3088e0d65..6384c05576 100644 --- a/setup.py +++ b/setup.py @@ -26,11 +26,11 @@ setup(name=PACKAGE, 'trytond.backend.mysql': ['init.sql'], 'trytond.backend.postgresql': ['init.sql'], 'trytond.backend.sqlite': ['init.sql'], - 'trytond.ir': ['tryton.cfg', '*.xml', 'locale/*.po'], + 'trytond.ir': ['tryton.cfg', '*.xml', 'view/*.xml', 'locale/*.po'], 'trytond.ir.module': ['*.xml'], 'trytond.ir.ui': ['*.xml', '*.rng', '*.rnc'], - 'trytond.res': ['tryton.cfg', '*.xml', 'locale/*.po'], - 'trytond.webdav': ['tryton.cfg', '*.xml', 'locale/*.po'], + 'trytond.res': ['tryton.cfg', '*.xml', 'view/*.xml', 'locale/*.po'], + 'trytond.webdav': ['tryton.cfg', '*.xml', 'view/*.xml', 'locale/*.po'], 'trytond.test': ['tryton.cfg', '*.xml'], }, scripts=['bin/trytond'], diff --git a/trytond/backend/mysql/init.sql b/trytond/backend/mysql/init.sql index fb274089df..797b6a80c1 100644 --- a/trytond/backend/mysql/init.sql +++ b/trytond/backend/mysql/init.sql @@ -24,7 +24,7 @@ CREATE TABLE ir_ui_view ( id BIGINT AUTO_INCREMENT NOT NULL, model VARCHAR(255) NOT NULL, type VARCHAR(255), - arch TEXT NOT NULL, + data TEXT NOT NULL, field_childs VARCHAR(255), priority BIGINT NOT NULL default 0, PRIMARY KEY(id) diff --git a/trytond/backend/postgresql/init.sql b/trytond/backend/postgresql/init.sql index 407b1cc841..a82b3f201a 100644 --- a/trytond/backend/postgresql/init.sql +++ b/trytond/backend/postgresql/init.sql @@ -30,7 +30,7 @@ CREATE TABLE ir_ui_view ( id INTEGER DEFAULT NEXTVAL('ir_ui_view_id_seq') NOT NULL, model VARCHAR NOT NULL, "type" VARCHAR, - arch TEXT NOT NULL, + data TEXT NOT NULL, field_childs VARCHAR, priority INTEGER NOT NULL, PRIMARY KEY(id) diff --git a/trytond/backend/sqlite/init.sql b/trytond/backend/sqlite/init.sql index 055e4f8ce2..52f6239520 100644 --- a/trytond/backend/sqlite/init.sql +++ b/trytond/backend/sqlite/init.sql @@ -22,7 +22,7 @@ CREATE TABLE ir_ui_view ( id INTEGER PRIMARY KEY AUTOINCREMENT, model VARCHAR, "type" VARCHAR, - arch TEXT, + data TEXT, field_childs VARCHAR, priority INTEGER ); diff --git a/trytond/ir/action.xml b/trytond/ir/action.xml index 5e4fc84a33..ff78767535 100644 --- a/trytond/ir/action.xml +++ b/trytond/ir/action.xml @@ -7,42 +7,12 @@ this repository contains the full copyright notices and license terms. --> ir.action form - - - ir.action tree - - - - - - ]]> - + action_list Actions @@ -67,93 +37,24 @@ this repository contains the full copyright notices and license terms. --> ir.action.keyword tree - - - - - - - ]]> - + action_keyword_list ir.action.keyword form - - - ir.action.report form - - - ir.action.report tree - - - - - - - - ]]> - + action_report_list Reports @@ -178,59 +79,12 @@ this repository contains the full copyright notices and license terms. --> ir.action.act_window form - - - ir.action.act_window tree - - - - - - - ]]> - + action_act_window_list Window Actions @@ -253,96 +107,32 @@ this repository contains the full copyright notices and license terms. --> ir.action.act_window.view form - - - ir.action.act_window.view tree - - - - - - - ]]> - + action_act_window_view_list ir.action.act_window.view tree - - - - - - ]]> - + action_act_window_view_list2 ir.action.wizard form - - - ir.action.wizard tree - - - - - - - ]]> - + action_wizard_list Wizards @@ -367,43 +157,12 @@ this repository contains the full copyright notices and license terms. --> ir.action.url form - - - ir.action.url tree - - - - - - - ]]> - + action_url_list URLs diff --git a/trytond/ir/attachment.xml b/trytond/ir/attachment.xml index 6899042aec..789d26dc34 100644 --- a/trytond/ir/attachment.xml +++ b/trytond/ir/attachment.xml @@ -6,53 +6,12 @@ this repository contains the full copyright notices and license terms. --> ir.attachment form - - - - - - - - - - - - - - ]]> - + attachment_form ir.attachment tree - - - - - - - - - - ]]> - + attachment_list Attachments diff --git a/trytond/ir/cron.xml b/trytond/ir/cron.xml index 4faa070458..cc1ca464f5 100644 --- a/trytond/ir/cron.xml +++ b/trytond/ir/cron.xml @@ -9,56 +9,12 @@ this repository contains the full copyright notices and license terms. --> ir.cron tree - - - - - - - - - - - - ]]> - + cron_list ir.cron form - - - Scheduled Actions diff --git a/trytond/ir/export.xml b/trytond/ir/export.xml index 857dbe627c..01f5b05792 100644 --- a/trytond/ir/export.xml +++ b/trytond/ir/export.xml @@ -6,29 +6,12 @@ this repository contains the full copyright notices and license terms. --> ir.export form - - - ir.export tree - - - - - - ]]> - + export_list Exports diff --git a/trytond/ir/lang.xml b/trytond/ir/lang.xml index 60bf7adefa..d361827651 100644 --- a/trytond/ir/lang.xml +++ b/trytond/ir/lang.xml @@ -92,47 +92,12 @@ this repository contains the full copyright notices and license terms. --> ir.lang tree - - - - - - - - - ]]> - + lang_list ir.lang form - - - Languages diff --git a/trytond/ir/model.xml b/trytond/ir/model.xml index ae170d68c7..d2806ac542 100644 --- a/trytond/ir/model.xml +++ b/trytond/ir/model.xml @@ -7,35 +7,12 @@ this repository contains the full copyright notices and license terms. --> ir.model form - - - ir.model tree - - - - - - - - ]]> - + model_list Models @@ -58,42 +35,12 @@ this repository contains the full copyright notices and license terms. --> ir.model.field form - - - ir.model.field tree - - - - - - - - - - ]]> - + model_field_list Fields @@ -116,43 +63,12 @@ this repository contains the full copyright notices and license terms. --> ir.model.access tree - - - - - - - - - - ]]> - + model_access_list ir.model.access form - - - Models Access @@ -176,44 +92,13 @@ this repository contains the full copyright notices and license terms. --> ir.model.field.access tree - - - - - - - - - - ]]> - + model_field_access_list ir.model.field.access form - - - @@ -244,16 +129,7 @@ this repository contains the full copyright notices and license terms. --> ir.model.print_model_graph.start form - - - @@ -270,29 +146,12 @@ this repository contains the full copyright notices and license terms. --> ir.model.button tree - - - - - - ]]> - + model_button_list ir.model.button form - - - diff --git a/trytond/ir/module/module.xml b/trytond/ir/module/module.xml index 79ad2644df..e93f3042fa 100644 --- a/trytond/ir/module/module.xml +++ b/trytond/ir/module/module.xml @@ -7,45 +7,12 @@ this repository contains the full copyright notices and license terms. --> ir.module.module form - - -