Manage order on Action Window
review951002
This commit is contained in:
1 parent
90ba280877
commit
039cf47ea1
6 files changed
+19
-33
No files matched your search
+9
-21
@@ -100,29 +100,17 @@ class Action(object):
|
||||
'active_ids': data.get('ids', []),
|
||||
}
|
||||
ctx.update(rpc.CONTEXT)
|
||||
eval_ctx = ctx.copy()
|
||||
eval_ctx['_user'] = rpc._USER
|
||||
action_ctx = PYSONDecoder(eval_ctx).decode(
|
||||
action.get('pyson_context') or '{}')
|
||||
ctx['_user'] = rpc._USER
|
||||
decoder = PYSONDecoder(ctx)
|
||||
action_ctx = decoder.decode(action.get('pyson_context') or '{}')
|
||||
ctx.update(action_ctx)
|
||||
ctx.update(context)
|
||||
|
||||
domain_context = ctx.copy()
|
||||
domain_context['context'] = ctx
|
||||
domain_context['_user'] = rpc._USER
|
||||
domain = PYSONDecoder(domain_context).decode(
|
||||
action['pyson_domain'])
|
||||
|
||||
search_context = ctx.copy()
|
||||
search_context['context'] = ctx
|
||||
search_context['_user'] = rpc._USER
|
||||
search_value = PYSONDecoder(search_context).decode(
|
||||
action['pyson_search_value'] or '[]')
|
||||
|
||||
tab_domain_context = ctx.copy()
|
||||
tab_domain_context['context'] = ctx
|
||||
tab_domain_context['_user'] = rpc._USER
|
||||
decoder = PYSONDecoder(tab_domain_context)
|
||||
ctx['context'] = ctx
|
||||
decoder = PYSONDecoder(ctx)
|
||||
domain = decoder.decode(action['pyson_domain'])
|
||||
order = decoder.decode(action['pyson_order'])
|
||||
search_value = decoder.decode(action['pyson_search_value'] or '[]')
|
||||
tab_domain = [(n, decoder.decode(d)) for n, d in action['domains']]
|
||||
|
||||
name = False
|
||||
@@ -133,7 +121,7 @@ class Action(object):
|
||||
res_id = action.get('res_id', data.get('res_id'))
|
||||
|
||||
Window.create(view_ids, res_model, res_id, domain,
|
||||
action_ctx, view_mode, name=name,
|
||||
action_ctx, order, view_mode, name=name,
|
||||
limit=action.get('limit'),
|
||||
auto_refresh=action.get('auto_refresh'),
|
||||
search_value=search_value,
|
||||
|
||||
@@ -85,7 +85,7 @@ class Form(SignalEvent, TabContent):
|
||||
'<tryton>/Form/Import Data'),
|
||||
]
|
||||
|
||||
def __init__(self, model, res_id=False, domain=None, mode=None,
|
||||
def __init__(self, model, res_id=False, domain=None, order=None, mode=None,
|
||||
view_ids=None, context=None, name=False, limit=None,
|
||||
auto_refresh=False, search_value=None, tab_domain=None):
|
||||
super(Form, self).__init__()
|
||||
@@ -109,7 +109,7 @@ class Form(SignalEvent, TabContent):
|
||||
self.dialogs = []
|
||||
|
||||
self.screen = Screen(self.model, mode=mode, context=self.context,
|
||||
view_ids=view_ids, domain=domain, limit=limit,
|
||||
view_ids=view_ids, domain=domain, limit=limit, order=order,
|
||||
readonly=bool(auto_refresh), search_value=search_value,
|
||||
tab_domain=tab_domain)
|
||||
self.screen.widget.show()
|
||||
|
||||
@@ -40,7 +40,7 @@ class Screen(SignalEvent):
|
||||
|
||||
def __init__(self, model_name, view_ids=None, mode=None, context=None,
|
||||
views_preload=None, domain=None, row_activate=None, limit=None,
|
||||
readonly=False, exclude_field=None, sort=None, search_value=None,
|
||||
readonly=False, exclude_field=None, order=None, search_value=None,
|
||||
tab_domain=None, alternate_view=False):
|
||||
if view_ids is None:
|
||||
view_ids = []
|
||||
@@ -86,7 +86,7 @@ class Screen(SignalEvent):
|
||||
self.__current_view = 0
|
||||
self.search_value = search_value
|
||||
self.fields_view_tree = None
|
||||
self.sort = sort
|
||||
self.order = order
|
||||
self.view_to_load = []
|
||||
self.expanded_nodes = collections.defaultdict(
|
||||
lambda: collections.defaultdict(lambda: None))
|
||||
@@ -199,7 +199,7 @@ class Screen(SignalEvent):
|
||||
|
||||
try:
|
||||
ids = RPCExecute('model', self.model_name, 'search', domain,
|
||||
self.offset, self.limit, self.sort, context=self.context)
|
||||
self.offset, self.limit, self.order, context=self.context)
|
||||
except RPCException:
|
||||
ids = []
|
||||
if not only_ids:
|
||||
|
||||
@@ -42,8 +42,6 @@ class AdaptModelGroup(gtk.GenericTreeModel):
|
||||
def __init__(self, group, children_field=None):
|
||||
super(AdaptModelGroup, self).__init__()
|
||||
self.group = group
|
||||
self.last_sort = None
|
||||
self.sort_asc = True
|
||||
self.set_property('leak_references', False)
|
||||
self.children_field = children_field
|
||||
self.__removed = None # XXX dirty hack to allow update of has_child
|
||||
|
||||
@@ -52,16 +52,16 @@ def sort_model(column, treeview, screen):
|
||||
if col != column:
|
||||
col.arrow_show = False
|
||||
col.arrow.hide()
|
||||
screen.sort = None
|
||||
screen.order = None
|
||||
if not column.arrow_show:
|
||||
column.arrow_show = True
|
||||
column.arrow.set(gtk.ARROW_DOWN, gtk.SHADOW_IN)
|
||||
column.arrow.show()
|
||||
screen.sort = [(column.name, 'ASC')]
|
||||
screen.order = [(column.name, 'ASC')]
|
||||
else:
|
||||
if column.arrow.get_property('arrow-type') == gtk.ARROW_DOWN:
|
||||
column.arrow.set(gtk.ARROW_UP, gtk.SHADOW_IN)
|
||||
screen.sort = [(column.name, 'DESC')]
|
||||
screen.order = [(column.name, 'DESC')]
|
||||
else:
|
||||
column.arrow_show = False
|
||||
column.arrow.hide()
|
||||
|
||||
@@ -20,7 +20,7 @@ class Window(object):
|
||||
|
||||
@staticmethod
|
||||
def create(view_ids, model, res_id=False, domain=None,
|
||||
context=None, mode=None, name=False, limit=None,
|
||||
context=None, order=None, mode=None, name=False, limit=None,
|
||||
auto_refresh=False, search_value=None, icon=None, tab_domain=None):
|
||||
from tryton.gui import Main
|
||||
if context is None:
|
||||
@@ -28,7 +28,7 @@ class Window(object):
|
||||
|
||||
if model:
|
||||
from form import Form
|
||||
win = Form(model, res_id, domain, mode=mode,
|
||||
win = Form(model, res_id, domain, order=order, mode=mode,
|
||||
view_ids=(view_ids or []), context=context, name=name,
|
||||
limit=limit, auto_refresh=auto_refresh,
|
||||
search_value=search_value, tab_domain=tab_domain)
|
||||
|
||||
Reference in new issue
Block a user