Manage context model of ir.action.act_window
issue5220 review20631002
This commit is contained in:
1 parent
42247bab4e
commit
8936e5133c
6 files changed
+59
-7
No files matched your search
@@ -1,3 +1,4 @@
|
||||
* Manage context model of ir.action.act_window
|
||||
* Add Note
|
||||
* Manage view_ids on tree view
|
||||
* Use Apple key for copy/past of list
|
||||
|
||||
@@ -139,7 +139,8 @@ class Action(object):
|
||||
limit=action.get('limit'),
|
||||
search_value=search_value,
|
||||
icon=(action.get('icon.rec_name') or ''),
|
||||
tab_domain=tab_domain)
|
||||
tab_domain=tab_domain,
|
||||
context_model=action['context_model'])
|
||||
elif action['type'] == 'ir.action.wizard':
|
||||
Window.create_wizard(action['wiz_name'], data,
|
||||
direct_print=action.get('direct_print', False),
|
||||
|
||||
@@ -93,7 +93,7 @@ class Form(SignalEvent, TabContent):
|
||||
|
||||
def __init__(self, model, res_id=False, domain=None, order=None, mode=None,
|
||||
view_ids=None, context=None, name=False, limit=None,
|
||||
search_value=None, tab_domain=None):
|
||||
search_value=None, tab_domain=None, context_model=None):
|
||||
super(Form, self).__init__()
|
||||
|
||||
if not mode:
|
||||
@@ -113,7 +113,8 @@ class Form(SignalEvent, TabContent):
|
||||
|
||||
self.screen = Screen(self.model, mode=mode, context=context,
|
||||
view_ids=view_ids, domain=domain, limit=limit, order=order,
|
||||
search_value=search_value, tab_domain=tab_domain)
|
||||
search_value=search_value, tab_domain=tab_domain,
|
||||
context_model=context_model)
|
||||
self.screen.widget.show()
|
||||
|
||||
if not name:
|
||||
|
||||
@@ -16,6 +16,8 @@ import xml.dom.minidom
|
||||
import gettext
|
||||
import logging
|
||||
|
||||
import gtk
|
||||
|
||||
from tryton.gui.window.view_form.model.group import Group
|
||||
from tryton.gui.window.view_form.view.screen_container import ScreenContainer
|
||||
from tryton.gui.window.view_form.view import View
|
||||
@@ -42,7 +44,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, order=None, search_value=None,
|
||||
tab_domain=None, alternate_view=False):
|
||||
tab_domain=None, context_model=None, alternate_view=False):
|
||||
if view_ids is None:
|
||||
view_ids = []
|
||||
if mode is None:
|
||||
@@ -84,6 +86,40 @@ class Screen(SignalEvent):
|
||||
self.screen_container = ScreenContainer(tab_domain)
|
||||
self.screen_container.alternate_view = alternate_view
|
||||
self.widget = self.screen_container.widget_get()
|
||||
|
||||
self.context_screen = None
|
||||
if context_model:
|
||||
self.context_screen = Screen(
|
||||
context_model, mode=['form'], context=context)
|
||||
context_widget = self.context_screen.widget
|
||||
|
||||
def walk_descendants(widget):
|
||||
yield widget
|
||||
if not hasattr(widget, 'get_children'):
|
||||
return
|
||||
for child in widget.get_children():
|
||||
for widget in walk_descendants(child):
|
||||
yield widget
|
||||
|
||||
for widget in walk_descendants(context_widget):
|
||||
if isinstance(widget, gtk.ScrolledWindow):
|
||||
widget.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
|
||||
elif isinstance(widget, gtk.Viewport):
|
||||
widget.set_shadow_type(gtk.SHADOW_NONE)
|
||||
elif isinstance(widget, gtk.Entry):
|
||||
widget.connect_after(
|
||||
'activate', self.screen_container.activate)
|
||||
elif isinstance(widget, gtk.CheckButton):
|
||||
widget.connect_after(
|
||||
'toggled', self.screen_container.activate)
|
||||
|
||||
self.screen_container.filter_vbox.pack_start(
|
||||
context_widget, expand=False, fill=True)
|
||||
self.screen_container.filter_vbox.reorder_child(
|
||||
context_widget, 0)
|
||||
self.context_screen.new()
|
||||
self.context_screen.widget.show()
|
||||
|
||||
self.__current_view = 0
|
||||
self.search_value = search_value
|
||||
self.fields_view_tree = {}
|
||||
@@ -191,6 +227,16 @@ class Screen(SignalEvent):
|
||||
return list(self.domain_parser.completion(search_string))
|
||||
|
||||
def search_filter(self, search_string=None, only_ids=False):
|
||||
if self.context_screen:
|
||||
context_record = self.context_screen.current_record
|
||||
if not context_record.validate():
|
||||
self.clear()
|
||||
self.context_screen.display(set_cursor=True)
|
||||
return False
|
||||
context = self.context
|
||||
context.update(self.context_screen.get_on_change_value())
|
||||
self.new_group(context)
|
||||
|
||||
domain = []
|
||||
|
||||
if self.domain_parser and not self.parent:
|
||||
|
||||
@@ -571,7 +571,9 @@ class ScreenContainer(object):
|
||||
|
||||
# Move the window under the button
|
||||
x, y = button.window.get_origin()
|
||||
self.search_window.move(x, y + button_allocation.height)
|
||||
self.search_window.move(
|
||||
x + button_allocation.x,
|
||||
y + button_allocation.y + button_allocation.height)
|
||||
|
||||
from tryton.gui.main import Main
|
||||
page = Main.get_main().get_page()
|
||||
|
||||
@@ -21,7 +21,7 @@ class Window(object):
|
||||
@staticmethod
|
||||
def create(view_ids, model, res_id=False, domain=None,
|
||||
context=None, order=None, mode=None, name=False, limit=None,
|
||||
search_value=None, icon=None, tab_domain=None):
|
||||
search_value=None, icon=None, tab_domain=None, context_model=None):
|
||||
from tryton.gui import Main
|
||||
if context is None:
|
||||
context = {}
|
||||
@@ -30,7 +30,8 @@ class Window(object):
|
||||
from form import Form
|
||||
win = Form(model, res_id, domain, order=order, mode=mode,
|
||||
view_ids=(view_ids or []), context=context, name=name,
|
||||
limit=limit, search_value=search_value, tab_domain=tab_domain)
|
||||
limit=limit, search_value=search_value, tab_domain=tab_domain,
|
||||
context_model=context_model)
|
||||
else:
|
||||
from board import Board
|
||||
win = Board(model, view_ids and view_ids[0] or None,
|
||||
|
||||
Reference in new issue
Block a user