Ejemplo n.º 1
0
 def fields_view_get(self,
                     cr,
                     user,
                     view_id=None,
                     view_type='form',
                     context=None,
                     toolbar=False,
                     submenu=False):
     res = super(report_xml,
                 self).fields_view_get(cr, user, view_id, view_type,
                                       context, toolbar, submenu)
     if view_type == 'form':
         ##### Check deferred_processing module #####
         cr.execute(
             "SELECT id, state FROM ir_module_module WHERE name='deferred_processing'"
         )
         deferred_proc_module = cr.dictfetchone()
         if not (deferred_proc_module and deferred_proc_module['state']
                 in ('installed', 'to upgrade')):
             doc = etree.XML(res['arch'])
             deferred_node = doc.xpath("//field[@name='deferred']")
             if deferred_node:
                 modifiers = {'invisible': True}
                 transfer_modifiers_to_node(modifiers, deferred_node[0])
             deferred_limit_node = doc.xpath(
                 "//field[@name='deferred_limit']")
             if deferred_limit_node:
                 transfer_modifiers_to_node(modifiers,
                                            deferred_limit_node[0])
             res['arch'] = etree.tostring(doc)
         ############################################
     return res
 def postprocess(self, model, node, view_id, in_tree_view, model_fields):
     fields = super(IrUiView, self).postprocess(model, node, view_id,
                                                in_tree_view, model_fields)
     if node.tag == 'field':
         if self._check_hidden_field(model, node.get('name')):
             modifiers = json.loads(node.get('modifiers'))
             modifiers['invisible'] = True
             orm.transfer_modifiers_to_node(modifiers, node)
     return fields
Ejemplo n.º 3
0
 def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
     res = super(report_xml, self).fields_view_get(cr, user, view_id, view_type, context, toolbar, submenu)
     if view_type=='form':
         ##### Check deferred_processing module #####
         cr.execute("SELECT id, state FROM ir_module_module WHERE name='deferred_processing'")
         deferred_proc_module = cr.dictfetchone()
         if not (deferred_proc_module and deferred_proc_module['state'] in ('installed', 'to upgrade')):
             doc = etree.XML(res['arch'])
             deferred_node = doc.xpath("//field[@name='deferred']")
             modifiers = {'invisible': True}
             if deferred_node:
                 orm.transfer_modifiers_to_node(modifiers, deferred_node[0])
                 deferred_limit_node = doc.xpath("//field[@name='deferred_limit']")
                 orm.transfer_modifiers_to_node(modifiers, deferred_limit_node[0])
             res['arch'] = etree.tostring(doc)
         ############################################
     return res
Ejemplo n.º 4
0
 def fields_view_get(self, cr, uid, view_id=None, view_type='form',
                     context=None, toolbar=False, submenu=False):
     """ Allow managers to set an empy parent_id (a project)
     """
     fvg = super(Ticket, self).fields_view_get(
         cr, uid, view_id=view_id, view_type=view_type,
         context=context, toolbar=toolbar, submenu=submenu)
     if view_type == 'form' and fvg['type'] == 'form':
         access_obj = self.pool.get('ir.model.access')
         allow = (access_obj.check_groups(cr, uid, "anytracker.group_member")
                  or access_obj.check_groups(cr, uid, "anytracker.group_manager"))
         doc = etree.fromstring(fvg['arch'])
         try:
             node = doc.xpath("//field[@name='parent_id']")[0]
         except:
             logger.error("It seems you're using a broken version of OpenERP")
             return fvg
         orm.transfer_modifiers_to_node({'required': not allow}, node)
         fvg['arch'] = etree.tostring(doc)
     return fvg
