From 2d296cb77922d33be2dc45b900191fac34bda429 Mon Sep 17 00:00:00 2001
From: Antony Lesuisse <al@openerp.com>
Date: Sun, 31 Aug 2014 16:56:44 +0200
Subject: [PATCH] [MERGE] ir-ui-view split active and show_customize

Split the ternary field application in active and show_customize, all four
possible value are now needed for the customize theme popup.
---
 addons/report_webkit/convert.py               |  2 +-
 addons/website/controllers/main.py            | 15 ++++----
 addons/website/models/ir_ui_view.py           | 11 +++---
 addons/website/views/themes.xml               | 24 ++++++------
 addons/website/views/website_templates.xml    |  6 +--
 .../views/website_blog_templates.xml          | 24 ++++++------
 addons/website_crm/views/website_crm.xml      |  4 +-
 .../views/website_crm_partner_assign.xml      |  2 +-
 .../views/website_customer.xml                |  4 +-
 addons/website_event/views/website_event.xml  | 12 +++---
 .../views/website_event_sale.xml              |  2 +-
 .../views/website_event.xml                   |  6 +--
 addons/website_hr/views/website_hr.xml        |  2 +-
 .../views/templates.xml                       |  6 +--
 .../views/website_membership.xml              |  4 +-
 .../website_quote/views/website_quotation.xml |  6 +--
 addons/website_sale/views/templates.xml       | 26 ++++++-------
 openerp/addons/base/ir/ir_ui_view.py          | 30 ++++-----------
 openerp/addons/base/ir/ir_ui_view_view.xml    |  5 ++-
 openerp/addons/base/tests/test_views.py       | 16 ++++----
 openerp/import_xml.rng                        | 10 +----
 openerp/tools/convert.py                      | 37 +++++++++++--------
 22 files changed, 120 insertions(+), 134 deletions(-)

diff --git a/addons/report_webkit/convert.py b/addons/report_webkit/convert.py
index e30209a77dc5..bfc1100c3ad1 100644
--- a/addons/report_webkit/convert.py
+++ b/addons/report_webkit/convert.py
@@ -41,7 +41,7 @@ class WebkitXMLImport(original_xml_import):
     # The solution is not meant to be long term solution, but at least
     # allows chaining of several overrides of the _tag_report method,
     # and does not require a copy/paste of the original code.
-    def _tag_report(self, cr, rec, data_node=None):
+    def _tag_report(self, cr, rec, data_node=None, mode=None):
         report_id = super(WebkitXMLImport, self)._tag_report(cr, rec, data_node)
         if rec.get('report_type') == 'webkit':
             header = rec.get('webkit_header')
diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py
index 11fed713fbd3..d5d9b7582e55 100644
--- a/addons/website/controllers/main.py
+++ b/addons/website/controllers/main.py
@@ -186,19 +186,18 @@ class Website(openerp.addons.web.controllers.main.Home):
             request.cr, request.uid, 'website', 'theme')
         views = Views.search(request.cr, request.uid, [
             ('inherit_id', '=', theme_template_id),
-            ('application', '=', 'enabled'),
         ], context=request.context)
         Views.write(request.cr, request.uid, views, {
-            'application': 'disabled',
-        }, context=request.context)
+            'active': False,
+        }, context=dict(request.context or {}, active_test=True))
 
         if theme_id:
             module, xml_id = theme_id.split('.')
             _, view_id = imd.get_object_reference(
                 request.cr, request.uid, module, xml_id)
             Views.write(request.cr, request.uid, [view_id], {
-                'application': 'enabled'
-            }, context=request.context)
+                'active': True
+            }, context=dict(request.context or {}, active_test=True))
 
         return request.render('website.themes', {'theme_changed': True})
 
@@ -242,13 +241,13 @@ class Website(openerp.addons.web.controllers.main.Home):
         user_groups = set(user.groups_id)
 
         views = request.registry["ir.ui.view"]\
-            ._views_get(request.cr, request.uid, xml_id, context=request.context)
+            ._views_get(request.cr, request.uid, xml_id, context=dict(request.context or {}, active_test=False))
         done = set()
         result = []
         for v in views:
             if not user_groups.issuperset(v.groups_id):
                 continue
-            if full or (v.application != 'always' and v.inherit_id.id != view_theme_id):
+            if full or (v.customize_show and v.inherit_id.id != view_theme_id):
                 if v.inherit_id not in done:
                     result.append({
                         'name': v.inherit_id.name,
@@ -265,7 +264,7 @@ class Website(openerp.addons.web.controllers.main.Home):
                     'xml_id': v.xml_id,
                     'inherit_id': v.inherit_id.id,
                     'header': False,
-                    'active': v.application in ('always', 'enabled'),
+                    'active': v.active,
                 })
         return result
 
diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py
index 9c7ec56d1865..da9de182eb83 100644
--- a/addons/website/models/ir_ui_view.py
+++ b/addons/website/models/ir_ui_view.py
@@ -1,8 +1,5 @@
 # -*- coding: utf-8 -*-
 import copy
-import re
-import simplejson
-import werkzeug
 
 from lxml import etree, html
 
@@ -18,9 +15,11 @@ class view(osv.osv):
         'website_meta_title': fields.char("Website meta title", size=70, translate=True),
         'website_meta_description': fields.text("Website meta description", size=160, translate=True),
         'website_meta_keywords': fields.char("Website meta keywords", translate=True),
+        'customize_show': fields.boolean("Show As Optional Inherit"),
     }
     _defaults = {
         'page': False,
+        'customize_show': False,
     }
 
 
@@ -68,15 +67,14 @@ class view(osv.osv):
         extensions = view.inherit_children_ids
         if not options:
             # only active children
-            extensions = (v for v in view.inherit_children_ids
-                          if v.application in ('always', 'enabled'))
+            extensions = (v for v in view.inherit_children_ids if v.active)
 
         # Keep options in a deterministic order regardless of their applicability
         for extension in sorted(extensions, key=lambda v: v.id):
             for r in self._views_get(
                     cr, uid, extension,
                     # only return optional grandchildren if this child is enabled
-                    options=extension.application in ('always', 'enabled'),
+                    options=extension.active,
                     context=context, root=False):
                 if r not in result:
                     result.append(r)
@@ -214,3 +212,4 @@ class view(osv.osv):
         view = self.browse(cr, SUPERUSER_ID, res_id, context=context)
         if view.model_data_id:
             view.model_data_id.write({'noupdate': True})
+
diff --git a/addons/website/views/themes.xml b/addons/website/views/themes.xml
index a24081332072..bfa0bd2e4b59 100644
--- a/addons/website/views/themes.xml
+++ b/addons/website/views/themes.xml
@@ -203,82 +203,82 @@
      All Default Themes
 -->
 
-    <template id="website.theme_amelia" name="Amelia" inherit_id="website.theme" optional="disabled">
+    <template id="website.theme_amelia" name="Amelia" inherit_id="website.theme" active="False" customize_show="True">
         <xpath expr="//link[@id='bootstrap_css']" position="replace">
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/amelia.min.css' t-ignore="true"/>
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/amelia.fix.css' t-ignore="true"/>
         </xpath>
     </template>
 
