From ba39e36699ef4b9bca44223d60a70997b4c9346e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 10 Aug 2015 11:10:17 +0200 Subject: [PATCH] Fix fall-back date format The date_format must come from screen context as fall-back. The date_format must be set on all actions context issue4892 review19351002 --- tryton/action/main.py | 8 +++++--- tryton/gui/window/view_form/view/form_gtk/calendar.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tryton/action/main.py b/tryton/action/main.py index 34b99d40d5..16c6d252d1 100644 --- a/tryton/action/main.py +++ b/tryton/action/main.py @@ -84,6 +84,11 @@ class Action(object): def _exec_action(action, data=None, context=None): if context is None: context = {} + else: + context = context.copy() + if 'date_format' not in context: + context['date_format'] = rpc.CONTEXT.get( + 'locale', {}).get('date', '%x') if data is None: data = {} else: @@ -114,9 +119,6 @@ class Action(object): ctx.update(action_ctx) ctx.update(context) action_ctx.update(context) - if 'date_format' not in action_ctx: - action_ctx['date_format'] = rpc.CONTEXT.get( - 'locale', {}).get('date', '%x') ctx['context'] = ctx decoder = PYSONDecoder(ctx) diff --git a/tryton/gui/window/view_form/view/form_gtk/calendar.py b/tryton/gui/window/view_form/view/form_gtk/calendar.py index 70f15b7327..19a0398b17 100644 --- a/tryton/gui/window/view_form/view/form_gtk/calendar.py +++ b/tryton/gui/window/view_form/view/form_gtk/calendar.py @@ -59,7 +59,7 @@ class Date(Widget): if field and record: format_ = field.date_format(record) else: - format_ = '%x' + format_ = self.view.screen.context.get('date_format', '%x') self.entry.props.format = format_ def display(self, record, field): @@ -126,7 +126,7 @@ class DateTime(Date): date_format = field.date_format(record) time_format = field.time_format(record) else: - date_format = '%x' + date_format = self.view.screen.context.get('date_format', '%x') time_format = '%X' self.entry.props.date_format = date_format self.entry.props.time_format = time_format