Add common date_format to fallback to rpc context format
Since issue6082, the rpc context locale date format is no more set in the group context. issue7071 review40971002
This commit is contained in:
1 parent
f33818773b
commit
4c24fa6bcf
5 files changed
+14
-12
No files matched your search
@@ -1430,3 +1430,7 @@ def ellipsize(string, length):
|
||||
return string
|
||||
ellipsis = _('...')
|
||||
return string[:length - len(ellipsis)] + ellipsis
|
||||
|
||||
|
||||
def date_format(format_):
|
||||
return format_ or rpc.CONTEXT.get('locale', {}).get('date', '%x')
|
||||
@@ -230,7 +230,7 @@ class DateTimeField(Field):
|
||||
|
||||
def date_format(self, record):
|
||||
context = self.get_context(record)
|
||||
return context.get('date_format', '%x')
|
||||
return common.date_format(context.get('date_format'))
|
||||
|
||||
def time_format(self, record):
|
||||
return record.expr_eval(self.attrs['format'])
|
||||
@@ -249,7 +249,7 @@ class DateField(Field):
|
||||
|
||||
def date_format(self, record):
|
||||
context = self.get_context(record)
|
||||
return context.get('date_format', '%x')
|
||||
return common.date_format(context.get('date_format'))
|
||||
|
||||
|
||||
class TimeField(Field):
|
||||
@@ -956,7 +956,7 @@ class DictField(Field):
|
||||
|
||||
def date_format(self, record):
|
||||
context = self.get_context(record)
|
||||
return context.get('date_format', '%x')
|
||||
return common.date_format(context.get('date_format'))
|
||||
|
||||
def time_format(self, record):
|
||||
return '%X'
|
||||
|
||||
@@ -129,8 +129,6 @@ class Screen(SignalEvent):
|
||||
self.search_value = attributes.get('search_value')
|
||||
self.fields_view_tree = {}
|
||||
self.order = self.default_order = attributes.get('order')
|
||||
self.__date_format = self.context.get(
|
||||
'date_format', rpc.CONTEXT.get('locale', {}).get('date', '%x'))
|
||||
self.view_to_load = []
|
||||
self._domain_parser = {}
|
||||
self.pre_validate = False
|
||||
@@ -335,10 +333,6 @@ class Screen(SignalEvent):
|
||||
def context(self):
|
||||
return self.group.context
|
||||
|
||||
@property
|
||||
def date_format(self):
|
||||
return self.__date_format
|
||||
|
||||
def __get_group(self):
|
||||
return self.__group
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import gettext
|
||||
import gobject
|
||||
|
||||
from .widget import Widget
|
||||
from tryton import common
|
||||
from tryton.common.datetime_ import (Date as DateEntry, Time as TimeEntry,
|
||||
DateTime as DateTimeEntry, add_operators)
|
||||
from tryton.common.widget_style import set_widget_style
|
||||
@@ -73,7 +74,8 @@ class Date(Widget):
|
||||
if field and record:
|
||||
format_ = field.date_format(record)
|
||||
else:
|
||||
format_ = self.view.screen.date_format
|
||||
format_ = common.date_format(
|
||||
self.view.screen.context.get('date_format'))
|
||||
self.entry.props.format = format_
|
||||
|
||||
def display(self, record, field):
|
||||
@@ -161,7 +163,8 @@ class DateTime(Date):
|
||||
date_format = field.date_format(record)
|
||||
time_format = field.time_format(record)
|
||||
else:
|
||||
date_format = self.view.screen.date_format
|
||||
date_format = common.date_format(
|
||||
self.view.screen.context.get('date_format'))
|
||||
time_format = '%X'
|
||||
self.entry.props.date_format = date_format
|
||||
self.entry.props.time_format = time_format
|
||||
@@ -556,7 +556,8 @@ class ScreenContainer(object):
|
||||
entry = Selection(selections)
|
||||
yoptions = gtk.FILL | gtk.EXPAND
|
||||
elif field['type'] in ('date', 'datetime', 'time'):
|
||||
date_format = self.screen.context.get('date_format', '%x')
|
||||
date_format = common.date_format(
|
||||
self.screen.context.get('date_format'))
|
||||
if field['type'] == 'date':
|
||||
entry = Dates(date_format)
|
||||
elif field['type'] in ('datetime', 'time'):
|
||||
|
||||
Reference in new issue
Block a user