-    <template id="website.theme_cerulean" name="Cerulean" inherit_id="website.theme" optional="disabled">
+    <template id="website.theme_cerulean" name="Cerulean" inherit_id="website.theme" active="False" customize_show="True">
         <xpath expr="//link[@id='bootstrap_css']" position="replace">
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/cerulean.min.css' t-ignore="true"/>
         </xpath>
     </template>
 
-    <template id="website.theme_cosmo" name="Cosmo" inherit_id="website.theme" optional="disabled">
+    <template id="website.theme_cosmo" name="Cosmo" inherit_id="website.theme" active="False" customize_show="True">
         <xpath expr="//link[@id='bootstrap_css']" position="replace">
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/cosmo.min.css' t-ignore="true"/>
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/cosmo.fix.css' t-ignore="true"/>
         </xpath>
     </template>
 
-    <template id="website.theme_cyborg" name="Cyborg" inherit_id="website.theme" optional="disabled">
+    <template id="website.theme_cyborg" name="Cyborg" inherit_id="website.theme" active="False" customize_show="True">
         <xpath expr="//link[@id='bootstrap_css']" position="replace">
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/cyborg.min.css' t-ignore="true"/>
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/cyborg.fix.css' t-ignore="true"/>
         </xpath>
     </template>
 
-    <template id="website.theme_flatly" name="Flatly" inherit_id="website.theme" optional="disabled">
+    <template id="website.theme_flatly" name="Flatly" inherit_id="website.theme" active="False" customize_show="True">
         <xpath expr="//link[@id='bootstrap_css']" position="replace">
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/flatly.min.css' t-ignore="true"/>
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/flatly.fix.css' t-ignore="true"/>
         </xpath>
     </template>
 
-    <template id="website.theme_journal" name="Journal" inherit_id="website.theme" optional="disabled">
+    <template id="website.theme_journal" name="Journal" inherit_id="website.theme" active="False" customize_show="True">
         <xpath expr="//link[@id='bootstrap_css']" position="replace">
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/journal.min.css' t-ignore="true"/>
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/journal.fix.css' t-ignore="true"/>
         </xpath>
     </template>
 
-    <template id="website.theme_readable" name="Readable" inherit_id="website.theme" optional="disabled">
+    <template id="website.theme_readable" name="Readable" inherit_id="website.theme" active="False" customize_show="True">
         <xpath expr="//link[@id='bootstrap_css']" position="replace">
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/readable.min.css' t-ignore="true"/>
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/readable.fix.css' t-ignore="true"/>
         </xpath>
     </template>
 
-    <template id="website.theme_simplex" name="Simplex" inherit_id="website.theme" optional="disabled">
+    <template id="website.theme_simplex" name="Simplex" inherit_id="website.theme" active="False" customize_show="True">
         <xpath expr="//link[@id='bootstrap_css']" position="replace">
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/simplex.min.css' t-ignore="true"/>
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/simplex.fix.css' t-ignore="true"/>
         </xpath>
     </template>
 
-    <template id="website.theme_slate" name="Slate" inherit_id="website.theme" optional="disabled">
+    <template id="website.theme_slate" name="Slate" inherit_id="website.theme" active="False" customize_show="True">
         <xpath expr="//link[@id='bootstrap_css']" position="replace">
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/slate.min.css' t-ignore="true"/>
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/slate.fix.css' t-ignore="true"/>
         </xpath>
     </template>
 
-    <template id="website.theme_spacelab" name="Spacelab" inherit_id="website.theme" optional="disabled">
+    <template id="website.theme_spacelab" name="Spacelab" inherit_id="website.theme" active="False" customize_show="True">
         <xpath expr="//link[@id='bootstrap_css']" position="replace">
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/spacelab.min.css' t-ignore="true"/>
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/spacelab.fix.css' t-ignore="true"/>
         </xpath>
     </template>
 
-    <template id="website.theme_united" name="United" inherit_id="website.theme" optional="disabled">
+    <template id="website.theme_united" name="United" inherit_id="website.theme" active="False" customize_show="True">
         <xpath expr="//link[@id='bootstrap_css']" position="replace">
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/united.min.css' t-ignore="true"/>
         </xpath>
     </template>
 
-    <template id="website.theme_yeti" name="Yeti" inherit_id="website.theme" optional="disabled">
+    <template id="website.theme_yeti" name="Yeti" inherit_id="website.theme" active="False" customize_show="True">
         <xpath expr="//link[@id='bootstrap_css']" position="replace">
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/yeti.min.css' t-ignore="true"/>
             <link rel='stylesheet' href='/website/static/src/css/bootswatch/yeti.fix.css' t-ignore="true"/>
diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml
index 96c85b25cde5..7921b783d4f0 100644
--- a/addons/website/views/website_templates.xml
+++ b/addons/website/views/website_templates.xml
@@ -169,7 +169,7 @@
     </xpath>
 </template>
 
-<template id="layout_logo_show" inherit_id="website.layout" optional="enabled" name="Show Logo">
+<template id="layout_logo_show" inherit_id="website.layout" customize_show="True" name="Show Logo">
     <xpath expr="//header//a[@class='navbar-brand']" position="replace">
         <a href="/" class="navbar-brand logo">
             <img src="/logo.png"/>
@@ -230,7 +230,7 @@
     </xpath>
 </template>
 
-<template id="show_sign_in" optional="enabled" inherit_id="website.layout" name="Show Sign In" groups="base.group_public">
+<template id="show_sign_in" customize_show="True" inherit_id="website.layout" name="Show Sign In" groups="base.group_public">
     <xpath expr="//ul[@id='top_menu']" position="inside">
         <li class="divider"/>
         <li>
@@ -272,7 +272,7 @@
     </xpath>
 </template>
 
-<template id="footer_default" inherit_id="website.footer_custom" optional="enabled" name="Automatic Footer">
+<template id="footer_default" inherit_id="website.footer_custom" customize_show="True" name="Automatic Footer">
     <xpath expr="//div[@id='footer']" position="replace">
         <div class="container hidden-print">
             <div class="row">
diff --git a/addons/website_blog/views/website_blog_templates.xml b/addons/website_blog/views/website_blog_templates.xml
index f1bea774bf09..e7f47113c7b6 100644
--- a/addons/website_blog/views/website_blog_templates.xml
+++ b/addons/website_blog/views/website_blog_templates.xml
@@ -161,7 +161,7 @@
 
 <!-- Option: Blog Post List: show tags -->
 <template id="opt_blog_post_short_tags" name="Tags"
-        optional="enabled" inherit_id="website_blog.blog_post_short">
+        customize_show="True" inherit_id="website_blog.blog_post_short">
     <xpath expr="//div[@name='blog_post_data']" position="inside">
         <p class="post-meta text-muted text-center" t-if="len(blog_post.tag_ids)">
             <span class="fa fa-tags"/>
