11# Copyright 2022 David Vidal
22# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
3+ from odoo .release import major_version
34import warnings
45
56from rich import box
@@ -311,7 +312,7 @@ def _show(
311312 name = "" ,
312313 fields = None ,
313314 view_id = None ,
314- view_type = "tree " ,
315+ view_type = "list " ,
315316 groupby = None ,
316317 partials = None ,
317318 ** extra ,
@@ -322,7 +323,7 @@ def _show(
322323 :param str name: Table name
323324 :param list fields: List of fields to render as columns, defaults to None
324325 :param int view_id: Default view id, defaults to None
325- :param str view_type: View type to take default fields form, defaults to "tree "
326+ :param str view_type: View type to take default fields form, defaults to "list "
326327 :param str groupby: Field name to group by records, defaults to None
327328 :param bool partials: Show operator partials when grouping, defaults to None
328329 :return rich.table: Rich Table Object
@@ -342,9 +343,16 @@ def _show(
342343 )
343344 # Compatibility with OdooRPC to access the object fields properties
344345 records_obj = records .env [records ._name ]
346+ # Ensure compatibility
347+ if major_version < "18.0" and view_type == "list" :
348+ view_type = "tree"
349+ if not fields and major_version >= "16.0" :
350+ fields = records_obj .get_view (
351+ view_id = view_id , view_type = view_type
352+ )["models" ][records_obj ._name ]
345353 if fields :
346354 fields = self ._get_field_attributes (fields , records_obj )
347- else :
355+ elif major_version < "16.0" :
348356 # Get fields from default tree view
349357 # Since v16 the method is deprecated. For the moment just silence warnings
350358 with warnings .catch_warnings ():
@@ -383,7 +391,7 @@ def show(
383391 records ,
384392 fields = None ,
385393 view_id = None ,
386- view_type = "tree " ,
394+ view_type = "list " ,
387395 groupby = None ,
388396 raw = None ,
389397 partials = None ,
@@ -394,7 +402,7 @@ def show(
394402 :param recordset records: Any Odoo recordset
395403 :param list fields: List of fields to render as columns, defaults to None
396404 :param int view_id: Default view id, defaults to None
397- :param str view_type: View type to take default fields form, defaults to "tree "
405+ :param str view_type: View type to take default fields form, defaults to "list "
398406 :param str groupby: Field name to group by records, defaults to None
399407 :param boolean raw: Return a `rich.table` object instead of render, defaults to None
400408 :param boolean partials: Show operator partials when grouping, defaults to None
0 commit comments