From f749c81e27d5947e2bc28f097bb46ef55fc4b70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80ngel=20=C3=80lvarez?= Date: Tue, 24 Mar 2020 09:54:19 +0100 Subject: [PATCH] add lazy loading --- lazy_loading.diff | 29 +++++++++++++++++++++++++++++ series | 1 + 2 files changed, 30 insertions(+) create mode 100644 lazy_loading.diff diff --git a/lazy_loading.diff b/lazy_loading.diff new file mode 100644 index 0000000..c1c30f6 --- /dev/null +++ b/lazy_loading.diff @@ -0,0 +1,29 @@ +diff --git a/trytond/model/fields/many2one.py b/trytond/model/fields/many2one.py +index 92ecf697..abb41628 100644 +--- a/trytond/trytond/model/fields/many2one.py ++++ b/trytond/trytond/model/fields/many2one.py +@@ -25,7 +25,7 @@ class Many2One(Field): + search_order=None, search_context=None, help='', required=False, + readonly=False, domain=None, states=None, select=False, + on_change=None, on_change_with=None, depends=None, context=None, +- loading='eager'): ++ loading='lazy'): + ''' + :param model_name: The name of the target model. + :param left: The name of the field to store the left value for +diff --git a/trytond/model/modelstorage.py b/trytond/model/modelstorage.py +index 9a7d4026..ba61dffd 100644 +--- a/trytond/trytond/model/modelstorage.py ++++ b/trytond/trytond/model/modelstorage.py +@@ -92,9 +92,9 @@ class ModelStorage(Model): + """ + + create_uid = fields.Many2One('res.user', 'Create User', readonly=True) +- create_date = fields.Timestamp('Create Date', readonly=True) ++ create_date = fields.Timestamp('Create Date', readonly=True, loading='lazy') + write_uid = fields.Many2One('res.user', 'Write User', readonly=True) +- write_date = fields.Timestamp('Write Date', readonly=True) ++ write_date = fields.Timestamp('Write Date', readonly=True, loading='lazy') + rec_name = fields.Function(fields.Char('Record Name'), 'get_rec_name', + searcher='search_rec_name') + diff --git a/series b/series index 30637a1..767b2b3 100644 --- a/series +++ b/series @@ -77,3 +77,4 @@ statement_of_account.diff # [account] Cumulate balance of previous fiscal years # issue8690.diff # Set company context in product instance stock_supply.diff # [stock_supply] Force rounding in the quantity of internal shipment moves issue9103.diff # [trytond] User-defined reports for custom template extensions +lazy_loading.diff # [trytond] lazy loading of id, create_date, write_date on many2one