Ejemplo n.º 5
0
 def fields_view_get(self, view_id=None, view_type='form',
                     toolbar=False, submenu=False):
     """ Allow managers to set an empy parent_id (a project)
     """
     fvg = super(Ticket, self).fields_view_get(
         view_id=view_id, view_type=view_type,
         toolbar=toolbar, submenu=submenu)
     if view_type == 'form' and fvg['type'] == 'form':
         ACCESS = self.env['ir.model.access']
         allow = (ACCESS.check_groups('anytracker.group_member')
                  or ACCESS.check_groups('anytracker.group_manager'))
         doc = etree.fromstring(fvg['arch'])
         try:
             node = doc.xpath("//field[@name='parent_id']")[0]
         except:
             logger.error("It seems you're using a broken version of Odoo")
             return fvg
         orm.transfer_modifiers_to_node({'required': not allow}, node)
         fvg['arch'] = etree.tostring(doc)
     return fvg
Ejemplo n.º 6
0
 def postprocess(self, model, node, view_id, in_tree_view, model_fields):
     res = super(IrUIView, self).postprocess(model, node, view_id,
                                             in_tree_view, model_fields)
     if node.tag == 'label' and node.get('for') and node.get('string'):
         mapping_field = self.env['bus.object.mapping.field'].search([
             ('model_id.model', '=', model),
             ('field_id.name', '=', node.get('for'))
         ])
         if mapping_field.mapping_id.is_exportable:
             node.set('string', u"⇐ %s" % node.get('string'))
         elif mapping_field.mapping_id.is_importable:
             node.set('string', u"⇒ %s" % node.get('string'))
         if mapping_field.mapping_id.is_importable and mapping_field.mapping_id.update_prohibited:
             orm.transfer_modifiers_to_node({'readonly': True}, node)
     if node.tag == 'field':
         if not node.attrib.get('invisible', False):
             mapping_field = self.env['bus.object.mapping.field'].search([
                 ('model_id.model', '=', model),
                 ('field_id.name', '=', node.get('name'))
             ])
             if mapping_field.mapping_id.is_importable and mapping_field.mapping_id.update_prohibited:
                 orm.transfer_modifiers_to_node({'readonly': True}, node)
     return res
Ejemplo n.º 7
0
 def fields_view_get(self,
                     view_id=None,
                     view_type='form',
                     toolbar=False,
                     submenu=False):
     if self.env.context.get('default_report_type') == 'aeroo':
         mda_mod = self.env['ir.model.data']
         if view_type == 'form':
             view_id = mda_mod.get_object_reference(
                 'report_aeroo', 'act_report_xml_view1')[1]
         elif view_type == 'tree':
             view_id = mda_mod.get_object_reference(
                 'report_aeroo', 'act_aeroo_report_xml_view_tree')[1]
     res = super(report_xml, self).fields_view_get(view_id,
                                                   view_type,
                                                   toolbar=toolbar,
                                                   submenu=submenu)
     if view_type == 'form' and self.env.context.get(
             'default_report_type') == 'aeroo':
         cr = self.env.cr
         ##### Check deferred_processing module #####
         cr.execute(
             "SELECT id, state FROM ir_module_module WHERE name='deferred_processing'"
         )
         deferred_proc_module = cr.dictfetchone()
         if not (deferred_proc_module and deferred_proc_module['state']
                 in ('installed', 'to upgrade')):
             doc = etree.XML(res['arch'])
             deferred_node = doc.xpath("//field[@name='deferred']")
             modifiers = {'invisible': True}
             transfer_modifiers_to_node(modifiers, deferred_node[0])
             deferred_limit_node = doc.xpath(
                 "//field[@name='deferred_limit']")
             transfer_modifiers_to_node(modifiers, deferred_limit_node[0])
             res['arch'] = etree.tostring(doc)
         ############################################
     return res