@@ -265,7 +265,7 @@
 
 <!-- Options: Blog Post: breadcrumb -->
 <template id="blog_breadcrumb" name="Breadcrumb"
-        inherit_id="website_blog.blog_post_complete" optional="disabled">
+        inherit_id="website_blog.blog_post_complete" active="False" customize_show="True">
     <xpath expr="//div[@id='title']" position="before">
         <div class="container">
           <div class="row">
@@ -285,7 +285,7 @@
 
 <!-- Options: Blog Post: user can reply -->
 <template id="opt_blog_post_complete_comment" name="Allow blog post comment"
-        inherit_id="website_blog.blog_post_complete" optional="disabled"
+        inherit_id="website_blog.blog_post_complete" active="False" customize_show="True"
         groups="website_mail.group_comment">
     <xpath expr="//ul[@id='comments-list']" position="before">
         <section class="mb32 read_width css_editable_mode_hidden">
@@ -307,7 +307,7 @@
 
 <!-- Options: Blog Post: user can select text for tweet -->
 <template id="opt_blog_post_select_to_tweet" name="Select to Tweet"
-        inherit_id="website_blog.blog_post_complete" optional="disabled">
+        inherit_id="website_blog.blog_post_complete" active="False" customize_show="True">
     <xpath expr="//div[@id='blog_content']" position="attributes">
         <attribute name="class">js_tweet mt32</attribute>
     </xpath>
@@ -318,7 +318,7 @@
 
 <!-- Options: Blog Post: user can add Inline Discussion -->
 <template id="opt_blog_post_inline_discussion" name="Allow comment in text"
-        inherit_id="website_blog.blog_post_complete" optional="disabled">
+        inherit_id="website_blog.blog_post_complete" active="False" customize_show="True">
     <xpath expr="//div[@id='blog_content']" position="attributes">
         <attribute name="enable_chatter_discuss">True</attribute>
     </xpath>
@@ -326,7 +326,7 @@
 
 <!-- Options: Blog Post: show tags -->
 <template id="opt_blog_post_complete_tags" name="Tags"
-        optional="enabled" inherit_id="website_blog.blog_post_complete">
+        customize_show="True" inherit_id="website_blog.blog_post_complete">
     <xpath expr="//p[@name='blog_post_data']" position="after">
         <p class="post-meta text-muted text-center" t-if="len(blog_post.tag_ids)">
             <span class="fa fa-tags"/>
@@ -358,7 +358,7 @@
 <!-- Option:Right Column for extra info -->
 
 <template id="index_right" name="Right Column"
-        inherit_id="website_blog.blog_post_short" optional="disabled">
+        inherit_id="website_blog.blog_post_short" active="False" customize_show="True">
     <xpath expr="//div[@id='main_column']" position="attributes">
         <attribute name="class">col-sm-8</attribute>
     </xpath>
@@ -369,7 +369,7 @@
 
 <!-- Option:Right Column: tags -->
 <template id="opt_blog_rc_tags" name="Tags"
-        inherit_id="website_blog.index_right" optional="disabled">
+        inherit_id="website_blog.index_right" active="False" customize_show="True">
     <xpath expr="//div[@id='blog_right_column']" position="inside">
         <section class="mt32">
         <h4>Tags</h4>
@@ -386,7 +386,7 @@
 
 <!-- Option:Right Column: archives -->
 <template id="opt_blog_rc_history" name="Archives"
-        inherit_id="website_blog.index_right" optional="disabled">
+        inherit_id="website_blog.index_right" active="False" customize_show="True">
     <xpath expr="//div[@id='blog_right_column']" position="inside">
         <section class="mt32">
         <h4>Archives</h4>
@@ -403,7 +403,7 @@
 
 <!-- Option:Right Column: about us -->
 <template id="opt_blog_rc_about_us" name="About Us" priority="2"
-        inherit_id="website_blog.index_right" optional="disabled">
+        inherit_id="website_blog.index_right" active="False" customize_show="True">
     <xpath expr="//div[@id='blog_right_column']" position="inside">
         <section class="mt32">
         <h4>About us</h4>
@@ -420,7 +420,7 @@
 
 <!-- Option:Right Column: follow us -->
 <template id="opt_blog_rc_follow_us" name="Follow us" priority="4"
-        inherit_id="website_blog.index_right" optional="disabled">
+        inherit_id="website_blog.index_right" active="False" customize_show="True">
     <xpath expr="//div[@id='blog_right_column']" position="inside">
         <section class="mt32">
             <h4>Follow us<small t-if="blog">: <t t-esc="blog.name"/></small></h4>
@@ -447,7 +447,7 @@
 
 <!-- Option:Right Column: blogs -->
 <template id="opt_blog_rc_blogs" name="Our Blogs" priority="6"
-        inherit_id="website_blog.index_right" optional="disabled">
+        inherit_id="website_blog.index_right" active="False" customize_show="True">
     <xpath expr="//div[@id='blog_right_column']" position="inside">
         <section class="mt32 mb32">
         <h4>Our Blogs</h4>
diff --git a/addons/website_crm/views/website_crm.xml b/addons/website_crm/views/website_crm.xml
index 1f845c42d545..d5dffd70dd21 100644
--- a/addons/website_crm/views/website_crm.xml
+++ b/addons/website_crm/views/website_crm.xml
@@ -2,7 +2,7 @@
 <openerp>
 <data>
 
-<template id="contactus_form" name="Contact Form" inherit_id="website.contactus" optional="enabled">
+<template id="contactus_form" name="Contact Form" inherit_id="website.contactus" customize_show="True">
     <xpath expr="//div[@name='mail_button']" position="replace">
         <form action="/crm/contactus" method="post" class="form-horizontal mt32" enctype="multipart/form-data">
             <t t-foreach="kwargs" t-as="kwarg">
@@ -47,7 +47,7 @@
     </xpath>
 </template>
 
-<template id="contactus_form_company_name" name="Company Name" inherit_id="website_crm.contactus_form" optional="enabled">
+<template id="contactus_form_company_name" name="Company Name" inherit_id="website_crm.contactus_form" customize_show="True">
     <xpath expr="//div[@name='email_from_container']" position="after">
         <div t-attf-class="form-group #{error and 'partner_name' in error and 'has-error' or ''}">
             <label class="col-md-3 col-sm-4 control-label" for="partner_name">Your Company</label>
diff --git a/addons/website_crm_partner_assign/views/website_crm_partner_assign.xml b/addons/website_crm_partner_assign/views/website_crm_partner_assign.xml
index 2285ee7933fb..eafebb00abe0 100644
--- a/addons/website_crm_partner_assign/views/website_crm_partner_assign.xml
+++ b/addons/website_crm_partner_assign/views/website_crm_partner_assign.xml
@@ -113,7 +113,7 @@
     </t>
 </template>
 
-<template id="ref_country" inherit_id="website_crm_partner_assign.index" optional="enabled" name="Left World Map">
+<template id="ref_country" inherit_id="website_crm_partner_assign.index" customize_show="True" name="Left World Map">
     <xpath expr="//ul[@id='reseller_countries']" position="after">
         <!-- modal for large map -->
         <div class="modal fade partner_map_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
