diff --git a/partner_tz/__init__.py b/partner_tz/__init__.py index 738a2eec0..fa947c50b 100644 --- a/partner_tz/__init__.py +++ b/partner_tz/__init__.py @@ -1,2 +1 @@ -from . import models from . import tools diff --git a/partner_tz/models/__init__.py b/partner_tz/models/__init__.py deleted file mode 100644 index 91fed54d4..000000000 --- a/partner_tz/models/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import res_partner diff --git a/partner_tz/models/res_partner.py b/partner_tz/models/res_partner.py deleted file mode 100644 index ab4526abb..000000000 --- a/partner_tz/models/res_partner.py +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2020 Camptocamp SA -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) -from odoo import fields, models - - -class ResPartner(models.Model): - - _inherit = 'res.partner' - - tz = fields.Selection(default=None) diff --git a/partner_tz/readme/DESCRIPTION.rst b/partner_tz/readme/DESCRIPTION.rst index ca7456a53..59b81af6d 100644 --- a/partner_tz/readme/DESCRIPTION.rst +++ b/partner_tz/readme/DESCRIPTION.rst @@ -1,3 +1,2 @@ -This module removes timezone default value on res.partner and display the field -on form view. +This module displays the timezone field on partner form view. Moreover it provides a few tools function in `tools/tz_utils.py`. diff --git a/partner_tz/readme/ROADMAP.rst b/partner_tz/readme/ROADMAP.rst new file mode 100644 index 000000000..50697b892 --- /dev/null +++ b/partner_tz/readme/ROADMAP.rst @@ -0,0 +1,8 @@ +* Odoo default value for timezone field uses the tz set on the connected user. + So if a user creates a partner located in a different timezone than his own, + the created partner will be set in the user's timezone instead of having the + timezone from its own location. + Ideally, we should change this behaviour to get the timezone from the country + and city of the partner when they are defined. + http://www.geonames.org/export/web-services.html#timezone might be a good + starting point. diff --git a/partner_tz/tools/__init__.py b/partner_tz/tools/__init__.py index ed3bafe21..36420787f 100644 --- a/partner_tz/tools/__init__.py +++ b/partner_tz/tools/__init__.py @@ -1 +1,6 @@ -from .tz_utils import * +from .tz_utils import tz_to_tz_naive_datetime +from .tz_utils import tz_to_utc_naive_datetime +from .tz_utils import utc_to_tz_naive_datetime +from .tz_utils import tz_to_tz_time +from .tz_utils import tz_to_utc_time +from .tz_utils import utc_to_tz_time diff --git a/partner_tz/tools/tz_utils.py b/partner_tz/tools/tz_utils.py index 4d4076552..e1b5a8c5d 100644 --- a/partner_tz/tools/tz_utils.py +++ b/partner_tz/tools/tz_utils.py @@ -1,10 +1,10 @@ # Copyright 2020 Camptocamp SA # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) -import pytz -from datetime import datetime, date +from datetime import date, datetime +import pytz -UTC_TZ = pytz.timezone('UTC') +UTC_TZ = pytz.timezone("UTC") def tz_to_tz_naive_datetime(from_tz, to_tz, date_time): diff --git a/partner_tz/views/res_partner.xml b/partner_tz/views/res_partner.xml index 70e15379d..0f79f51a2 100644 --- a/partner_tz/views/res_partner.xml +++ b/partner_tz/views/res_partner.xml @@ -1,4 +1,4 @@ - + res.partner.form.inherit