From cf21042954835d05fbaa59270899776ebb2a1a7a Mon Sep 17 00:00:00 2001 From: sbejaoui Date: Wed, 19 Dec 2018 16:03:13 +0100 Subject: [PATCH] [UPD] - Update documentation --- onchange_helper/models/base.py | 8 ++++++++ onchange_helper/readme/USAGE.rst | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/onchange_helper/models/base.py b/onchange_helper/models/base.py index ad685aad2..3863e4424 100644 --- a/onchange_helper/models/base.py +++ b/onchange_helper/models/base.py @@ -22,6 +22,14 @@ class Base(models.AbstractModel): @api.model def play_onchanges(self, values, onchange_fields): + """ + :param values: dict of input value that + :param onchange_fields: fields for which onchange methods will be + played + Order in onchange_fields is very important as onchanges methods will + be played in that order. + :return: changed values + """ # _onchange_spec() will return onchange fields from the default view # we need all fields in the dict even the empty ones # otherwise 'onchange()' will not apply changes to them diff --git a/onchange_helper/readme/USAGE.rst b/onchange_helper/readme/USAGE.rst index e8b5a738c..52da81375 100644 --- a/onchange_helper/readme/USAGE.rst +++ b/onchange_helper/readme/USAGE.rst @@ -31,3 +31,9 @@ You can also use it on existing record for example: Then the onchange will be played with the vals passed and the existing vals of the sale. `vals` will be updated with partner_invoice_id, pricelist_id, etc.. Behind the scene, `play_onchanges` will execute **all the methods** registered for the list of changed fields, so you do not have to call manually each onchange. To avoid performance issue when the method is called on a record, the record will be transformed into a memory record before calling the registered methods to avoid to trigger SQL updates command when values are assigned to the record by the onchange + + +Notes: + +- Order in onchange_fields is very important as onchanges methods will be played in that order. +- If you use memory object in `vals`, be award that onchange method in base model call `self.invalidate_cache()` that reset it.