[MIG][10.0][datetime_formatter] Migration
Special highlights: - Fixed some license headers. - Adhered to normal addon structure. - Removed `exceptions.py` and use `UserError` instead. - Allow submodules to import some constants from main namespace. The rest is basically a standard migration.pull/2274/head
parent
28e63164ac
commit
b2508e69f2
|
@ -37,7 +37,7 @@ If you are a developer, to use this module, you need to:
|
|||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/149/9.0
|
||||
:target: https://runbot.odoo-community.org/runbot/149/10.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
|
||||
# © 2016 Tecnativa, S.L. - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from . import models
|
||||
# Make these easily available for submodules
|
||||
from .models.res_lang import MODE_DATE, MODE_DATETIME, MODE_TIME
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
|
||||
# © 2016 Tecnativa, S.L. - Vicent Cubells
|
||||
# Copyright 2015, 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
# Copyright 2016 Tecnativa, S.L. - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
"name": "Date & Time Formatter",
|
||||
"summary": "Helper functions to give correct format to date[time] fields",
|
||||
"version": "9.0.1.0.0",
|
||||
"version": "10.0.1.0.0",
|
||||
"category": "Tools",
|
||||
"website": "https://tecnativa.com",
|
||||
"website": "https://www.tecnativa.com",
|
||||
"author": "Grupo ESOC Ingeniería de Servicios, "
|
||||
"Tecnativa,"
|
||||
"Odoo Community Association (OCA)",
|
|
@ -1,12 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
|
||||
# © 2016 Tecnativa, S.L. - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from openerp import _, exceptions
|
||||
|
||||
|
||||
class BestMatchedLanguageNotFoundError(exceptions.MissingError):
|
||||
def __init__(self, lang):
|
||||
msg = (_("Best matched language (%s) not found.") % lang)
|
||||
super(BestMatchedLanguageNotFoundError, self).__init__(msg)
|
||||
self.lang = lang
|
|
@ -0,0 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from . import res_lang
|
|
@ -1,12 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
|
||||
# © 2016 Tecnativa, S.L. - Vicent Cubells
|
||||
# Copyright 2015, 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
# Copyright 2016 Tecnativa, S.L. - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from datetime import datetime, timedelta
|
||||
from openerp import api, fields, models
|
||||
from openerp.tools import (DEFAULT_SERVER_DATE_FORMAT,
|
||||
DEFAULT_SERVER_TIME_FORMAT)
|
||||
from . import exceptions as ex
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.tools import (DEFAULT_SERVER_DATE_FORMAT,
|
||||
DEFAULT_SERVER_TIME_FORMAT)
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
# Available modes for :param:`.ResLang.datetime_formatter.template`
|
||||
MODE_DATETIME = "MODE_DATETIME"
|
||||
|
@ -56,7 +56,9 @@ class ResLang(models.Model):
|
|||
record.ensure_one()
|
||||
except ValueError:
|
||||
if not failure_safe:
|
||||
raise ex.BestMatchedLanguageNotFoundError(lang)
|
||||
raise UserError(
|
||||
_("Best matched language (%s) not found.") % lang
|
||||
)
|
||||
else:
|
||||
record = first_installed
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
|
||||
# © 2016 Tecnativa, S.L. - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from . import test_best_matcher, test_formatter
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
|
||||
# © 2016 Tecnativa, S.L. - Vicent Cubells
|
||||
# Copyright 2015, 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
# Copyright 2016 Tecnativa, S.L. - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from openerp.tests.common import TransactionCase
|
||||
from .. import exceptions
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class BasicCase(TransactionCase):
|
||||
|
@ -72,5 +72,5 @@ class BasicCase(TransactionCase):
|
|||
self.assertEqual(self.rl.best_match("fake_LANG").code, first.code)
|
||||
|
||||
# Unsafe mode
|
||||
with self.assertRaises(exceptions.BestMatchedLanguageNotFoundError):
|
||||
with self.assertRaises(UserError):
|
||||
self.rl.best_match("fake_LANG", failure_safe=False)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# © 2015 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis
|
||||
# © 2016 Tecnativa, S.L. - Vicent Cubells
|
||||
# Copyright 2015, 2017 Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||
# Copyright 2016 Tecnativa, S.L. - Vicent Cubells
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
import datetime
|
||||
from random import random
|
||||
from openerp.tests.common import TransactionCase
|
||||
from openerp.tools import (DEFAULT_SERVER_DATE_FORMAT,
|
||||
DEFAULT_SERVER_TIME_FORMAT,
|
||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
from ..models import MODE_DATE, MODE_TIME, MODE_DATETIME
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.tools import (DEFAULT_SERVER_DATE_FORMAT,
|
||||
DEFAULT_SERVER_TIME_FORMAT,
|
||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
from ..models.res_lang import MODE_DATE, MODE_TIME, MODE_DATETIME
|
||||
|
||||
|
||||
class FormatterCase(TransactionCase):
|
||||
|
|
Loading…
Reference in New Issue