Ejemplo n.º 8
0
 def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
     if self.env.context.get('default_report_type')=='aeroo':
         mda_mod = self.env['ir.model.data']
         if view_type == 'form':
             view_id = mda_mod.get_object_reference('report_aeroo', 'act_report_xml_view1')[1]
         elif view_type == 'tree':
             view_id = mda_mod.get_object_reference('report_aeroo', 'act_aeroo_report_xml_view_tree')[1]
     res = super(report_xml, self).fields_view_get(view_id, view_type,
         toolbar=toolbar, submenu=submenu)
     if view_type=='form' and self.env.context.get('default_report_type')=='aeroo':
         cr = self.env.cr
         ##### Check deferred_processing module #####
         cr.execute("SELECT id, state FROM ir_module_module WHERE name='deferred_processing'")
         deferred_proc_module = cr.dictfetchone()
         if not (deferred_proc_module and deferred_proc_module['state'] in ('installed', 'to upgrade')):
             doc = etree.XML(res['arch'])
             deferred_node = doc.xpath("//field[@name='deferred']")
             modifiers = {'invisible': True}
             transfer_modifiers_to_node(modifiers, deferred_node[0])
             deferred_limit_node = doc.xpath("//field[@name='deferred_limit']")
             transfer_modifiers_to_node(modifiers, deferred_limit_node[0])
             res['arch'] = etree.tostring(doc)
         ############################################
     return res
Ejemplo n.º 9
0
    def postprocess(self, cr, user, model, node, view_id, in_tree_view, model_fields, context=None):
        """Return the description of the fields in the node.

        In a normal call to this method, node is a complete view architecture
        but it is actually possible to give some sub-node (this is used so
        that the method can call itself recursively).

        Originally, the field descriptions are drawn from the node itself.
        But there is now some code calling fields_get() in order to merge some
        of those information in the architecture.

        """
        if context is None:
            context = {}
        result = False
        fields = {}
        children = True

        modifiers = {}
        Model = self.pool.get(model)
        if not Model:
            self.raise_view_error(cr, user, _('Model not found: %(model)s') % dict(model=model),
                                  view_id, context)

        def encode(s):
            if isinstance(s, unicode):
                return s.encode('utf8')
            return s

        def check_group(node):
            """Apply group restrictions,  may be set at view level or model level::
               * at view level this means the element should be made invisible to
                 people who are not members
               * at model level (exclusively for fields, obviously), this means
                 the field should be completely removed from the view, as it is
                 completely unavailable for non-members

               :return: True if field should be included in the result of fields_view_get
            """
            if node.tag == 'field' and node.get('name') in Model._all_columns:
                column = Model._all_columns[node.get('name')].column
                if column.groups and not self.user_has_groups(
                        cr, user, groups=column.groups, context=context):
                    node.getparent().remove(node)
                    fields.pop(node.get('name'), None)
                    # no point processing view-level ``groups`` anymore, return
                    return False
            if node.get('groups'):
                can_see = self.user_has_groups(
                    cr, user, groups=node.get('groups'), context=context)
                if not can_see:
                    node.set('invisible', '1')
                    modifiers['invisible'] = True
                    if 'attrs' in node.attrib:
                        del(node.attrib['attrs']) #avoid making field visible later
                del(node.attrib['groups'])
            return True

        if node.tag in ('field', 'node', 'arrow'):
            if node.get('object'):
                attrs = {}
                views = {}
                xml = "<form>"
                for f in node:
                    if f.tag == 'field':
                        xml += etree.tostring(f, encoding="utf-8")
                xml += "</form>"
                new_xml = etree.fromstring(encode(xml))
                ctx = context.copy()
                ctx['base_model_name'] = model
                xarch, xfields = self.postprocess_and_fields(cr, user, node.get('object'), new_xml, view_id, ctx)
                views['form'] = {
                    'arch': xarch,
                    'fields': xfields
                }
                attrs = {'views': views}
                fields = xfields
            if node.get('name'):
                attrs = {}
                try:
                    if node.get('name') in Model._columns:
                        column = Model._columns[node.get('name')]
                    else:
                        column = Model._inherit_fields[node.get('name')][2]
                except Exception:
                    column = False

                if column:
                    children = False
                    views = {}
                    for f in node:
                        if f.tag in ('form', 'tree', 'graph', 'kanban', 'calendar'):
                            node.remove(f)
                            ctx = context.copy()
                            ctx['base_model_name'] = model
                            xarch, xfields = self.postprocess_and_fields(cr, user, column._obj or None, f, view_id, ctx)
                            views[str(f.tag)] = {
                                'arch': xarch,
                                'fields': xfields
                            }
                    attrs = {'views': views}
                fields[node.get('name')] = attrs

                field = model_fields.get(node.get('name'))
                if field:
                    orm.transfer_field_to_modifiers(field, modifiers)

        elif node.tag in ('form', 'tree'):
            result = Model.view_header_get(cr, user, False, node.tag, context)
            if result:
                node.set('string', result)
            in_tree_view = node.tag == 'tree'

        elif node.tag == 'calendar':
            for additional_field in ('date_start', 'date_delay', 'date_stop', 'color', 'all_day', 'attendee'):
                if node.get(additional_field):
                    fields[node.get(additional_field)] = {}

        if not check_group(node):
            # node must be removed, no need to proceed further with its children
            return fields

        # The view architeture overrides the python model.
        # Get the attrs before they are (possibly) deleted by check_group below
        orm.transfer_node_to_modifiers(node, modifiers, context, in_tree_view)

        # TODO remove attrs counterpart in modifiers when invisible is true ?

        # translate view
        if 'lang' in context:
            Translations = self.pool['ir.translation']
            if node.text and node.text.strip():
                trans = Translations._get_source(cr, user, model, 'view', context['lang'], node.text.strip())
                if trans:
                    node.text = node.text.replace(node.text.strip(), trans)
            if node.tail and node.tail.strip():
                trans = Translations._get_source(cr, user, model, 'view', context['lang'], node.tail.strip())
                if trans:
                    node.tail =  node.tail.replace(node.tail.strip(), trans)

            if node.get('string') and not result:
                trans = Translations._get_source(cr, user, model, 'view', context['lang'], node.get('string'))
                if trans == node.get('string') and ('base_model_name' in context):
                    # If translation is same as source, perhaps we'd have more luck with the alternative model name
                    # (in case we are in a mixed situation, such as an inherited view where parent_view.model != model
                    trans = Translations._get_source(cr, user, context['base_model_name'], 'view', context['lang'], node.get('string'))
                if trans:
                    node.set('string', trans)

            for attr_name in ('confirm', 'sum', 'avg', 'help', 'placeholder'):
                attr_value = node.get(attr_name)
                if attr_value:
                    trans = Translations._get_source(cr, user, model, 'view', context['lang'], attr_value)
                    if trans:
                        node.set(attr_name, trans)

        for f in node:
            if children or (node.tag == 'field' and f.tag in ('filter','separator')):
                fields.update(self.postprocess(cr, user, model, f, view_id, in_tree_view, model_fields, context))

        orm.transfer_modifiers_to_node(modifiers, node)
        return fields
