Skip to content
Snippets Groups Projects
Commit 16912d7b authored by Maruan Aguerdouh (magm)'s avatar Maruan Aguerdouh (magm)
Browse files

[FIX] web: remove properties from compatible import fields


Steps to reproduce:

- Install Knowledge App
- Create a sub-article and add them as many properties as you want.
- Go to search to get the list view and export the article, adding both
of the properties field (`article_properties`,
`article_properties_definition`).
- Now try to import the file we just exported.

At this moment this issue affects knowledge properties and crm, leads
properties (for reference see: #122817) but the proper fix is still not
applied, and since it's implementation is complicated we are going to
remove the properties from the export when we tick the
"I want to update data (import-compatible export)." until the proper fix
is done.

opw-3346642

closes odoo/odoo#131568

Signed-off-by: default avatarStéphane Debauche (std) <std@odoo.com>
parent 1b618b32
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ from unittest.mock import patch
from odoo import http
from odoo.tests import common, tagged
from odoo.tools.misc import get_lang
from odoo.addons.web.controllers.export import ExportXlsxWriter
from odoo.addons.web.controllers.export import ExportXlsxWriter, Export
from odoo.addons.mail.tests.common import mail_new_test_user
......@@ -391,3 +391,18 @@ class TestGroupedExport(XlsxCreatorCase):
[' 86420.864 (1)','86420.86'],
['1' ,'86420.86'],
])
@tagged('-at_install', 'post_install')
class TestExport(common.HttpCase):
def test_properties_type_fields_not_selectable_with_import_compat(self):
with patch.object(Export, 'fields_get', return_value={
'id': {'string': 'ID', 'type': 'integer'},
'name': {'string': 'Name', 'type': 'char'},
'properties': {'string': 'Properties', 'type': 'properties'},
'properties_definition': {'string': 'Properties Definition', 'type': 'properties_definition'}
}):
fields = Export().get_fields("mock_model", import_compat=True)
field_names = [field['id'] for field in fields]
self.assertNotIn('properties', field_names)
self.assertNotIn('properties_definition', field_names)
......@@ -331,6 +331,8 @@ class Export(http.Controller):
if import_compat and not field_name == 'id':
if exclude and field_name in exclude:
continue
if field.get('type') in ('properties', 'properties_definition'):
continue
if field.get('readonly'):
# If none of the field's states unsets readonly, skip the field
if all(dict(attrs).get('readonly', True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment