Store selection tree state

review822002
This commit is contained in:
Cédric Krier
2013-08-01 17:09:10 +02:00
parent 52a8141bda
commit adcf28d085
7 changed files with 57 additions and 40 deletions
+1
View File
@@ -1,3 +1,4 @@
* Store selection tree state
* Add order to Action Window
* Add factor on number fields
* Add calendar view
+1 -1
View File
@@ -41,7 +41,7 @@ def register():
View,
ShowViewStart,
ViewTreeWidth,
ViewTreeExpandedState,
ViewTreeState,
ViewSearch,
Icon,
Property,
+27 -13
View File
@@ -16,7 +16,7 @@ from trytond.rpc import RPC
__all__ = [
'View', 'ShowViewStart', 'ShowView',
'ViewTreeWidth', 'ViewTreeExpandedState', 'ViewSearch',
'ViewTreeWidth', 'ViewTreeState', 'ViewSearch',
]
@@ -290,9 +290,9 @@ class ViewTreeWidth(ModelSQL, ModelView):
cls.create(to_create)
class ViewTreeExpandedState(ModelSQL, ModelView):
'View Tree Expanded State'
__name__ = 'ir.ui.view_tree_expanded_state'
class ViewTreeState(ModelSQL, ModelView):
'View Tree State'
__name__ = 'ir.ui.view_tree_state'
_rec_name = 'model'
model = fields.Char('Model', required=True)
domain = fields.Char('Domain', required=True)
@@ -300,20 +300,27 @@ class ViewTreeExpandedState(ModelSQL, ModelView):
ondelete='CASCADE')
child_name = fields.Char('Child Name')
nodes = fields.Text('Expanded Nodes')
selected_nodes = fields.Text('Selected Nodes')
@classmethod
def __setup__(cls):
super(ViewTreeExpandedState, cls).__setup__()
super(ViewTreeState, cls).__setup__()
cls.__rpc__.update({
'set_expanded': RPC(readonly=False),
'get_expanded': RPC(),
'set': RPC(readonly=False),
'get': RPC(),
})
@classmethod
def __register__(cls, module_name):
super(ViewTreeExpandedState, cls).__register__(module_name)
cursor = Transaction().cursor
table = TableHandler(cursor, cls, module_name)
# Migration from 2.8: table name changed
table.table_rename(cursor, 'ir_ui_view_tree_expanded_state',
cls._table)
super(ViewTreeState, cls).__register__(module_name)
table = TableHandler(cursor, cls, module_name)
table.index_action(['model', 'domain', 'user', 'child_name'], 'add')
@@ -321,8 +328,12 @@ class ViewTreeExpandedState(ModelSQL, ModelView):
def default_nodes():
return '[]'
@staticmethod
def default_selected_nodes():
return '[]'
@classmethod
def set_expanded(cls, model, domain, child_name, nodes):
def set(cls, model, domain, child_name, nodes, selected_nodes):
current_user = Transaction().user
with Transaction().set_user(0):
records = cls.search([
@@ -338,10 +349,11 @@ class ViewTreeExpandedState(ModelSQL, ModelView):
'domain': domain,
'child_name': child_name,
'nodes': nodes,
'selected_nodes': selected_nodes,
}])
@classmethod
def get_expanded(cls, model, domain, child_name):
def get(cls, model, domain, child_name):
current_user = Transaction().user
with Transaction().set_user(0):
try:
@@ -353,8 +365,10 @@ class ViewTreeExpandedState(ModelSQL, ModelView):
],
limit=1)
except ValueError:
return '[]'
return cls(expanded_info).nodes
return (cls.default_nodes(), cls.default_selected_nodes())
state = cls(expanded_info)
return (state.nodes or cls.default_nodes(),
state.selected_nodes or cls.default_selected_nodes())
class ViewSearch(ModelSQL, ModelView):
+17 -17
View File
@@ -69,35 +69,35 @@ this repository contains the full copyright notices and license terms. -->
<menuitem parent="menu_ui"
action="act_view_tree_width_form" id="menu_view_tree_width"/>
<record model="ir.ui.view" id="view_tree_expanded_state_form">
<field name="model">ir.ui.view_tree_expanded_state</field>
<record model="ir.ui.view" id="view_tree_state_form">
<field name="model">ir.ui.view_tree_state</field>
<field name="type">form</field>
<field name="name">ui_view_tree_expanded_state_form</field>
<field name="name">ui_view_tree_state_form</field>
</record>
<record model="ir.ui.view" id="view_tree_expanded_state_tree">
<field name="model">ir.ui.view_tree_expanded_state</field>
<record model="ir.ui.view" id="view_tree_state_tree">
<field name="model">ir.ui.view_tree_state</field>
<field name="type">tree</field>
<field name="name">ui_view_tree_expanded_state_list</field>
<field name="name">ui_view_tree_state_list</field>
</record>
<record model="ir.action.act_window" id="act_view_tree_expanded_state">
<field name="name">Tree Expanded State</field>
<record model="ir.action.act_window" id="act_view_tree_state">
<field name="name">Tree State</field>
<field name="type">ir.action.act_window</field>
<field name="res_model">ir.ui.view_tree_expanded_state</field>
<field name="res_model">ir.ui.view_tree_state</field>
</record>
<record model="ir.action.act_window.view"
id="act_view_tree_expanded_state_tree">
id="act_view_tree_state_tree">
<field name="sequence" eval="10"/>
<field name="view" ref="view_tree_expanded_state_tree"/>
<field name="act_window" ref="act_view_tree_expanded_state"/>
<field name="view" ref="view_tree_state_tree"/>
<field name="act_window" ref="act_view_tree_state"/>
</record>
<record model="ir.action.act_window.view"
id="act_view_tree_expanded_state_form">
id="act_view_tree_state_form">
<field name="sequence" eval="20"/>
<field name="view" ref="view_tree_expanded_state_form"/>
<field name="act_window" ref="act_view_tree_expanded_state"/>
<field name="view" ref="view_tree_state_form"/>
<field name="act_window" ref="act_view_tree_state"/>
</record>
<menuitem parent="menu_ui" action="act_view_tree_expanded_state"
id="menu_view_tree_expanded_state"/>
<menuitem parent="menu_ui" action="act_view_tree_state"
id="menu_view_tree_state"/>
<record model="ir.ui.view" id="view_search_form">
<field name="model">ir.ui.view_search</field>
@@ -1,15 +1,17 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form string="View Tree Expanded State">
<form string="View Tree State">
<label name="model"/>
<field name="model"/>
<label name="user"/>
<field name="user"/>
<label name="domain"/>
<field name="domain"/>
<label name="child_name" />
<field name="child_name" />
<separator name="nodes" colspan="4" />
<label name="child_name"/>
<field name="child_name"/>
<separator name="nodes" colspan="4"/>
<field name="nodes" colspan="4"/>
<separator name="selected_nodes" colspan="4"/>
<field name="selected_nodes" colspan="4"/>
</form>
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree string="Views Tree Expanded State">
<tree string="Views Tree State">
<field name="model"/>
<field name="domain"/>
<field name="user"/>
+4 -4
View File
@@ -795,15 +795,15 @@ this repository contains the full copyright notices and license terms. -->
<field name="function">trigger_time</field>
</record>
<record model="ir.model.access" id="rule_default_view_tree_expanded_state">
<field name="model" search="[('model', '=', 'ir.ui.view_tree_expanded_state')]" />
<record model="ir.model.access" id="rule_default_view_tree_state">
<field name="model" search="[('model', '=', 'ir.ui.view_tree_state')]" />
<field name="perm_read" eval="False" />
<field name="perm_write" eval="False" />
<field name="perm_create" eval="False" />
<field name="perm_delete" eval="False" />
</record>
<record model="ir.model.access" id="rule_group_view_tree_expanded_state">
<field name="model" search="[('model', '=', 'ir.ui.view_tree_expanded_state')]" />
<record model="ir.model.access" id="rule_group_view_tree_state">
<field name="model" search="[('model', '=', 'ir.ui.view_tree_state')]" />
<field name="group" ref="res.group_admin" />
<field name="perm_read" eval="True" />
<field name="perm_write" eval="True" />