Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
d2b9e8aa
Commit
d2b9e8aa
authored
8 years ago
by
Nicolas Martinelli
Browse files
Options
Downloads
Patches
Plain Diff
[REF] base, mail: use new format_date method
parent
b1eb3444
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
addons/mail/models/mail_template.py
+2
-9
2 additions, 9 deletions
addons/mail/models/mail_template.py
odoo/addons/base/ir/ir_qweb/fields.py
+2
-16
2 additions, 16 deletions
odoo/addons/base/ir/ir_qweb/fields.py
with
4 additions
and
25 deletions
addons/mail/models/mail_template.py
+
2
−
9
View file @
d2b9e8aa
...
...
@@ -20,17 +20,10 @@ _logger = logging.getLogger(__name__)
def
format_date
(
env
,
date
,
pattern
=
False
):
date
=
datetime
.
datetime
.
strptime
(
date
[:
10
],
tools
.
DEFAULT_SERVER_DATE_FORMAT
)
lang_code
=
env
.
context
.
get
(
'
lang
'
)
or
'
en_US
'
if
not
pattern
:
lang
=
env
[
'
res.lang
'
].
_lang_get
(
lang_code
)
pattern
=
lang
.
date_format
try
:
locale
=
babel
.
Locale
.
parse
(
lang_code
)
pattern
=
tools
.
posix_to_ldml
(
pattern
,
locale
=
locale
)
return
babel
.
dates
.
format_date
(
date
,
format
=
pattern
,
locale
=
locale
)
return
tools
.
format_date
(
env
,
date
,
date_format
=
pattern
)
except
babel
.
core
.
UnknownLocaleError
:
return
date
.
strftime
(
pattern
)
return
date
def
format_tz
(
env
,
dt
,
tz
=
False
,
format
=
False
):
...
...
This diff is collapsed.
Click to expand it.
odoo/addons/base/ir/ir_qweb/fields.py
+
2
−
16
View file @
d2b9e8aa
...
...
@@ -5,7 +5,7 @@ from odoo import api, fields, models, _
from
PIL
import
Image
from
cStringIO
import
StringIO
import
babel
from
odoo.tools
import
html_escape
as
escape
,
posix_to_ldml
,
safe_eval
,
float_utils
from
odoo.tools
import
html_escape
as
escape
,
posix_to_ldml
,
safe_eval
,
float_utils
,
format_date
from
.qweb
import
unicodifier
import
logging
...
...
@@ -167,21 +167,7 @@ class DateConverter(models.AbstractModel):
@api.model
def
value_to_html
(
self
,
value
,
options
):
if
not
value
or
len
(
value
)
<
10
:
return
''
lang
=
self
.
user_lang
()
locale
=
babel
.
Locale
.
parse
(
lang
.
code
)
if
isinstance
(
value
,
basestring
):
value
=
fields
.
Datetime
.
from_string
(
value
[:
10
])
if
options
and
'
format
'
in
options
:
pattern
=
options
[
'
format
'
]
else
:
strftime_pattern
=
lang
.
date_format
pattern
=
posix_to_ldml
(
strftime_pattern
,
locale
=
locale
)
return
babel
.
dates
.
format_date
(
value
,
format
=
pattern
,
locale
=
locale
)
return
format_date
(
self
.
env
,
value
,
date_format
=
(
options
or
{}).
get
(
'
format
'
))
class
DateTimeConverter
(
models
.
AbstractModel
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment