Skip to content

Commit

Permalink
add check_write_from_computed_field module
Browse files Browse the repository at this point in the history
  • Loading branch information
Kev-Roche committed Jul 2, 2024
1 parent e8e9d00 commit 7c511ce
Show file tree
Hide file tree
Showing 11 changed files with 583 additions and 0 deletions.
68 changes: 68 additions & 0 deletions check_write_from_computed_field/README.rst
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/akretion/odoo-perf/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 <https://github.com/akretion/odoo-perf/issues/new?body=module:%20check_write_from_computed_field%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* Kévin Roche <[email protected]>

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 <https://github.com/akretion/odoo-perf/tree/16.0/check_write_from_computed_field>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions check_write_from_computed_field/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions check_write_from_computed_field/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 Akretion (https://www.akretion.com).
# @author Kévin Roche <[email protected]>
# 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": [],
}
1 change: 1 addition & 0 deletions check_write_from_computed_field/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import base
29 changes: 29 additions & 0 deletions check_write_from_computed_field/models/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 Akretion (https://www.akretion.com).
# @author Kévin Roche <[email protected]>
# 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)
1 change: 1 addition & 0 deletions check_write_from_computed_field/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Kévin Roche <[email protected]>
1 change: 1 addition & 0 deletions check_write_from_computed_field/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to check the write called by a computed field in the logs.
Loading

0 comments on commit 7c511ce

Please sign in to comment.