diff --git a/addons/website_customer/views/website_customer.xml b/addons/website_customer/views/website_customer.xml
index 5d0a8f6d7ba8..a74e6b6f97f4 100644
--- a/addons/website_customer/views/website_customer.xml
+++ b/addons/website_customer/views/website_customer.xml
@@ -66,7 +66,7 @@
 </template>
 
 <!-- Option: left column: World Map -->
-<template id="opt_country" inherit_id="website_customer.index" optional="enabled" name="Show Map">
+<template id="opt_country" inherit_id="website_customer.index" customize_show="True" name="Show Map">
     <xpath expr="//div[@id='ref_left_column']" position="inside">
         <!-- modal for large map -->
         <div class="modal fade customer_map_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
@@ -90,7 +90,7 @@
     </xpath>
 </template>
 
-<template id="opt_country_list" inherit_id="website_customer.index" optional="enabled" name="Filter on Countries">
+<template id="opt_country_list" inherit_id="website_customer.index" customize_show="True" name="Filter on Countries">
     <xpath expr="//div[@id='ref_left_column']" position="inside">
         <h3>References by Country</h3>
         <ul class="nav nav-pills nav-stacked mt16 mb32">
diff --git a/addons/website_event/views/website_event.xml b/addons/website_event/views/website_event.xml
index 986904efea56..a5d437402b75 100644
--- a/addons/website_event/views/website_event.xml
+++ b/addons/website_event/views/website_event.xml
@@ -88,7 +88,7 @@
     </t>
 </template>
 
-<template id="event_right_photos" inherit_id="website_event.index" optional="disabled" name="Photos">
+<template id="event_right_photos" inherit_id="website_event.index" active="False" customize_show="True" name="Photos">
     <xpath expr="//div[@id='right_column']" position="inside">
         <div class="row">
             <div class="col-md-12 mb16">
@@ -107,7 +107,7 @@
     </xpath>
 </template>
 
-<template id="event_right_quotes" inherit_id="website_event.index" optional="disabled" name="Quotes">
+<template id="event_right_quotes" inherit_id="website_event.index" active="False" customize_show="True" name="Quotes">
     <xpath expr="//div[@id='right_column']" position="inside">
         <div class="row">
             <div class="col-md-12 mb16">
@@ -124,7 +124,7 @@
     </xpath>
 </template>
 
-<template id="event_right_country_event" inherit_id="website_event.index" optional="disabled" name="Country Events">
+<template id="event_right_country_event" inherit_id="website_event.index" active="False" customize_show="True" name="Country Events">
     <xpath expr="//div[@id='right_column']" position="inside">
         <div class="row">
             <div class="col-md-12 mb16 mt16 country_events">
@@ -141,7 +141,7 @@
     </xpath>
 </template>
 
-<template id="event_left_column" optional="enabled" inherit_id="website_event.index" name="Filters">
+<template id="event_left_column" customize_show="True" inherit_id="website_event.index" name="Filters">
     <xpath expr="//div[@id='middle_column']" position="attributes">
         <attribute name="class">col-md-6</attribute>
     </xpath>
@@ -160,7 +160,7 @@
     </xpath>
 </template>
 
-<template id="event_category" inherit_id="website_event.event_left_column" optional="disabled" name="Filter by Category">
+<template id="event_category" inherit_id="website_event.event_left_column" active="False" customize_show="True" name="Filter by Category">
     <xpath expr="//div[@id='left_column']" position="inside">
         <ul class="nav nav-pills nav-stacked mt32">
             <t t-foreach="types" t-as="type">
@@ -175,7 +175,7 @@
     </xpath>
 </template>
 
-<template id="event_location" inherit_id="website_event.event_left_column" optional="disabled" name="Filter by Country">
+<template id="event_location" inherit_id="website_event.event_left_column" active="False" customize_show="True" name="Filter by Country">
     <xpath expr="//div[@id='left_column']" position="inside">
         <ul class="nav nav-pills nav-stacked mt32">
             <t t-foreach="countries" t-as="country">
diff --git a/addons/website_event_sale/views/website_event_sale.xml b/addons/website_event_sale/views/website_event_sale.xml
index c34ff045731f..cf68e99146dc 100644
--- a/addons/website_event_sale/views/website_event_sale.xml
+++ b/addons/website_event_sale/views/website_event_sale.xml
@@ -25,7 +25,7 @@
     </xpath>
 </template>
 
-<template id="event_description_full" inherit_id="website_event.event_description_full" optional="enabled" name="Event's Ticket form">
+<template id="event_description_full" inherit_id="website_event.event_description_full" customize_show="True" name="Event's Ticket form">
     <xpath expr="//div[@t-field='event.description']" position="before">
         <form t-attf-action="/event/cart/update?event_id=#{ event.id }" method="post" t-if="event.event_ticket_ids">
             <table itemprop="offers" class="table table-striped">
diff --git a/addons/website_event_track/views/website_event.xml b/addons/website_event_track/views/website_event.xml
index 05da470c0415..597710c90cae 100644
--- a/addons/website_event_track/views/website_event.xml
+++ b/addons/website_event_track/views/website_event.xml
@@ -2,7 +2,7 @@
 <openerp>
 <data>
 
-<template name="Sponsors" id="event_sponsor" optional="enabled" inherit_id="website_event.layout">
+<template name="Sponsors" id="event_sponsor" customize_show="True" inherit_id="website_event.layout">
     <xpath expr="//t[@t-call='website.layout']" position="inside">
         <t t-set="head">
             <link rel='stylesheet' href='/website_event_track/static/src/css/website_event_track.css'/>
@@ -155,7 +155,7 @@
     </t>
 </template>
 
-<template id="tracks_filter" inherit_id="website_event_track.tracks" optional="enabled" name="Filter on Tags">
+<template id="tracks_filter" inherit_id="website_event_track.tracks" customize_show="True" name="Filter on Tags">
     <xpath expr="//div[@id='left_column']" position="inside">
         <ul class="nav nav-pills nav-stacked">
             <li t-att-class="'' if searches.get('tag') else 'active'"><a t-attf-href="/event/#{ slug(event) }/track">All Tags</a></li>
@@ -244,7 +244,7 @@
     </t>
 </template>
 
-<template id="event_track_social" name="Social Widgets" inherit_id="website_event_track.track_view" optional="disabled">
+<template id="event_track_social" name="Social Widgets" inherit_id="website_event_track.track_view" active="False" customize_show="True">
     <xpath expr="//div[@id='right_column']" position="inside">
         <div class="panel panel-default">
             <div class="panel-heading">
diff --git a/addons/website_hr/views/website_hr.xml b/addons/website_hr/views/website_hr.xml
index 74324294d945..f0a6b3596fd5 100644
--- a/addons/website_hr/views/website_hr.xml
+++ b/addons/website_hr/views/website_hr.xml
@@ -3,7 +3,7 @@
 <data>
 <!-- Page --> 
 
