Fallback to model name as title

issue9596
review300381002
This commit is contained in:
Cédric Krier committed 2020-10-04 00:35:23 +02:00
1 parent 4bd91f0cf5
commit 0db065083c
8 files changed
+36 -7

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Fallback to model name as title
* Manage deletable and writable state
* Support e-mail template
* Send e-mail via the server
+2 -2
View File
@@ -1,7 +1,7 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from .common import (
IconFactory, MODELACCESS, MODELHISTORY, VIEW_SEARCH,
IconFactory, MODELACCESS, MODELHISTORY, MODELNAME, VIEW_SEARCH,
get_toplevel_window, get_sensible_widget, selection, file_selection,
slugify, file_write, file_open, mailto, message, warning, userwarning, sur,
sur_3b, ask, concurrency, error, to_xml, process_exception, Login, Logout,
@@ -18,7 +18,7 @@ from .environment import EvalEnvironment
from . import timedelta
__all__ = [
IconFactory, MODELACCESS, MODELHISTORY, VIEW_SEARCH,
IconFactory, MODELACCESS, MODELHISTORY, MODELNAME, VIEW_SEARCH,
get_toplevel_window, get_sensible_widget, selection, file_selection,
slugify, file_write, file_open, mailto, message, warning, userwarning, sur,
sur_3b, ask, concurrency, error, to_xml, process_exception, Login, Logout,
+22
View File
@@ -228,6 +228,28 @@ class ModelHistory(object):
MODELHISTORY = ModelHistory()
class ModelName:
_names = {}
def load_names(self):
try:
self._names = rpc.execute(
'model', 'ir.model', 'get_names', rpc.CONTEXT)
except TrytonServerError:
pass
def get(self, model):
if not self._names:
self.load_names()
return self._names.get(model, '')
def clear(self):
return self._names.clear()
MODELNAME = ModelName()
class ViewSearch(object):
searches = {}
+1
View File
@@ -532,6 +532,7 @@ class Main(Gtk.Application):
self.favorite_unset()
self.primary_menu.set_menu_model(self._get_primary_menu())
CONFIG['client.lang'] = prefs['language']
common.MODELNAME.clear()
# Set placeholder after language is set to get correct translation
self.global_search_entry.set_placeholder_text(_("Action"))
CONFIG.save()
+3 -4
View File
@@ -7,7 +7,7 @@ import xml.dom.minidom
from tryton.signal_event import SignalEvent
from tryton.gui import Main
from tryton.gui.window.view_board import ViewBoard
from tryton.common import RPCExecute, RPCException
from tryton.common import RPCExecute, RPCException, MODELNAME
from .tabcontent import TabContent
@@ -35,9 +35,8 @@ class Board(SignalEvent, TabContent):
self.model = model
self.dialogs = []
if not name:
self.name = self.board.name
else:
self.name = name
name = MODELNAME.get(model)
self.name = name
self.create_tabcontent()
self.board.reload()
+2
View File
@@ -48,6 +48,8 @@ class Form(SignalEvent, TabContent):
self.screen = Screen(self.model, **attributes)
self.screen.widget.show()
if not name:
name = common.MODELNAME.get(model)
self.name = name
self.create_tabcontent()
+3 -1
View File
@@ -6,7 +6,7 @@ from gi.repository import Gdk, Gtk, Pango
from .infobar import InfoBar
import tryton.common as common
from tryton.common import TRYTON_ICON
from tryton.common import TRYTON_ICON, MODELNAME
from tryton.common.domain_parser import quote
from tryton.common.underline import set_underline
from tryton.common.widget_style import widget_class
@@ -30,6 +30,8 @@ class WinForm(NoModal, InfoBar):
self.domain = domain
self.context = context
self.save_current = save_current
if not title:
title = MODELNAME.get(screen.model_name)
self.title = title
self.prev_view = self.screen.current_view
self.screen.screen_container.alternate_view = True
+2
View File
@@ -32,6 +32,8 @@ class WinSearch(NoModal):
self.views_preload = views_preload
self.sel_multi = sel_multi
self.callback = callback
if not title:
title = common.MODELNAME.get(model)
self.title = title
self.exclude_field = exclude_field