From fa8dc795b1a44ed05f856586735583686ffdf867 Mon Sep 17 00:00:00 2001 From: John Herholz Date: Fri, 28 Jun 2024 19:41:17 +0200 Subject: [PATCH] [MIG] edi_exchange_template_oca: Migration to 17.0 --- .../static/description/index.html | 1024 +++++++---------- .../tests/test_edi_backend_output.py | 37 +- .../edi_exchange_template_output_views.xml | 19 +- 3 files changed, 469 insertions(+), 611 deletions(-) diff --git a/edi_exchange_template_oca/static/description/index.html b/edi_exchange_template_oca/static/description/index.html index b950a29df..c0b6328d2 100644 --- a/edi_exchange_template_oca/static/description/index.html +++ b/edi_exchange_template_oca/static/description/index.html @@ -1,596 +1,432 @@ + - - - - EDI Exchange Template - - - -
-

EDI Exchange Template

- - -

- - Beta - - - License: LGPL-3 - - - OCA/edi-framework - - - Translate me on Weblate - - - Try me on Runboat - -

-

Provide EDI exchange templates to control input/output records contents.

-

Provides following models:

-
    -
  1. EDI exchange output template, generates output using QWeb templates
  2. -
  3. [TODO] EDI exchange input template
  4. -
-

- Table of contents -

-
- -
-
-

- Bug Tracker -

-

Bugs are tracked on - GitHub Issues. - In case of trouble, please check there if your issue has already been reported. - If you spotted it first, help us to smash it by providing a detailed and welcomed - - feedback. -

-

Do not contact contributors directly about support or help with technical issues.

-
-
-

- Credits -

-
-

- Authors -

-
    -
  • ACSONE
  • -
  • Camptocamp
  • -
-
-
-

- Contributors -

- -
-
-

- Maintainers -

-

This module is maintained by the OCA.

- - Odoo Community Association - -

OCA, or the Odoo Community Association, is a nonprofit organization whose - mission is to support the collaborative development of Odoo features and - promote its widespread use. -

-

Current - maintainer: -

-

- - simahawk - -

-

This module is part of the - - OCA/edi-framework - - project on GitHub. -

-

You are welcome to contribute. To learn how please visit - https://odoo-community.org/page/Contribute. -

-
-
-
- + + + +EDI Exchange Template + + + +
+

EDI Exchange Template

+ + +

Beta License: LGPL-3 OCA/edi-framework Translate me on Weblate Try me on Runboat

+

Provide EDI exchange templates to control input/output records contents.

+

Provides following models:

+
    +
  1. EDI exchange output template, generates output using QWeb templates
  2. +
  3. [TODO] EDI exchange input template
  4. +
+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE
  • +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

simahawk

+

This module is part of the OCA/edi-framework project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ diff --git a/edi_exchange_template_oca/tests/test_edi_backend_output.py b/edi_exchange_template_oca/tests/test_edi_backend_output.py index 013a51784..a1acee2b4 100644 --- a/edi_exchange_template_oca/tests/test_edi_backend_output.py +++ b/edi_exchange_template_oca/tests/test_edi_backend_output.py @@ -1,6 +1,8 @@ # Copyright 2020 ACSONE SA/NV () # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). +import datetime +from freezegun import freeze_time from lxml import etree from odoo.addons.edi_oca.tests.common import EDIBackendCommonComponentTestCase @@ -35,6 +37,7 @@ def _setup_records(cls): "name": "Out 1", "backend_type_id": cls.backend.backend_type_id.id, "type_id": cls.type_out1.id, + "generator": "qweb", "template_id": qweb_tmpl.id, "output_type": "txt", } @@ -75,6 +78,7 @@ def _setup_records(cls): "name": "Out 2", "backend_type_id": cls.backend.backend_type_id.id, "type_id": cls.type_out2.id, + "generator": "qweb", "template_id": qweb_tmpl.id, "output_type": "xml", "code_snippet": """ @@ -137,12 +141,11 @@ def test_get_template(self): ) def test_generate_file(self): - output = self.backend.exchange_generate(self.record1) + self.backend.exchange_generate(self.record1) expected = f"{self.partner.ref} - {self.partner.name}" - self.assertEqual(output, "Exchange data generated") file_content = self.record1._get_file_content() self.assertEqual(file_content.strip(), expected) - output = self.backend.exchange_generate(self.record2) + self.backend.exchange_generate(self.record2) file_content = self.record2._get_file_content() doc = etree.fromstring(file_content) self.assertEqual(doc.tag, "Record") @@ -164,8 +167,7 @@ def test_prettify(self): self.assertEqual(output, b"\n 1\n\n") def test_generate_file_report(self): - output = self.backend.exchange_generate(self.record3) - self.assertEqual(output, "Exchange data generated") + self.backend.exchange_generate(self.record3) file_content = self.record3._get_file_content() self.assertEqual( self.report._render(self.report, [self.record3.res_id])[0] @@ -173,3 +175,28 @@ def test_generate_file_report(self): .decode("UTF-8"), file_content.strip(), ) + + def test_date_to_string(self): + dt = datetime.date(2024, 9, 10) + no_dt = "" + converted_dt_utc = self.tmpl_out1._date_to_string(dt) + converted_dt_non_utc = self.tmpl_out1._date_to_string(dt, False) + converted_no_dt = self.tmpl_out1._date_to_string(no_dt) + self.assertEqual(converted_dt_utc, "2024-09-10") + self.assertEqual(converted_dt_non_utc, "2024-09-10") + self.assertEqual(converted_no_dt, "") + + def test_datetime_to_string(self): + dt = datetime.datetime(2024, 9, 10, 11, 5, 49) + no_dt = "" + converted_dt_utc = self.tmpl_out1._datetime_to_string(dt) + converted_dt_non_utc = self.tmpl_out1._datetime_to_string(dt, False) + converted_no_dt = self.tmpl_out1._datetime_to_string(no_dt) + self.assertEqual(converted_dt_utc, "2024-09-10 00:00:00") + self.assertEqual(converted_dt_non_utc, "2024-09-10 11:05:49") + self.assertEqual(converted_no_dt, "") + + @freeze_time("2024-07-27 10:00:00") + def test_utc_now(self): + utc_now_output = self.tmpl_out1._utc_now() + self.assertEqual(utc_now_output, "2024-07-27T10:00:00") diff --git a/edi_exchange_template_oca/views/edi_exchange_template_output_views.xml b/edi_exchange_template_oca/views/edi_exchange_template_output_views.xml index 1a3ce93bd..3a9f771e2 100644 --- a/edi_exchange_template_oca/views/edi_exchange_template_output_views.xml +++ b/edi_exchange_template_oca/views/edi_exchange_template_output_views.xml @@ -15,7 +15,7 @@ edi.exchange.template.output -
+