From 718b0f8b63261e1312b5626d48de050b21a9dccf Mon Sep 17 00:00:00 2001
From: Martin Trigaux <mat@odoo.com>
Date: Tue, 2 Oct 2018 09:44:56 +0200
Subject: [PATCH] [FIX] models: display first external id onyl

In case the result matches two records (e.g. a model has one external id per
module inheriting it), the last was used.

Use the first only.

Fixes #27363
---
 odoo/models.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/odoo/models.py b/odoo/models.py
index c0e5aa8033a2..81621725a342 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -2954,7 +2954,8 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
         xml_data = dict((x['res_id'], x) for x in IrModelData.search_read([('model', '=', self._name),
                                                                            ('res_id', 'in', self.ids)],
                                                                           ['res_id', 'noupdate', 'module', 'name'],
-                                                                          order='id'))
+                                                                          order='id',
+                                                                          limit=1))
         for r in res:
             value = xml_data.get(r['id'], {})
             r['xmlid'] = '%(module)s.%(name)s' % value if value else False
-- 
GitLab