[REF] extract the two inlined default view generators left into fields_view_get into their own methods
follow the preexisting __get_default_$name_view bzr revid: xmo@openerp.com-20110915111221-20ktl1bi2qne5wz7
This commit is contained in:
parent
8a9c0dbad7
commit
734c1a43a0
|
@ -1689,6 +1689,28 @@ class orm_template(object):
|
||||||
raise except_orm('View error', msg)
|
raise except_orm('View error', msg)
|
||||||
return arch, fields
|
return arch, fields
|
||||||
|
|
||||||
|
def __get_default_form_view(self, cr, user, context=None):
|
||||||
|
# TODO it seems fields_get can be replaced by _all_columns (no need for translation)
|
||||||
|
res = self.fields_get(cr, user, context=context)
|
||||||
|
xml = '<?xml version="1.0" encoding="utf-8"?> ' \
|
||||||
|
'<form string="%s">' % (self._description,)
|
||||||
|
for x in res:
|
||||||
|
if res[x]['type'] not in ('one2many', 'many2many'):
|
||||||
|
xml += '<field name="%s"/>' % (x,)
|
||||||
|
if res[x]['type'] == 'text':
|
||||||
|
xml += "<newline/>"
|
||||||
|
xml += "</form>"
|
||||||
|
return xml
|
||||||
|
|
||||||
|
def __get_default_tree_view(self, cr, user, context=None):
|
||||||
|
_rec_name = self._rec_name
|
||||||
|
if _rec_name not in self._columns:
|
||||||
|
_rec_name = self._columns.keys()[0]
|
||||||
|
xml = '<?xml version="1.0" encoding="utf-8"?>' \
|
||||||
|
'<tree string="%s"><field name="%s"/></tree>' \
|
||||||
|
% (self._description, _rec_name)
|
||||||
|
return xml
|
||||||
|
|
||||||
def __get_default_calendar_view(self):
|
def __get_default_calendar_view(self):
|
||||||
"""Generate a default calendar view (For internal use only).
|
"""Generate a default calendar view (For internal use only).
|
||||||
"""
|
"""
|
||||||
|
@ -1965,24 +1987,10 @@ class orm_template(object):
|
||||||
|
|
||||||
# otherwise, build some kind of default view
|
# otherwise, build some kind of default view
|
||||||
if view_type == 'form':
|
if view_type == 'form':
|
||||||
# TODO it seems fields_get can be replaced by _all_columns (no need for translation)
|
xml = self.__get_default_form_view(cr, user, context)
|
||||||
res = self.fields_get(cr, user, context=context)
|
|
||||||
xml = '<?xml version="1.0" encoding="utf-8"?> ' \
|
|
||||||
'<form string="%s">' % (self._description,)
|
|
||||||
for x in res:
|
|
||||||
if res[x]['type'] not in ('one2many', 'many2many'):
|
|
||||||
xml += '<field name="%s"/>' % (x,)
|
|
||||||
if res[x]['type'] == 'text':
|
|
||||||
xml += "<newline/>"
|
|
||||||
xml += "</form>"
|
|
||||||
|
|
||||||
elif view_type == 'tree':
|
elif view_type == 'tree':
|
||||||
_rec_name = self._rec_name
|
xml = self.__get_default_tree_view(cr, user, context)
|
||||||
if _rec_name not in self._columns:
|
|
||||||
_rec_name = self._columns.keys()[0]
|
|
||||||
xml = '<?xml version="1.0" encoding="utf-8"?>' \
|
|
||||||
'<tree string="%s"><field name="%s"/></tree>' \
|
|
||||||
% (self._description, _rec_name)
|
|
||||||
|
|
||||||
elif view_type == 'calendar':
|
elif view_type == 'calendar':
|
||||||
xml = self.__get_default_calendar_view()
|
xml = self.__get_default_calendar_view()
|
||||||
|
|
Loading…
Reference in New Issue