From 358a50951e5c5751364e28bc9215e317bf37156f Mon Sep 17 00:00:00 2001 From: thien Date: Fri, 29 Nov 2024 12:13:30 +0700 Subject: [PATCH] [MIG] product_template_multi_link_date_span: Migration to 18.0 --- .../README.rst | 4 ++++ .../__manifest__.py | 2 +- .../models/product_template_link.py | 11 +++++++---- .../readme/CONTRIBUTORS.md | 1 + .../readme/CREDITS.md | 2 ++ .../static/description/index.html | 3 +++ .../test_product_template_link_date_span.py | 4 ++-- .../views/product_template_link_type_view.xml | 2 +- .../views/product_template_link_view.xml | 19 ++++--------------- 9 files changed, 25 insertions(+), 23 deletions(-) diff --git a/product_template_multi_link_date_span/README.rst b/product_template_multi_link_date_span/README.rst index d61a7a0c8e..9eabd99a6a 100644 --- a/product_template_multi_link_date_span/README.rst +++ b/product_template_multi_link_date_span/README.rst @@ -62,6 +62,7 @@ Contributors - Trobz - Dung Tran + - Thien Vo - Simone Orsi @@ -72,6 +73,9 @@ The development of this module has been financially supported by: - Camptocamp +The migration of this module from 14.0 to 18.0 was financially supported +by Camptocamp. + Maintainers ----------- diff --git a/product_template_multi_link_date_span/__manifest__.py b/product_template_multi_link_date_span/__manifest__.py index e0b6d5ffb9..9a681d4d94 100644 --- a/product_template_multi_link_date_span/__manifest__.py +++ b/product_template_multi_link_date_span/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Product Template Multi Link With Dates", "summary": "Add an optional date span for when a link is active.", - "version": "14.0.1.1.0", + "version": "18.0.1.0.0", "category": "Sale", "author": "Camptocamp, Odoo Community Association (OCA)", "license": "AGPL-3", diff --git a/product_template_multi_link_date_span/models/product_template_link.py b/product_template_multi_link_date_span/models/product_template_link.py index 7ad69328eb..a07490573f 100644 --- a/product_template_multi_link_date_span/models/product_template_link.py +++ b/product_template_multi_link_date_span/models/product_template_link.py @@ -3,7 +3,7 @@ # @author Simone Orsi # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import _, api, exceptions, fields, models +from odoo import api, exceptions, fields, models class ProductTemplateLink(models.Model): @@ -16,19 +16,22 @@ class ProductTemplateLink(models.Model): @api.depends("date_start", "date_end", "type_id.limited_by_dates") def _compute_is_link_active(self): - super()._compute_is_link_active() + res = super()._compute_is_link_active() today = fields.Date.today() for record in self: if record.limited_by_dates: record.is_link_active = ( (record.date_start or today) <= today <= (record.date_end or today) ) + return res @api.constrains("type_id", "date_start") def _check_mandatory_date_start(self): for rec in self: if rec.mandatory_date_start and not rec.date_start: raise exceptions.UserError( - _("A start date is required according to link type: %s") - % rec.type_id.name + self.env._( + "A start date is required according to link type: %s", + rec.type_id.name, + ) ) diff --git a/product_template_multi_link_date_span/readme/CONTRIBUTORS.md b/product_template_multi_link_date_span/readme/CONTRIBUTORS.md index db49081e9b..8483d38020 100644 --- a/product_template_multi_link_date_span/readme/CONTRIBUTORS.md +++ b/product_template_multi_link_date_span/readme/CONTRIBUTORS.md @@ -2,5 +2,6 @@ - Trobz - Dung Tran \<\> + - Thien Vo \<\> - Simone Orsi \<\> diff --git a/product_template_multi_link_date_span/readme/CREDITS.md b/product_template_multi_link_date_span/readme/CREDITS.md index 705d3b30ca..102074537c 100644 --- a/product_template_multi_link_date_span/readme/CREDITS.md +++ b/product_template_multi_link_date_span/readme/CREDITS.md @@ -1,3 +1,5 @@ The development of this module has been financially supported by: - Camptocamp + +The migration of this module from 14.0 to 18.0 was financially supported by Camptocamp. diff --git a/product_template_multi_link_date_span/static/description/index.html b/product_template_multi_link_date_span/static/description/index.html index f202258a47..d3802618ca 100644 --- a/product_template_multi_link_date_span/static/description/index.html +++ b/product_template_multi_link_date_span/static/description/index.html @@ -407,6 +407,7 @@

Contributors

  • Thierry Ducrest <thierry.ducrest@camptocamp.com>
  • Trobz
  • Simone Orsi <simahawk@gmail.com>
  • @@ -418,6 +419,8 @@

    Other credits

    • Camptocamp
    +

    The migration of this module from 14.0 to 18.0 was financially supported +by Camptocamp.

    Maintainers

    diff --git a/product_template_multi_link_date_span/tests/test_product_template_link_date_span.py b/product_template_multi_link_date_span/tests/test_product_template_link_date_span.py index 2c92ff3e22..2058aaedbc 100644 --- a/product_template_multi_link_date_span/tests/test_product_template_link_date_span.py +++ b/product_template_multi_link_date_span/tests/test_product_template_link_date_span.py @@ -4,11 +4,11 @@ from freezegun import freeze_time from odoo import exceptions -from odoo.tests.common import SavepointCase +from odoo.tests.common import TransactionCase @freeze_time("2020-07-29") -class TestProductTemplateLinkDateSpan(SavepointCase): +class TestProductTemplateLinkDateSpan(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/product_template_multi_link_date_span/views/product_template_link_type_view.xml b/product_template_multi_link_date_span/views/product_template_link_type_view.xml index 08cbfbd6bd..b9b3ffd1fd 100644 --- a/product_template_multi_link_date_span/views/product_template_link_type_view.xml +++ b/product_template_multi_link_date_span/views/product_template_link_type_view.xml @@ -1,7 +1,7 @@ - product.template.link.type.tree.date.span + product.template.link.type.list.date.span product.template.link.type - product.template.link.tree.date.span + product.template.link.list.date.span product.template.link - - + @@ -27,16 +23,9 @@ /> - - + - +