-<template id="aboutus" inherit_id="website.aboutus" optional="enabled" name="Our Team">
+<template id="aboutus" inherit_id="website.aboutus" customize_show="True" name="Our Team">
     <xpath expr="//div[@class='oe_structure']" position="after">
         <section class="container">
             <div class="col-sm-12 text-center" t-if="len(employee_ids)">
diff --git a/addons/website_hr_recruitment/views/templates.xml b/addons/website_hr_recruitment/views/templates.xml
index a1e218806120..0d1397cb6df0 100644
--- a/addons/website_hr_recruitment/views/templates.xml
+++ b/addons/website_hr_recruitment/views/templates.xml
@@ -224,7 +224,7 @@
     </t>
 </template>
 
-<template id="job_countries" inherit_id="website_hr_recruitment.index" optional="disabled" name="Filter by Countries">
+<template id="job_countries" inherit_id="website_hr_recruitment.index" active="False" customize_show="True" name="Filter by Countries">
     <xpath expr="//div[@id='jobs_grid_left']" position="inside">
         <ul class="nav nav-pills nav-stacked mb32">
             <li t-att-class=" '' if country_id else 'active' "><a t-attf-href="/jobs#{ '/department/%s' % slug(department_id) if department_id else '' }#{ '/office/%s' % office_id if office_id else '' }">All Countries</a></li>
@@ -243,7 +243,7 @@
     </xpath>
 </template>
 
-<template id="job_departments" inherit_id="website_hr_recruitment.index" optional="disabled" name="Filter by Departments">
+<template id="job_departments" inherit_id="website_hr_recruitment.index" active="False" customize_show="True" name="Filter by Departments">
     <xpath expr="//div[@id='jobs_grid_left']" position="inside">
         <ul class="nav nav-pills nav-stacked mb32">
             <li t-att-class=" '' if department_id else 'active' "><a t-attf-href="/jobs#{ '/country/%s' % slug(country_id) if country_id else '' }#{ '/office/%s' % office_id if office_id else '' }">All Departments</a></li>
@@ -262,7 +262,7 @@
     </xpath>
 </template>
 
-<template id="job_offices" inherit_id="website_hr_recruitment.index" optional="disabled" name="Filter by Offices">
+<template id="job_offices" inherit_id="website_hr_recruitment.index" active="False" customize_show="True" name="Filter by Offices">
     <xpath expr="//div[@id='jobs_grid_left']" position="inside">
         <ul class="nav nav-pills nav-stacked mb32">
             <li t-att-class=" '' if office_id else 'active' "><a t-attf-href="/jobs#{ '/country/%s' % slug(country_id) if country_id else '' }#{ '/department/%s' % slug(department_id) if department_id else '' }">All Offices</a></li>
diff --git a/addons/website_membership/views/website_membership.xml b/addons/website_membership/views/website_membership.xml
index c7145e6be798..f1f101f47eb4 100644
--- a/addons/website_membership/views/website_membership.xml
+++ b/addons/website_membership/views/website_membership.xml
@@ -84,7 +84,7 @@
 </template>
 
 <template id="opt_index_country" name="Location"
-        optional="enabled" inherit_id="website_membership.index">
+        customize_show="True" inherit_id="website_membership.index">
     <xpath expr="//div[@id='left_column']/ul[1]" position="after">
         <ul class="nav nav-pills nav-stacked mt16">
             <li class="nav-header"><h3>Location</h3></li>
@@ -101,7 +101,7 @@
 
 <!-- Option: index: Left Google Map -->
 <template id="opt_index_google_map" name="Left World Map"
-        optional="enabled" inherit_id="website_membership.index">
+        customize_show="True" inherit_id="website_membership.index">
     <xpath expr="//div[@id='left_column']/ul[last()]" position="after">
         <!-- modal for large map -->
         <div class="modal fade partner_map_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
diff --git a/addons/website_quote/views/website_quotation.xml b/addons/website_quote/views/website_quotation.xml
index 3ada2798ca41..e949e3d4d1b6 100644
--- a/addons/website_quote/views/website_quotation.xml
+++ b/addons/website_quote/views/website_quotation.xml
@@ -92,7 +92,7 @@
       </section>
   </template>
 
-  <template id="change_quantity" inherit_id="website_quote.pricing" optional="disabled" name="Change Quantity">
+  <template id="change_quantity" inherit_id="website_quote.pricing" active="False" customize_show="True" name="Change Quantity">
       <xpath expr="//div[@id='quote_qty']" position="replace">
           <div class="input-group">
               <span class="input-group-addon hidden-print">
@@ -130,7 +130,7 @@
   </template>
 
   <!-- Options:Quotation Chatter: user can reply -->
-  <template id="opt_quotation_chatter_post_complete_comment" name="Allow Comments" optional="enabled" inherit_id="website_quote.chatter">
+  <template id="opt_quotation_chatter_post_complete_comment" name="Allow Comments" customize_show="True" inherit_id="website_quote.chatter">
       <xpath expr="//h1" position="after">
           <section class="mb32 css_editable_mode_hidden hidden-print">
               <form id="comment" t-attf-action="/quote/#{quotation.id}/#{quotation.access_token}/post" method="POST">
@@ -388,7 +388,7 @@
   </template>
 
   <!-- Options:Quotation Signature -->
-  <template id="opt_quotation_signature" name="Ask Signature" optional="enabled" inherit_id="website_quote.so_quotation">
+  <template id="opt_quotation_signature" name="Ask Signature" customize_show="True" inherit_id="website_quote.so_quotation">
       <xpath expr="//div[@id='sign-dialog']" position="inside">
         <div class="panel panel-default mt16 mb0" id="drawsign">
             <div class="panel-heading">
diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml
index 132b34fe95d1..4c74c42868bc 100644
--- a/addons/website_sale/views/templates.xml
+++ b/addons/website_sale/views/templates.xml
@@ -104,7 +104,7 @@
   </form>
 </template>
 
-<template id="products_description" inherit_id="website_sale.products_item" optional="disabled" name="Product Description">
+<template id="products_description" inherit_id="website_sale.products_item" active="False" customize_show="True" name="Product Description">
   <xpath expr="//div[@class='product_price']" position="before">
       <div class="text-info oe_subdescription" contenteditable="false">
         <div itemprop="description" t-field="product.description_sale"></div>
@@ -112,7 +112,7 @@
   </xpath>
 </template>
 
-<template id="products_add_to_cart" inherit_id="website_sale.products_item" optional="disabled" name="Add to Cart">
+<template id="products_add_to_cart" inherit_id="website_sale.products_item" active="False" customize_show="True" name="Add to Cart">
   <xpath expr="//div[@class='product_price']" position="inside">
     <input name="product_id" t-att-value="product.product_variant_ids[0].id" type="hidden"/>
     <a class="btn btn-default btn-xs fa fa-shopping-cart a-submit"/>
@@ -259,7 +259,7 @@
   </li>
 </template>
 