Ejemplo n.º 10
0
    def postprocess(self, cr, user, model, node, view_id, in_tree_view, model_fields, context=None):
        """Return the description of the fields in the node.

        In a normal call to this method, node is a complete view architecture
        but it is actually possible to give some sub-node (this is used so
        that the method can call itself recursively).

        Originally, the field descriptions are drawn from the node itself.
        But there is now some code calling fields_get() in order to merge some
        of those information in the architecture.

        """
        if context is None:
            context = {}
        result = False
        fields = {}
        children = True

        modifiers = {}
        Model = self.pool.get(model)
        if not Model:
            self.raise_view_error(cr, user, _('Model not found: %(model)s') % dict(model=model),
                                  view_id, context)

        def encode(s):
            if isinstance(s, unicode):
                return s.encode('utf8')
            return s

        def check_group(node):
            """Apply group restrictions,  may be set at view level or model level::
               * at view level this means the element should be made invisible to
                 people who are not members
               * at model level (exclusively for fields, obviously), this means
                 the field should be completely removed from the view, as it is
                 completely unavailable for non-members

               :return: True if field should be included in the result of fields_view_get
            """
            if node.tag == 'field' and node.get('name') in Model._all_columns:
                column = Model._all_columns[node.get('name')].column
                if column.groups and not self.user_has_groups(
                        cr, user, groups=column.groups, context=context):
                    node.getparent().remove(node)
                    fields.pop(node.get('name'), None)
                    # no point processing view-level ``groups`` anymore, return
                    return False
            if node.get('groups'):
                can_see = self.user_has_groups(
                    cr, user, groups=node.get('groups'), context=context)
                if not can_see:
                    node.set('invisible', '1')
                    modifiers['invisible'] = True
                    if 'attrs' in node.attrib:
                        del(node.attrib['attrs']) #avoid making field visible later
                del(node.attrib['groups'])
            return True

        if node.tag in ('field', 'node', 'arrow'):
            if node.get('object'):
                attrs = {}
                views = {}
                xml = "<form>"
                for f in node:
                    if f.tag == 'field':
                        xml += etree.tostring(f, encoding="utf-8")
                xml += "</form>"
                new_xml = etree.fromstring(encode(xml))
                ctx = context.copy()
                ctx['base_model_name'] = model
                xarch, xfields = self.postprocess_and_fields(cr, user, node.get('object'), new_xml, view_id, ctx)
                views['form'] = {
                    'arch': xarch,
                    'fields': xfields
                }
                attrs = {'views': views}
                fields = xfields
            if node.get('name'):
                attrs = {}
                try:
                    if node.get('name') in Model._columns:
                        column = Model._columns[node.get('name')]
                    else:
                        column = Model._inherit_fields[node.get('name')][2]
                except Exception:
                    column = False

                if column:
                    children = False
                    views = {}
                    for f in node:
                        if f.tag in ('form', 'tree', 'graph', 'kanban', 'calendar'):
                            node.remove(f)
                            ctx = context.copy()
                            ctx['base_model_name'] = model
                            xarch, xfields = self.postprocess_and_fields(cr, user, column._obj or None, f, view_id, ctx)
                            views[str(f.tag)] = {
                                'arch': xarch,
                                'fields': xfields
                            }
                    attrs = {'views': views}
                fields[node.get('name')] = attrs

                field = model_fields.get(node.get('name'))
                if field:
                    orm.transfer_field_to_modifiers(field, modifiers)

        elif node.tag in ('form', 'tree'):
            result = Model.view_header_get(cr, user, False, node.tag, context)
            if result:
                node.set('string', result)
            in_tree_view = node.tag == 'tree'

        elif node.tag == 'calendar':
            for additional_field in ('date_start', 'date_delay', 'date_stop', 'color', 'all_day', 'attendee'):
                if node.get(additional_field):
                    fields[node.get(additional_field)] = {}

        if not check_group(node):
            # node must be removed, no need to proceed further with its children
            return fields

        # The view architeture overrides the python model.
        # Get the attrs before they are (possibly) deleted by check_group below
        orm.transfer_node_to_modifiers(node, modifiers, context, in_tree_view)

        # TODO remove attrs counterpart in modifiers when invisible is true ?

        # translate view
        if 'lang' in context:
            Translations = self.pool['ir.translation']
            if node.text and node.text.strip():
                trans = Translations._get_source(cr, user, model, 'view', context['lang'], node.text.strip())
                if trans:
                    node.text = node.text.replace(node.text.strip(), trans)
            if node.tail and node.tail.strip():
                trans = Translations._get_source(cr, user, model, 'view', context['lang'], node.tail.strip())
                if trans:
                    node.tail =  node.tail.replace(node.tail.strip(), trans)

            if node.get('string') and not result:
                trans = Translations._get_source(cr, user, model, 'view', context['lang'], node.get('string'))
                if trans == node.get('string') and ('base_model_name' in context):
                    # If translation is same as source, perhaps we'd have more luck with the alternative model name
                    # (in case we are in a mixed situation, such as an inherited view where parent_view.model != model
                    trans = Translations._get_source(cr, user, context['base_model_name'], 'view', context['lang'], node.get('string'))
                if trans:
                    node.set('string', trans)

            for attr_name in ('confirm', 'sum', 'avg', 'help', 'placeholder'):
                attr_value = node.get(attr_name)
                if attr_value:
                    trans = Translations._get_source(cr, user, model, 'view', context['lang'], attr_value)
                    if trans:
                        node.set(attr_name, trans)

        for f in node:
            if children or (node.tag == 'field' and f.tag in ('filter','separator')):
                fields.update(self.postprocess(cr, user, model, f, view_id, in_tree_view, model_fields, context))

        orm.transfer_modifiers_to_node(modifiers, node)
        return fields
