From 933cea7d6215e729a8ace37323b2bc6e20127d19 Mon Sep 17 00:00:00 2001 From: Lukas Tran Date: Thu, 12 Dec 2024 09:30:02 +0700 Subject: [PATCH] [MIG] agreement: Migration to 18.0 --- agreement/README.rst | 10 ++++++++++ agreement/__manifest__.py | 2 +- agreement/models/agreement.py | 20 +++++++------------- agreement/readme/CONTRIBUTORS.md | 3 +++ agreement/readme/CREDITS.md | 2 ++ agreement/static/description/index.html | 15 +++++++++++++-- agreement/tests/test_agreement.py | 9 ++++----- agreement/views/agreement.xml | 16 +++++----------- agreement/views/agreement_type.xml | 7 +++---- 9 files changed, 48 insertions(+), 36 deletions(-) create mode 100644 agreement/readme/CREDITS.md diff --git a/agreement/README.rst b/agreement/README.rst index 952e2bab..8997c37a 100644 --- a/agreement/README.rst +++ b/agreement/README.rst @@ -85,6 +85,16 @@ Contributors - Maxime Franco +- `Trobz `__: + + - Nhan Tran + +Other credits +------------- + +The migration of this module from 17.0 to 18.0 was financially supported +by Camptocamp. + Maintainers ----------- diff --git a/agreement/__manifest__.py b/agreement/__manifest__.py index 95a53d12..1da5a063 100644 --- a/agreement/__manifest__.py +++ b/agreement/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Agreement", "summary": "Adds an agreement object", - "version": "17.0.1.0.0", + "version": "18.0.1.0.0", "category": "Contract", "author": "Akretion, " "Yves Goldberg (Ygol Internetwork), " diff --git a/agreement/models/agreement.py b/agreement/models/agreement.py index 91d71685..5f54b12b 100644 --- a/agreement/models/agreement.py +++ b/agreement/models/agreement.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import _, api, fields, models +from odoo import api, fields, models class Agreement(models.Model): @@ -26,7 +26,6 @@ class Agreement(models.Model): ) is_template = fields.Boolean( string="Is a Template?", - default=False, copy=False, help="Set if the agreement is a template. " "Template agreements don't require a partner.", @@ -51,8 +50,8 @@ class Agreement(models.Model): @api.model def _domain_selection(self): return [ - ("sale", _("Sale")), - ("purchase", _("Purchase")), + ("sale", self.env._("Sale")), + ("purchase", self.env._("Purchase")), ] @api.depends("agreement_type_id") @@ -63,14 +62,9 @@ def _compute_domain(self): else: rec.domain = "sale" - def name_get(self): - res = [] - for agr in self: - name = agr.name - if agr.code: - name = f"[{agr.code}] {agr.name}" - res.append((agr.id, name)) - return res + def _compute_display_name(self): + for rec in self: + rec.display_name = f"[{rec.code}] {rec.name}" _sql_constraints = [ ( @@ -85,5 +79,5 @@ def copy(self, default=None): default = dict(default or {}) if default.get("code", False): return super().copy(default) - default.setdefault("code", _("%(code)s (copy)", code=self.code)) + default.setdefault("code", self.env._("%(code)s (copy)", code=self.code)) return super().copy(default) diff --git a/agreement/readme/CONTRIBUTORS.md b/agreement/readme/CONTRIBUTORS.md index f4c5e31d..5c4f7a93 100644 --- a/agreement/readme/CONTRIBUTORS.md +++ b/agreement/readme/CONTRIBUTORS.md @@ -13,3 +13,6 @@ - [Acsone](https://www.acsone.eu/): - Maxime Franco +- [Trobz](https://www.trobz.com/): + + - Nhan Tran \<\> diff --git a/agreement/readme/CREDITS.md b/agreement/readme/CREDITS.md new file mode 100644 index 00000000..8edec949 --- /dev/null +++ b/agreement/readme/CREDITS.md @@ -0,0 +1,2 @@ +The migration of this module from 17.0 to 18.0 was financially supported +by Camptocamp. diff --git a/agreement/static/description/index.html b/agreement/static/description/index.html index 6e3329f1..ba3a8e00 100644 --- a/agreement/static/description/index.html +++ b/agreement/static/description/index.html @@ -389,7 +389,8 @@

Agreement

  • Credits
  • @@ -434,10 +435,20 @@

    Contributors

  • Maxime Franco
  • +
  • Trobz:

    + +
  • +
    +

    Other credits

    +

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

    +
    -

    Maintainers

    +

    Maintainers

    This module is maintained by the OCA.

    Odoo Community Association diff --git a/agreement/tests/test_agreement.py b/agreement/tests/test_agreement.py index e176aeb5..59e4b8b9 100644 --- a/agreement/tests/test_agreement.py +++ b/agreement/tests/test_agreement.py @@ -27,13 +27,12 @@ def test_agreement_type_change(self): self.agreement.write({"agreement_type_id": self.agreement_type.id}) self.assertEqual(self.agreement.domain, self.agreement_type.domain) - def test_name_get(self): - res = self.agreement.name_get() - self.assertEqual(res[0][0], self.agreement.id) - self.assertEqual(res[0][1], f"[{self.agreement.code}] {self.agreement.name}") + def test_compute_display_name(self): + display_name = self.agreement.display_name + self.assertEqual(display_name, f"[{self.agreement.code}] {self.agreement.name}") def test_copy(self): agreement1 = self.agreement.copy(default={"code": "Test Code"}) agreement2 = self.agreement.copy() self.assertEqual(agreement1.code, "Test Code") - self.assertEqual(agreement2.code, "%s (copy)" % (self.agreement.code)) + self.assertEqual(agreement2.code, f"{self.agreement.code} (copy)") diff --git a/agreement/views/agreement.xml b/agreement/views/agreement.xml index cd791768..56672b12 100644 --- a/agreement/views/agreement.xml +++ b/agreement/views/agreement.xml @@ -17,7 +17,6 @@ bg_color="bg-danger" invisible="active" /> -