diff --git a/setup/web_archive_date/odoo/addons/web_archive_date b/setup/web_archive_date/odoo/addons/web_archive_date new file mode 120000 index 0000000000..b6c6db4808 --- /dev/null +++ b/setup/web_archive_date/odoo/addons/web_archive_date @@ -0,0 +1 @@ +../../../../web_archive_date \ No newline at end of file diff --git a/setup/web_archive_date/setup.py b/setup/web_archive_date/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/web_archive_date/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/web_archive_date/README.rst b/web_archive_date/README.rst new file mode 100644 index 0000000000..22270e441b --- /dev/null +++ b/web_archive_date/README.rst @@ -0,0 +1,102 @@ +================ +Web Archive Date +================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github + :target: https://github.com/OCA/server-ux/tree/13.0/web_archive_date + :alt: OCA/server-ux +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-ux-13-0/server-ux-13-0-web_archive_date + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/250/13.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Glue module between `web` and `base_archive_date`. + +This module adds the `Latest Archived Date:` and `Latest Archived by:` as fields showing in the metadata of a record. Just like the `Latest Modification Date:` (write_date) or the `Created by:` (create_uid). + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Install the module, archive a record and show on the Metdata of the record and you'll +be able to see the `Latest Archived Date` `Latest Archived by` there. +#. To check the Metadata: +* Activate the Developer Mode. +* Click on the `bug`, once the markdown appears, click on the View Metadata button. +* You can check the `Latest Archived Date` and `Latest Archived by` value once the record has been archived previously. + +Known issues / Roadmap +====================== + +Format of `archive_date` is not the same as `write_date` shown in the metadata. Values are formatted in javascript. Can't inherit the method and adapt the value there. + +TO BE DONE: Check how to format the value in the QWeb view somehow. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* `ForgeFlow S.L. `_: + + * Guillem Casassas + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-GuillemCForgeFlow| image:: https://github.com/GuillemCForgeFlow.png?size=40px + :target: https://github.com/GuillemCForgeFlow + :alt: GuillemCForgeFlow + +Current `maintainer `__: + +|maintainer-GuillemCForgeFlow| + +This module is part of the `OCA/server-ux `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_archive_date/__init__.py b/web_archive_date/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/web_archive_date/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/web_archive_date/__manifest__.py b/web_archive_date/__manifest__.py new file mode 100644 index 0000000000..da7b5177ec --- /dev/null +++ b/web_archive_date/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Web Archive Date", + "summary": """ + Reflects the Latest Archived Date and Latest Archived by on the record metadata. + """, + "version": "14.0.1.0.1", + "category": "Usability", + "license": "AGPL-3", + "website": "https://github.com/OCA/server-ux", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "depends": ["web", "base_archive_date"], + "maintainers": ["GuillemCForgeFlow"], + "qweb": ["static/src/xml/debug.xml"], + "installable": True, + "application": False, + "auto_install": True, +} diff --git a/web_archive_date/i18n/web_archive_date.pot b/web_archive_date/i18n/web_archive_date.pot new file mode 100644 index 0000000000..65fb87813c --- /dev/null +++ b/web_archive_date/i18n/web_archive_date.pot @@ -0,0 +1,33 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_archive_date +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: web_archive_date +#: model:ir.model,name:web_archive_date.model_base +msgid "Base" +msgstr "" + +#. module: web_archive_date +#. openerp-web +#: code:addons/web_archive_date/static/src/xml/debug.xml:0 +#, python-format +msgid "Latest Archived Date:" +msgstr "" + +#. module: web_archive_date +#. openerp-web +#: code:addons/web_archive_date/static/src/xml/debug.xml:0 +#, python-format +msgid "Latest Archived by:" +msgstr "" diff --git a/web_archive_date/models/__init__.py b/web_archive_date/models/__init__.py new file mode 100644 index 0000000000..0e44449338 --- /dev/null +++ b/web_archive_date/models/__init__.py @@ -0,0 +1 @@ +from . import base diff --git a/web_archive_date/models/base.py b/web_archive_date/models/base.py new file mode 100644 index 0000000000..bcfbe558cc --- /dev/null +++ b/web_archive_date/models/base.py @@ -0,0 +1,26 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import models + +from odoo.addons.base_archive_date.models.base import LOG_ARCHIVE_DATE, LOG_ARCHIVE_UID + + +class Base(models.AbstractModel): + _inherit = "base" + + def get_metadata(self): + def merge_lists_of_dicts(original, new, key): + merged_dict = {} + for item in original: + merged_dict[item[key]] = item + for item in new: + merged_dict.setdefault(item[key], {}).update(item) + merged_list = list(merged_dict.values()) + return merged_list + + result = super(Base, self).get_metadata() + fields_list = list(self._fields) + if LOG_ARCHIVE_DATE in fields_list and LOG_ARCHIVE_UID in fields_list: + archive_dict = self.read([LOG_ARCHIVE_DATE, LOG_ARCHIVE_UID]) + return merge_lists_of_dicts(result, archive_dict, "id") + return result diff --git a/web_archive_date/readme/CONTRIBUTORS.rst b/web_archive_date/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..a502d31e5b --- /dev/null +++ b/web_archive_date/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `ForgeFlow S.L. `_: + + * Guillem Casassas diff --git a/web_archive_date/readme/DESCRIPTION.rst b/web_archive_date/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..4ec4ffa3be --- /dev/null +++ b/web_archive_date/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +Glue module between `web` and `base_archive_date`. + +This module adds the `Latest Archived Date:` and `Latest Archived by:` as fields showing in the metadata of a record. Just like the `Latest Modification Date:` (write_date) or the `Created by:` (create_uid). diff --git a/web_archive_date/readme/ROADMAP.rst b/web_archive_date/readme/ROADMAP.rst new file mode 100644 index 0000000000..99666376d6 --- /dev/null +++ b/web_archive_date/readme/ROADMAP.rst @@ -0,0 +1,3 @@ +Format of `archive_date` is not the same as `write_date` shown in the metadata. Values are formatted in javascript. Can't inherit the method and adapt the value there. + +TO BE DONE: Check how to format the value in the QWeb view somehow. diff --git a/web_archive_date/readme/USAGE.rst b/web_archive_date/readme/USAGE.rst new file mode 100644 index 0000000000..9cc96ad5de --- /dev/null +++ b/web_archive_date/readme/USAGE.rst @@ -0,0 +1,6 @@ +#. Install the module, archive a record and show on the Metdata of the record and you'll +be able to see the `Latest Archived Date` `Latest Archived by` there. +#. To check the Metadata: +* Activate the Developer Mode. +* Click on the `bug`, once the markdown appears, click on the View Metadata button. +* You can check the `Latest Archived Date` and `Latest Archived by` value once the record has been archived previously. diff --git a/web_archive_date/static/description/icon.png b/web_archive_date/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/web_archive_date/static/description/icon.png differ diff --git a/web_archive_date/static/description/index.html b/web_archive_date/static/description/index.html new file mode 100644 index 0000000000..526225eb85 --- /dev/null +++ b/web_archive_date/static/description/index.html @@ -0,0 +1,441 @@ + + + + + + +Web Archive Date + + + +
+