-<template id="products_categories" inherit_id="website_sale.products" optional="disabled" name="Product Categories">
+<template id="products_categories" inherit_id="website_sale.products" active="False" customize_show="True" name="Product Categories">
   <xpath expr="//div[@id='products_grid_before']" position="inside">
       <ul class="nav nav-pills nav-stacked mt16">
           <li t-att-class=" '' if category else 'active' "><a t-att-href="keep('/shop',category=0)">All Products</a></li>
@@ -276,7 +276,7 @@
   </xpath>
 </template>
 
-<template id="products_attributes" inherit_id="website_sale.products" optional="disabled" name="Product Attribute's Filters">
+<template id="products_attributes" inherit_id="website_sale.products" active="False" customize_show="True" name="Product Attribute's Filters">
   <xpath expr="//div[@id='products_grid_before']" position="inside">
       <form class="js_attributes" method="get">
           <input type="hidden" name="search" t-att-value="search"/>
@@ -331,7 +331,7 @@
   </xpath>
 </template>
 
-<template id="products_list_view" inherit_id="website_sale.products" optional="disabled" name="List View">
+<template id="products_list_view" inherit_id="website_sale.products" active="False" customize_show="True" name="List View">
   <xpath expr="//div[@id='products_grid']//table" position="replace">
     <t t-foreach="products" t-as="product">
       <div class="oe_product oe_list oe_product_cart" t-att-data-publish="product.website_published and 'on' or 'off'">
@@ -414,7 +414,7 @@
   </t>
 </template>
 
-<template id="product_quantity" inherit_id="website_sale.product" optional="enabled" name="Select Quantity">
+<template id="product_quantity" inherit_id="website_sale.product" customize_show="True" name="Select Quantity">
   <xpath expr="//a[@id='add_to_cart']" position="before">
     <div class="css_quantity input-group" style="width: 108px;">
         <span class="input-group-addon">
@@ -462,7 +462,7 @@
   </div>
 </template>
 
-<template id="product_variants" inherit_id="website_sale.product" optional="disabled" name="List View of Variants">
+<template id="product_variants" inherit_id="website_sale.product" active="False" customize_show="True" name="List View of Variants">
   <xpath expr="//t[@t-placeholder='select']" position="replace">
     <input type="hidden" t-if="len(product.product_variant_ids) == 1" name="product_id" t-att-value="product.product_variant_ids[0].id"/>
     <t t-if="len(product.product_variant_ids) &gt; 1">
@@ -550,7 +550,7 @@
   </ul>
 </template>
 
-<template id="recommended_products" inherit_id="website_sale.product" optional="enabled" name="Alternative Products">
+<template id="recommended_products" inherit_id="website_sale.product" customize_show="True" name="Alternative Products">
   <xpath expr="//div[@id='product_full_description']" position="after">
       <div class="container mt32" t-if="product.alternative_product_ids">
           <h3>Suggested alternatives:</h3>
@@ -572,7 +572,7 @@
   </xpath>
 </template>
 
-<template id="product_attributes" inherit_id="website_sale.product" optional="enabled" name="Product attributes">
+<template id="product_attributes" inherit_id="website_sale.product" customize_show="True" name="Product attributes">
   <xpath expr="//p[@t-field='product.description_sale']" position="after">
     <hr t-if="sum([(1 if len(l.value_ids)==1 else 0) for l in product.attribute_line_ids])"/>
     <p class="text-muted">
@@ -587,7 +587,7 @@
 
 <!-- Product options: OpenChatter -->
 
-<template id="product_comment" inherit_id="website_sale.product" optional="disabled" name="Discussion">
+<template id="product_comment" inherit_id="website_sale.product" active="False" customize_show="True" name="Discussion">
     <xpath expr="//div[@t-field='product.website_description']" position="after">
         <hr class="mb32"/>
         <section class="container">
@@ -753,7 +753,7 @@
   </t>
 </template>
 
-<template id="suggested_products_list" inherit_id="website_sale.cart" optional="enabled" name="Suggested Products in my cart">
+<template id="suggested_products_list" inherit_id="website_sale.cart" customize_show="True" name="Suggested Products in my cart">
   <xpath expr="//table[@id='cart_products']" position="after">
       <table t-if="suggested_products" class='table table-striped table-condensed'>
           <colgroup>
@@ -810,13 +810,13 @@
   </xpath>
 </template>
 
-<template id="continue_shopping" inherit_id="website_sale.cart" optional="enabled" name="Continue Shopping Button">
+<template id="continue_shopping" inherit_id="website_sale.cart" customize_show="True" name="Continue Shopping Button">
   <xpath expr="//a[@href='/shop/checkout']" position="before">
     <a href="/shop" class="btn btn-default mb32"><span class="fa fa-long-arrow-left"/> Continue Shopping</a>
   </xpath>
 </template>
 
-<template id="reduction_code" inherit_id="website_sale.cart" optional="disabled" name="Reduction Code">
+<template id="reduction_code" inherit_id="website_sale.cart" active="False" customize_show="True" name="Reduction Code">
   <xpath expr="//div[@id='right_column']" position="inside">
       <h4>Coupon Code</h4>
       <p>
diff --git a/openerp/addons/base/ir/ir_ui_view.py b/openerp/addons/base/ir/ir_ui_view.py
index eda031003766..5146cdcbf580 100644
--- a/openerp/addons/base/ir/ir_ui_view.py
+++ b/openerp/addons/base/ir/ir_ui_view.py
@@ -167,21 +167,15 @@ class view(osv.osv):
   (<xpath/>) are applied, and the result is used as if it were this view's
   actual arch.
 """),
-        'application': fields.selection([
-                ('always', "Always applied"),
-                ('enabled', "Optional, enabled"),
-                ('disabled', "Optional, disabled"),
-            ],
-            required=True, string="Application status",
+        'active': fields.boolean("Active", required=True,
             help="""If this view is inherited,
-* if always, the view always extends its parent
-* if enabled, the view currently extends its parent but can be disabled
-* if disabled, the view currently does not extend its parent but can be enabled
+* if True, the view always extends its parent
+* if False, the view currently does not extend its parent but can be enabled
              """),
     }
     _defaults = {
         'mode': 'primary',
-        'application': 'always',
+        'active': True,
         'priority': 16,
     }
     _order = "priority,name"
@@ -289,18 +283,10 @@ class view(osv.osv):
         return ret
 
     def toggle(self, cr, uid, ids, context=None):
-        """ Switches between enabled and disabled application statuses
+        """ Switches between enabled and disabled statuses
         """
-        for view in self.browse(cr, uid, ids, context=context):
-            if view.application == 'enabled':
-                view.write({'application': 'disabled'})
-            elif view.application == 'disabled':
-                view.write({'application': 'enabled'})
-            else:
-                raise ValueError(_("Can't toggle view %d with application %r") % (
-                    view.id,
-                    view.application,
-                ))
+        for view in self.browse(cr, uid, ids, context=dict(context or {}, active_test=False)):
+            view.write({'active': not view.active})
 
     # default view selection
     def default_view(self, cr, uid, model, view_type, context=None):
