From 5ad925cee1cacc015f58605c70d9c110f1be8a9a Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 23 Nov 2023 19:07:55 +0100 Subject: [PATCH] [MIG] base_dynamic_list from v14 to v16 --- base_dynamic_list/__manifest__.py | 6 ++--- base_dynamic_list/models/dynamic_list.py | 32 ++++++++++-------------- base_dynamic_list/views/dynamic_list.xml | 2 +- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/base_dynamic_list/__manifest__.py b/base_dynamic_list/__manifest__.py index a2e7d5d..5a49bf8 100644 --- a/base_dynamic_list/__manifest__.py +++ b/base_dynamic_list/__manifest__.py @@ -1,10 +1,10 @@ -# Copyright 2020-2021 Akretion France (http://www.akretion.com) +# Copyright 2020-2023 Akretion France (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Base Dynamic List', - 'version': '14.0.1.0.0', + 'version': '16.0.1.0.0', 'category': 'Tools', 'license': 'AGPL-3', 'summary': 'Dynamic lists', @@ -58,5 +58,5 @@ Limitation: when you want to have different access rights on these lists dependi 'security/ir.model.access.csv', 'views/dynamic_list.xml', ], - 'installable': False, + 'installable': True, } diff --git a/base_dynamic_list/models/dynamic_list.py b/base_dynamic_list/models/dynamic_list.py index 92e9eb1..16453e6 100644 --- a/base_dynamic_list/models/dynamic_list.py +++ b/base_dynamic_list/models/dynamic_list.py @@ -1,4 +1,4 @@ -# Copyright 2020-2021 Akretion France (http://www.akretion.com) +# Copyright 2020-2023 Akretion France (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -63,18 +63,15 @@ class DynamicListCode(models.Model): res.append((rec.id, '[%s] %s' % (rec.code, rec.name))) return res - @api.model - def name_search( - self, name='', args=None, operator='ilike', limit=80): + def _name_search(self, name='', args=None, operator='ilike', limit=100, name_get_uid=None): if args is None: args = [] + ids = [] if name and operator == 'ilike': - recs = self.search( - [('code', '=', name)] + args, limit=limit) - if recs: - return recs.name_get() - return super().name_search( - name=name, args=args, operator=operator, limit=limit) + ids = list(self._search([('code', '=', name)] + args, limit=limit)) + if ids: + return ids + return super()._name_search(name=name, args=args, operator=operator, limit=limit, name_get_uid=name_get_uid) class DynamicListCodeTranslate(models.Model): @@ -101,15 +98,12 @@ class DynamicListCodeTranslate(models.Model): res.append((rec.id, '[%s] %s' % (rec.code, rec.name))) return res - @api.model - def name_search( - self, name='', args=None, operator='ilike', limit=80): + def _name_search(self, name='', args=None, operator='ilike', limit=100, name_get_uid=None): if args is None: args = [] + ids = [] if name and operator == 'ilike': - recs = self.search( - [('code', '=', name)] + args, limit=limit) - if recs: - return recs.name_get() - return super().name_search( - name=name, args=args, operator=operator, limit=limit) + ids = list(self._search([('code', '=', name)] + args, limit=limit)) + if ids: + return ids + return super()._name_search(name=name, args=args, operator=operator, limit=limit, name_get_uid=name_get_uid) diff --git a/base_dynamic_list/views/dynamic_list.xml b/base_dynamic_list/views/dynamic_list.xml index e3542af..5fbc42f 100644 --- a/base_dynamic_list/views/dynamic_list.xml +++ b/base_dynamic_list/views/dynamic_list.xml @@ -1,6 +1,6 @@