Web Archive Date

+ + +

Beta License: AGPL-3 OCA/server-ux Translate me on Weblate Try me on Runbot

+

Glue module between web and base_archive_date.

+

This module adds the Latest Archived Date: and Latest Archived by: as fields showing in the metadata of a record. Just like the Latest Modification Date: (write_date) or the Created by: (create_uid).

+

Table of contents

+ +
+

Usage

+

#. Install the module, archive a record and show on the Metdata of the record and you’ll +be able to see the Latest Archived Date Latest Archived by there. +#. To check the Metadata: +* Activate the Developer Mode. +* Click on the bug, once the markdown appears, click on the View Metadata button. +* You can check the Latest Archived Date and Latest Archived by value once the record has been archived previously.

+
+
+

Known issues / Roadmap

+

Format of archive_date is not the same as write_date shown in the metadata. Values are formatted in javascript. Can’t inherit the method and adapt the value there.

+

TO BE DONE: Check how to format the value in the QWeb view somehow.

+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+ +
+

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:

+

GuillemCForgeFlow

+

This module is part of the OCA/server-ux project on GitHub.

+

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

+
+
+
+ + diff --git a/web_archive_date/static/src/xml/debug.xml b/web_archive_date/static/src/xml/debug.xml new file mode 100644 index 0000000000..271aba1128 --- /dev/null +++ b/web_archive_date/static/src/xml/debug.xml @@ -0,0 +1,17 @@ + + + diff --git a/web_archive_date/tests/__init__.py b/web_archive_date/tests/__init__.py new file mode 100644 index 0000000000..3fd0acab86 --- /dev/null +++ b/web_archive_date/tests/__init__.py @@ -0,0 +1 @@ +from . import test_web_archive_date diff --git a/web_archive_date/tests/test_web_archive_date.py b/web_archive_date/tests/test_web_archive_date.py new file mode 100644 index 0000000000..2f342daf12 --- /dev/null +++ b/web_archive_date/tests/test_web_archive_date.py @@ -0,0 +1,65 @@ +# Copyright 2023 ForgeFlow S.L. (https://www.forgeflow.com) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.addons.base_archive_date.tests.test_base_archive_date import ( + TestBaseArchiveDate, +) + + +class TestWebArchiveDate(TestBaseArchiveDate): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + + # Models + cls.company_model = cls.env["res.company"] + + # Instances + cls.company = cls.company_model.create({"name": "Test Company"}) + + def test_01_check_metadata_shown(self): + """ + Check that the method getting the metadata on a record, once it is archived. + """ + self.partner.toggle_active() + metadata = self.partner.get_metadata() + self.assertEqual(len(metadata), 1, "List should only contain one value.") + value = metadata[0] + self.assertTrue(value) + self.assertTrue( + "id" in value.keys() and self.partner.id == value.get("id"), + "Partner ID should be the value of the key ID in the dictionary.", + ) + self.assertTrue( + "archive_date" in value.keys() and "archive_uid" in value.keys() + ) + self.assertEqual( + value.get("archive_date"), + self.partner.archive_date, + "Value shown in the metadata view should be equal to the one set in the partner.", + ) + self.assertEqual( + value.get("archive_uid")[0], + self.partner.archive_uid.id, + "User ID shown used in the metadata should be the same as the archive_uid value.", + ) + + def test_02_check_metadata_shown_on_model_not_having_active_field(self): + """ + Check that the method getting the metadata on a record, if the record doesn't + have the active field. + """ + c_fields_list = list(self.company._fields) + self.assertFalse("active" in c_fields_list) + metadata = self.company.get_metadata() + self.assertEqual(len(metadata), 1, "List should only contain one value.") + value = metadata[0] + self.assertFalse( + "archive_date" in value.keys(), + "The Archive Date should not be listed for a model not having the active field.", + ) + self.assertFalse( + "archive_uid" in value.keys(), + "The Archive by should not be listed for a model not having the active field.", + )