Ejemplo n.º 11
0
    def postprocess(self,
                    cr,
                    user,
                    model,
                    node,
                    view_id,
                    in_tree_view,
                    model_fields,
                    context=None):
        """Return the description of the fields in the node.

        In a normal call to this method, node is a complete view architecture
        but it is actually possible to give some sub-node (this is used so
        that the method can call itself recursively).

        Originally, the field descriptions are drawn from the node itself.
        But there is now some code calling fields_get() in order to merge some
        of those information in the architecture.

        """

        if context is None:
            context = {}
        result = False
        fields = {}
        children = True

        modifiers = {}
        Model = self.pool.get(model)
        if Model is None:
            self.raise_view_error(
                cr, user,
                _('Model not found: %(model)s') % dict(model=model), view_id,
                context)

        def encode(s):
            if isinstance(s, unicode):
                return s.encode('utf8')
            return s

        def check_group(node):
            """Apply group restrictions,  may be set at view level or model level::
               * at view level this means the element should be made invisible to
                 people who are not members
               * at model level (exclusively for fields, obviously), this means
                 the field should be completely removed from the view, as it is
                 completely unavailable for non-members

               :return: True if field should be included in the result of fields_view_get
            """

            if node.tag == 'field' and node.get('name') in Model._fields:
                field = Model._fields[node.get('name')]
                # Apply field level access-rights
                field_obj = self.pool.get('ir.model.fields')
                field_ids = field_obj.search_read(
                    cr, user, [('name', '=', node.get('name')),
                               ('model', '=', Model._name)])  # Search field
                if field_ids:
                    field_ids = field_ids[0]
                    invisible_groups = field_ids.get('invisible_groups')
                    read_only_groups = field_ids.get('read_only_groups')
                    same_field_flag = True
                    if invisible_groups:  # Apply invisible on field based on groups
                        cr.execute(
                            """SELECT 1 FROM res_groups_users_rel WHERE uid=%s AND gid IN %s""",
                            (user, tuple(invisible_groups)))
                        if bool(cr.fetchone()):
                            node.set('invisible', '1')
                            modifiers['invisible'] = True
                            # Remove attrs for conditional visible/invisible (DOMAIN) issue.
                            if 'attrs' in node.attrib:
                                del (node.attrib['attrs'])
                            # Remove widget that is call external view/template and we are not able to apply restriction on other view/template becuase we apply restriction only on fields.
                            if 'widget' in node.attrib:
                                del (node.attrib['widget'])
                            same_field_flag = False
                    # If field have a any invisible group than no need to check read only group or apply read only attribute on field.
                    if read_only_groups and same_field_flag:  # Apply readonly on field based on groups
                        cr.execute(
                            """SELECT 1 FROM res_groups_users_rel WHERE uid=%s AND gid IN %s""",
                            (user, tuple(read_only_groups)))
                        if bool(cr.fetchone()):
                            node.set('readonly', '1')
                            if 'attrs' in node.attrib:
                                attrs = eval(node.attrib['attrs'])
                                if attrs.get('invisible', False):
                                    # For read only attribute, remove other attributes like required that gives warning in case of none value.
                                    node.attrib['attrs'] = str(
                                        {'invisible': attrs['invisible']})
                if field.groups and not self.user_has_groups(
                        cr, user, groups=field.groups, context=context):
                    node.getparent().remove(node)
                    fields.pop(node.get('name'), None)
                    # no point processing view-level ``groups`` anymore, return
                    return False

            if node.get('groups'):

                can_see = self.user_has_groups(cr,
                                               user,
                                               groups=node.get('groups'),
                                               context=context)
                if not can_see:
                    node.set('invisible', '1')
                    modifiers['invisible'] = True
                    if 'attrs' in node.attrib:
                        del (node.attrib['attrs']
                             )  # avoid making field visible later
                del (node.attrib['groups'])
            return True

        if node.tag in ('field', 'node', 'arrow'):
            if node.get('object'):
                attrs = {}
                views = {}
                xml = "<form>"
                for f in node:
                    if f.tag == 'field':
                        xml += etree.tostring(f, encoding="utf-8")
                xml += "</form>"
                new_xml = etree.fromstring(encode(xml))
                ctx = context.copy()
                ctx['base_model_name'] = model
                xarch, xfields = self.postprocess_and_fields(
                    cr, user, node.get('object'), new_xml, view_id, ctx)
                views['form'] = {'arch': xarch, 'fields': xfields}
                attrs = {'views': views}
                fields = xfields
            if node.get('name'):
                attrs = {}
                field = Model._fields.get(node.get('name'))
                if field:
                    children = False
                    views = {}
                    for f in node:
                        if f.tag in ('form', 'tree', 'graph', 'kanban',
                                     'calendar'):
                            node.remove(f)
                            ctx = context.copy()
                            ctx['base_model_name'] = model
                            xarch, xfields = self.postprocess_and_fields(
                                cr, user, field.comodel_name, f, view_id, ctx)
                            views[str(f.tag)] = {
                                'arch': xarch,
                                'fields': xfields
                            }
                    attrs = {'views': views}
                fields[node.get('name')] = attrs

                field = model_fields.get(node.get('name'))
                if field:
                    orm.transfer_field_to_modifiers(field, modifiers)

        elif node.tag in ('form', 'tree'):
            result = Model.view_header_get(cr, user, False, node.tag, context)
            if result:
                node.set('string', result)
            in_tree_view = node.tag == 'tree'

        elif node.tag == 'calendar':
            for additional_field in ('date_start', 'date_delay', 'date_stop',
                                     'color', 'all_day', 'attendee'):
                if node.get(additional_field):
                    fields[node.get(additional_field)] = {}

        if not check_group(node):
            # node must be removed, no need to proceed further with its children
            return fields

        # The view architeture overrides the python model.
        # Get the attrs before they are (possibly) deleted by check_group below
        orm.transfer_node_to_modifiers(node, modifiers, context, in_tree_view)

        # TODO remove attrs counterpart in modifiers when invisible is true ?

        # translate view
        if 'lang' in context:
            Translations = self.pool['ir.translation']
            if node.text and node.text.strip():
                term = node.text.strip()
                trans = Translations._get_source(cr, user, model, 'view',
                                                 context['lang'], term)
                if trans:
                    node.text = node.text.replace(term, trans)
            if node.tail and node.tail.strip():
                term = node.tail.strip()
                trans = Translations._get_source(cr, user, model, 'view',
                                                 context['lang'], term)
                if trans:
                    node.tail = node.tail.replace(term, trans)

            if node.get('string') and node.get(
                    'string').strip() and not result:
                term = node.get('string').strip()
                trans = Translations._get_source(cr, user, model, 'view',
                                                 context['lang'], term)
                if trans == term and ('base_model_name' in context):
                    # If translation is same as source, perhaps we'd have more luck with the alternative model name
                    # (in case we are in a mixed situation, such as an inherited view where parent_view.model != model
                    trans = Translations._get_source(
                        cr, user, context['base_model_name'], 'view',
                        context['lang'], term)
                if trans:
                    node.set('string', trans)

            for attr_name in ('confirm', 'sum', 'avg', 'help', 'placeholder'):
                attr_value = node.get(attr_name)
                if attr_value and attr_value.strip():
                    trans = Translations._get_source(cr, user, model, 'view',
                                                     context['lang'],
                                                     attr_value.strip())
                    if trans:
                        node.set(attr_name, trans)

        for f in node:
            if children or (node.tag == 'field'
                            and f.tag in ('filter', 'separator')):
                fields.update(
                    self.postprocess(cr, user, model, f, view_id, in_tree_view,
                                     model_fields, context))
        orm.transfer_modifiers_to_node(modifiers, node)
        return fields