@@ -346,7 +332,7 @@ class view(osv.osv):
             ['inherit_id', '=', view_id],
             ['model', '=', model],
             ['mode', '=', 'extension'],
-            ['application', 'in', ['always', 'enabled']],
+            ['active', '=', True],
         ]
         if self.pool._init:
             # Module init currently in progress, only consider views from
diff --git a/openerp/addons/base/ir/ir_ui_view_view.xml b/openerp/addons/base/ir/ir_ui_view_view.xml
index 663c0c36ccce..3e7ae5ae42bb 100644
--- a/openerp/addons/base/ir/ir_ui_view_view.xml
+++ b/openerp/addons/base/ir/ir_ui_view_view.xml
@@ -19,7 +19,7 @@
                             <field name="inherit_id"/>
                             <field name="model_data_id"/>
                             <field name="xml_id"/>
-                            <field name="application"/>
+                            <field name="active"/>
                         </group>
                     </group>
                     <notebook>
@@ -61,6 +61,8 @@
             <field name="arch" type="xml">
                 <search string="Views">
                     <field name="name" filter_domain="['|', '|', ('name','ilike',self), ('model','ilike',self), ('model_data_id','ilike',self)]" string="View"/>
+                    <filter string="Active" name="active" domain="[('active', '=',True)]"/>
+                    <filter string="Unactive" domain="[('active', '=',False)]"/>
                     <filter string="Form" domain="[('type', '=','form')]"/>
                     <filter string="Tree" domain="[('type', '=', 'tree')]"/>
                     <filter string="Kanban" domain="[('type', '=', 'kanban')]"/>
@@ -83,6 +85,7 @@
             <field name="type">ir.actions.act_window</field>
             <field name="res_model">ir.ui.view</field>
             <field name="view_id" ref="view_view_tree"/>
+            <field name="context">{'search_default_active': 1}</field>
             <field name="help">Views allows you to personalize each view of Odoo. You can add new fields, move fields, rename them or delete the ones that you do not need.</field>
         </record>
         <menuitem action="action_ui_view" id="menu_action_ui_view" parent="base.next_id_2" sequence="2"/>
diff --git a/openerp/addons/base/tests/test_views.py b/openerp/addons/base/tests/test_views.py
index 8d79398cd04b..f950843da542 100644
--- a/openerp/addons/base/tests/test_views.py
+++ b/openerp/addons/base/tests/test_views.py
@@ -642,7 +642,7 @@ class test_views(ViewCase):
         """Insert view into database via a query to passtrough validation"""
         kw.pop('id', None)
         kw.setdefault('mode', 'extension' if kw.get('inherit_id') else 'primary')
-        kw.setdefault('application', 'always')
+        kw.setdefault('active', True)
 
         keys = sorted(kw.keys())
         fields = ','.join('"%s"' % (k.replace('"', r'\"'),) for k in keys)
@@ -1095,21 +1095,21 @@ class TestOptionalViews(ViewCase):
         self.v1 = self.create({
             'model': 'a',
             'inherit_id': self.v0,
-            'application': 'always',
+            'active': True,
             'priority': 10,
             'arch': '<xpath expr="//base" position="after"><v1/></xpath>',
         })
         self.v2 = self.create({
             'model': 'a',
             'inherit_id': self.v0,
-            'application': 'enabled',
+            'active': True,
             'priority': 9,
             'arch': '<xpath expr="//base" position="after"><v2/></xpath>',
         })
         self.v3 = self.create({
             'model': 'a',
             'inherit_id': self.v0,
-            'application': 'disabled',
+            'active': False,
             'priority': 8,
             'arch': '<xpath expr="//base" position="after"><v3/></xpath>'
         })
@@ -1128,10 +1128,10 @@ class TestOptionalViews(ViewCase):
         )
 
     def test_applied_state_toggle(self):
-        """ Change application states of v2 and v3, check that the results
+        """ Change active states of v2 and v3, check that the results
         are as expected
         """
-        self.browse(self.v2).write({'application': 'disabled'})
+        self.browse(self.v2).toggle()
         arch = self.read_combined(self.v0)['arch']
         self.assertEqual(
             ET.fromstring(arch),
@@ -1141,7 +1141,7 @@ class TestOptionalViews(ViewCase):
             )
         )
 
-        self.browse(self.v3).write({'application': 'enabled'})
+        self.browse(self.v3).toggle()
         arch = self.read_combined(self.v0)['arch']
         self.assertEqual(
             ET.fromstring(arch),
@@ -1152,7 +1152,7 @@ class TestOptionalViews(ViewCase):
             )
         )
 
-        self.browse(self.v2).write({'application': 'enabled'})
+        self.browse(self.v2).toggle()
         arch = self.read_combined(self.v0)['arch']
         self.assertEqual(
             ET.fromstring(arch),
diff --git a/openerp/import_xml.rng b/openerp/import_xml.rng
index b27b92c677a7..cb2cc6d8de21 100644
--- a/openerp/import_xml.rng
+++ b/openerp/import_xml.rng
@@ -204,14 +204,8 @@
                         </rng:optional>
                     </rng:optional>
                     <rng:optional><rng:attribute name="groups"/></rng:optional>
-                    <rng:optional>
-                        <rng:attribute name="optional">
-                            <rng:choice>
-                                <rng:value>enabled</rng:value>
-                                <rng:value>disabled</rng:value>
-                            </rng:choice>
-                        </rng:attribute>
-                    </rng:optional>
+                    <rng:optional><rng:attribute name="active"></rng:attribute></rng:optional>
+                    <rng:optional><rng:attribute name="customize_show"></rng:attribute></rng:optional>
                 </rng:group>
                 <rng:optional>
                     <rng:attribute name="page"><rng:value>True</rng:value></rng:attribute>
diff --git a/openerp/tools/convert.py b/openerp/tools/convert.py
index 842855249e5c..7f56322dc940 100644
--- a/openerp/tools/convert.py
+++ b/openerp/tools/convert.py
@@ -60,6 +60,8 @@ from misc import SKIPPED_ELEMENT_TYPES
 
 from misc import unquote
 
+from openerp import SUPERUSER_ID
+
 # Import of XML records requires the unsafe eval as well,
 # almost everywhere, which is ok because it supposedly comes
 # from trusted data, but at least we make it obvious now.
@@ -289,7 +291,7 @@ form: module.record_id""" % (xml_id,)
         if len(id) > 64:
             _logger.error('id: %s is to long (max: 64)', id)
 
-    def _tag_delete(self, cr, rec, data_node=None):
+    def _tag_delete(self, cr, rec, data_node=None, mode=None):
         d_model = rec.get("model")
         d_search = rec.get("search",'').encode('utf-8')
         d_id = rec.get("id")
@@ -320,7 +322,7 @@ form: module.record_id""" % (xml_id,)
 
         return True
 
-    def _tag_report(self, cr, rec, data_node=None):
+    def _tag_report(self, cr, rec, data_node=None, mode=None):
         res = {}
         for dest,f in (('name','string'),('model','model'),('report_name','name')):
             res[dest] = rec.get(f,'').encode('utf8')
@@ -369,7 +371,7 @@ form: module.record_id""" % (xml_id,)
             self._remove_ir_values(cr, res['name'], value, res['model'])
         return id
 
