'Utility function to get a view combined with its inherited views.
* Gets the top of the view tree if a sub-view is requested
* Applies all inherited archs on the root view
* Returns the view with all requested fields
.. note:: ``arch`` is always added to the fields list even if not
requested (similar to ``id``)'

@api.multi
def read_combined(self, fields=None):

    if ('check_view_ids' not in self._context):
        self = self.with_context(check_view_ids=[])
    check_view_ids = self._context['check_view_ids']
    root = self
    while (root.mode != 'primary'):
        check_view_ids.append(root.id)
        root = root.inherit_id
    if fields:
        fields = list({'arch', 'model'}.union(fields))
    [view_data] = root.read(fields=fields)
    view_arch = etree.fromstring(view_data['arch'].encode('utf-8'))
    if (not root.inherit_id):
        arch_tree = view_arch
    else:
        parent_view = root.inherit_id.read_combined(fields=fields)
        arch_tree = etree.fromstring(parent_view['arch'])
        arch_tree = self.apply_inheritance_specs(arch_tree, view_arch, parent_view['id'])
    if self._context.get('inherit_branding'):
        arch_tree.attrib.update({'data-oe-model': 'ir.ui.view', 'data-oe-id': str(root.id), 'data-oe-field': 'arch'})
    arch = self.apply_view_inheritance(arch_tree, root.id, self.model)
    return dict(view_data, arch=etree.tostring(arch, encoding='utf-8'))
