diff --git a/check_write_from_computed_field/README.rst b/check_write_from_computed_field/README.rst new file mode 100644 index 0000000..4e236fa --- /dev/null +++ b/check_write_from_computed_field/README.rst @@ -0,0 +1,68 @@ +=============================== +Check Write From Computed Field +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:fb310fe636d9a1d0445a2c6ae0b16f4730a2373aa5e39d451c4c028d4b365a52 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-akretion%2Fodoo--perf-lightgray.png?logo=github + :target: https://github.com/akretion/odoo-perf/tree/16.0/check_write_from_computed_field + :alt: akretion/odoo-perf + +|badge1| |badge2| |badge3| + +This module allows to check the write called by a computed field in the logs. + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Akretion + +Contributors +~~~~~~~~~~~~ + +* Kévin Roche + +Maintainers +~~~~~~~~~~~ + +.. |maintainer-Kev-Roche| image:: https://github.com/Kev-Roche.png?size=40px + :target: https://github.com/Kev-Roche + :alt: Kev-Roche + +Current maintainer: + +|maintainer-Kev-Roche| + +This module is part of the `akretion/odoo-perf `_ project on GitHub. + +You are welcome to contribute. diff --git a/check_write_from_computed_field/__init__.py b/check_write_from_computed_field/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/check_write_from_computed_field/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/check_write_from_computed_field/__manifest__.py b/check_write_from_computed_field/__manifest__.py new file mode 100644 index 0000000..1eeee8a --- /dev/null +++ b/check_write_from_computed_field/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2024 Akretion (https://www.akretion.com). +# @author Kévin Roche +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Check Write From Computed Field", + "summary": "module to check write from computed field", + "version": "16.0.1.0.0", + "category": "TODO", + "website": "https://github.com/akretion/odoo-perf", + "author": "Akretion, Odoo Community Association (OCA)", + "license": "AGPL-3", + "maintainers": ["Kev-Roche"], + "application": False, + "installable": True, + "depends": [ + "base", + ], + "data": [], +} diff --git a/check_write_from_computed_field/models/__init__.py b/check_write_from_computed_field/models/__init__.py new file mode 100644 index 0000000..0e44449 --- /dev/null +++ b/check_write_from_computed_field/models/__init__.py @@ -0,0 +1 @@ +from . import base diff --git a/check_write_from_computed_field/models/base.py b/check_write_from_computed_field/models/base.py new file mode 100644 index 0000000..9448095 --- /dev/null +++ b/check_write_from_computed_field/models/base.py @@ -0,0 +1,29 @@ +# Copyright 2024 Akretion (https://www.akretion.com). +# @author Kévin Roche +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import logging + +from odoo import api, models + +_logger = logging.getLogger(__name__) + + +class BaseModel(models.AbstractModel): + _inherit = "base" + + @api.model + def _compute_field_value(self, field): + self = self.with_context(compute_field=field) + return super(BaseModel, self)._compute_field_value(field) + + def write(self, vals): + if self._context.get("compute_field"): + _logger.warning( + "Write operation triggered by computed field on model: " + f"model :{self._name}, " + f"field : {self._context.get('compute_field')}, " + f"vals: {vals} " + f"context: {self._context}, " + ) + return super(BaseModel, self).write(vals) diff --git a/check_write_from_computed_field/readme/CONTRIBUTORS.rst b/check_write_from_computed_field/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..5ef178f --- /dev/null +++ b/check_write_from_computed_field/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Kévin Roche \ No newline at end of file diff --git a/check_write_from_computed_field/readme/DESCRIPTION.rst b/check_write_from_computed_field/readme/DESCRIPTION.rst new file mode 100644 index 0000000..7877e11 --- /dev/null +++ b/check_write_from_computed_field/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to check the write called by a computed field in the logs. diff --git a/check_write_from_computed_field/static/description/index.html b/check_write_from_computed_field/static/description/index.html new file mode 100644 index 0000000..25c818d --- /dev/null +++ b/check_write_from_computed_field/static/description/index.html @@ -0,0 +1,417 @@ + + + + + +Check Write From Computed Field + + + +
+

Check Write From Computed Field

+ + +

Beta License: AGPL-3 akretion/odoo-perf

+

This module allows to check the write called by a computed field in the logs.

+

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

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

Current maintainer:

+

Kev-Roche

+

This module is part of the akretion/odoo-perf project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/check_write_from_computed_field/views/base.xml b/check_write_from_computed_field/views/base.xml new file mode 100644 index 0000000..17e5d00 --- /dev/null +++ b/check_write_from_computed_field/views/base.xml @@ -0,0 +1,38 @@ + + + + + + + + base + + + + + + + + + + base + + + + + + + + + + base + + + + + + + + diff --git a/setup/check_write_from_computed_field/odoo/addons/check_write_from_computed_field b/setup/check_write_from_computed_field/odoo/addons/check_write_from_computed_field new file mode 120000 index 0000000..b93229a --- /dev/null +++ b/setup/check_write_from_computed_field/odoo/addons/check_write_from_computed_field @@ -0,0 +1 @@ +../../../../check_write_from_computed_field \ No newline at end of file diff --git a/setup/check_write_from_computed_field/setup.py b/setup/check_write_from_computed_field/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/check_write_from_computed_field/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)