-    def _tag_function(self, cr, rec, data_node=None):
+    def _tag_function(self, cr, rec, data_node=None, mode=None):
         if self.isnoupdate(data_node) and self.mode != 'init':
             return
         context = self.get_context(data_node, rec, {'ref': _ref(self, cr)})
@@ -377,7 +379,7 @@ form: module.record_id""" % (xml_id,)
         _eval_xml(self,rec, self.pool, cr, uid, self.idref, context=context)
         return
 
-    def _tag_url(self, cr, rec, data_node=None):
+    def _tag_url(self, cr, rec, data_node=None, mode=None):
         url = rec.get("url",'').encode('utf8')
         target = rec.get("target",'').encode('utf8')
         name = rec.get("name",'').encode('utf8')
@@ -389,7 +391,7 @@ form: module.record_id""" % (xml_id,)
         id = self.pool['ir.model.data']._update(cr, self.uid, "ir.actions.act_url", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode)
         self.idref[xml_id] = int(id)
 
-    def _tag_act_window(self, cr, rec, data_node=None):
+    def _tag_act_window(self, cr, rec, data_node=None, mode=None):
         name = rec.get('name','').encode('utf-8')
         xml_id = rec.get('id','').encode('utf8')
         self._test_xml_id(xml_id)
@@ -497,7 +499,7 @@ form: module.record_id""" % (xml_id,)
             self.pool['ir.model.data'].ir_set(cr, self.uid, 'action', keyword, xml_id, [src_model], value, replace=replace, isobject=True, xml_id=xml_id)
         # TODO add remove ir.model.data
 
-    def _tag_ir_set(self, cr, rec, data_node=None):
+    def _tag_ir_set(self, cr, rec, data_node=None, mode=None):
         if self.mode != 'init':
             return
         res = {}
@@ -507,7 +509,7 @@ form: module.record_id""" % (xml_id,)
             res[f_name] = f_val
         self.pool['ir.model.data'].ir_set(cr, self.uid, res['key'], res['key2'], res['name'], res['models'], res['value'], replace=res.get('replace',True), isobject=res.get('isobject', False), meta=res.get('meta',None))
 
-    def _tag_workflow(self, cr, rec, data_node=None):
+    def _tag_workflow(self, cr, rec, data_node=None, mode=None):
         if self.isnoupdate(data_node) and self.mode != 'init':
             return
         model = rec.get('model').encode('ascii')
@@ -533,7 +535,7 @@ form: module.record_id""" % (xml_id,)
     #   action="action_id"
     #   parent="parent_id"
     #
-    def _tag_menuitem(self, cr, rec, data_node=None):
+    def _tag_menuitem(self, cr, rec, data_node=None, mode=None):
         rec_id = rec.get("id",'').encode('ascii')
         self._test_xml_id(rec_id)
         m_l = map(escape, escape_re.split(rec.get("name",'').encode('utf8')))
@@ -622,7 +624,7 @@ form: module.record_id""" % (xml_id,)
     def _assert_equals(self, f1, f2, prec=4):
         return not round(f1 - f2, prec)
 
-    def _tag_assert(self, cr, rec, data_node=None):
+    def _tag_assert(self, cr, rec, data_node=None, mode=None):
         if self.isnoupdate(data_node) and self.mode != 'init':
             return
 
@@ -686,7 +688,7 @@ form: module.record_id""" % (xml_id,)
         else: # all tests were successful for this assertion tag (no break)
             self.assertion_report.record_success()
 
-    def _tag_record(self, cr, rec, data_node=None):
+    def _tag_record(self, cr, rec, data_node=None, mode=None):
         rec_model = rec.get("model").encode('ascii')
         model = self.pool[rec_model]
         rec_id = rec.get("id",'').encode('ascii')
@@ -767,7 +769,7 @@ form: module.record_id""" % (xml_id,)
             cr.commit()
         return rec_model, id
 
-    def _tag_template(self, cr, el, data_node=None):
+    def _tag_template(self, cr, el, data_node=None, mode=None):
         # This helper transforms a <template> element into a <record> and forwards it
         tpl_id = el.get('id', el.get('t-name', '')).encode('ascii')
         full_tpl_id = tpl_id
@@ -798,6 +800,10 @@ form: module.record_id""" % (xml_id,)
         record.append(Field(el.get('priority', "16"), name='priority'))
         if 'inherit_id' in el.attrib:
             record.append(Field(name='inherit_id', ref=el.get('inherit_id')))
+        if el.get('active') in ("True", "False") and mode != "update":
+            record.append(Field(name='active', eval=el.get('active')))
+        if el.get('customize_show') in ("True", "False"):
+            record.append(Field(name='customize_show', eval=el.get('customize_show')))
         groups = el.attrib.pop('groups', None)
         if groups:
             grp_lst = map(lambda x: "ref('%s')" % x, groups.split(','))
@@ -814,8 +820,6 @@ form: module.record_id""" % (xml_id,)
                 )
             )
             record.append(Field('primary', name='mode'))
-        if el.get('optional'):
-            record.append(Field(el.get('optional'), name='application'))
         # inject complete <template> element (after changing node name) into
         # the ``arch`` field
         record.append(Field(el, name="arch", type="xml"))
@@ -836,7 +840,7 @@ form: module.record_id""" % (xml_id,)
             mod,id_str = id_str.split('.')
         return model_data_obj.get_object_reference(cr, self.uid, mod, id_str)
 
-    def parse(self, de):
+    def parse(self, de, mode=None):
         if de.tag != 'openerp':
             raise Exception("Mismatch xml format: root tag must be `openerp`.")
 
@@ -844,7 +848,7 @@ form: module.record_id""" % (xml_id,)
             for rec in n:
                 if rec.tag in self._tags:
                     try:
-                        self._tags[rec.tag](self.cr, rec, n)
+                        self._tags[rec.tag](self.cr, rec, n, mode=mode)
                     except Exception, e:
                         self.cr.rollback()
                         exc_info = sys.exc_info()
@@ -883,6 +887,7 @@ def convert_file(cr, module, filename, idref, mode='update', noupdate=False, kin
         pathname = os.path.join(module, filename)
     fp = misc.file_open(pathname)
     ext = os.path.splitext(filename)[1].lower()
+
     try:
         if ext == '.csv':
             convert_csv_import(cr, module, pathname, fp.read(), idref, mode, noupdate)
@@ -977,7 +982,7 @@ def convert_xml_import(cr, module, xmlfile, idref=None, mode='init', noupdate=Fa
     if idref is None:
         idref={}
     obj = xml_import(cr, module, idref, mode, report=report, noupdate=noupdate)
-    obj.parse(doc.getroot())
+    obj.parse(doc.getroot(), mode=mode)
     return True
 
 
-- 
GitLab