From a22f10e2ad4df24d585284742491a2edcce9955a Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Mon, 17 Dec 2018 19:29:54 +0100 Subject: [PATCH] [IMP] - read may be harmful to performance --- onchange_helper/__manifest__.py | 3 ++- onchange_helper/models/base.py | 7 ++++++- onchange_helper/readme/CONTRIBUTORS.rst | 2 +- onchange_helper/readme/DESCRIPTION.rst | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/onchange_helper/__manifest__.py b/onchange_helper/__manifest__.py index d220bd481..386ae237e 100644 --- a/onchange_helper/__manifest__.py +++ b/onchange_helper/__manifest__.py @@ -4,7 +4,8 @@ { 'name': 'Onchange Helper', 'version': '12.0.1.0.0', - 'summary': 'Technical module that ease execution of onchange in Python code', + 'summary': 'Technical module that ease execution' + ' of onchange in Python code', 'author': 'Akretion,Camptocamp,Odoo Community Association (OCA)', 'website': 'https://github.com/OCA/server-tools', 'license': 'AGPL-3', diff --git a/onchange_helper/models/base.py b/onchange_helper/models/base.py index d0823dbb0..00d888bb8 100644 --- a/onchange_helper/models/base.py +++ b/onchange_helper/models/base.py @@ -31,7 +31,12 @@ class Base(models.AbstractModel): # If self is an empty record we will have an empty value if self: self.ensure_one() - record_values = self._convert_to_write(self.read()[0]) + record_values = self._convert_to_write( + { + field_name: self[field_name] + for field_name, field in self._fields.items() + } + ) else: record_values = {} for field in self._fields: diff --git a/onchange_helper/readme/CONTRIBUTORS.rst b/onchange_helper/readme/CONTRIBUTORS.rst index 85d5fd7e1..f4084e979 100644 --- a/onchange_helper/readme/CONTRIBUTORS.rst +++ b/onchange_helper/readme/CONTRIBUTORS.rst @@ -1,3 +1,3 @@ * Guewen Baconnier * Florian da Costa -* Andrea Stirpe \ No newline at end of file +* Andrea Stirpe diff --git a/onchange_helper/readme/DESCRIPTION.rst b/onchange_helper/readme/DESCRIPTION.rst index 012f36c6f..23c01a8ef 100644 --- a/onchange_helper/readme/DESCRIPTION.rst +++ b/onchange_helper/readme/DESCRIPTION.rst @@ -1 +1 @@ -This is a technical module. Its goal is to ease the play of onchange method directly called from Python code. \ No newline at end of file +This is a technical module. Its goal is to ease the play of onchange method directly called from Python code.