[IMP] inherit_option_id -> application

This commit is contained in:
Xavier Morel 2014-05-27 11:54:01 +02:00
parent e2f41d09ba
commit e06f5b414b
20 changed files with 126 additions and 107 deletions

View File

@ -158,22 +158,25 @@ class Website(openerp.addons.web.controllers.main.Home):
@http.route('/website/theme_change', type='http', auth="user", website=True)
def theme_change(self, theme_id=False, **kwargs):
imd = request.registry['ir.model.data']
view = request.registry['ir.ui.view']
Views = request.registry['ir.ui.view']
view_model, view_option_id = imd.get_object_reference(
_, theme_template_id = imd.get_object_reference(
request.cr, request.uid, 'website', 'theme')
views = view.search(
request.cr, request.uid, [('inherit_id', '=', view_option_id)],
context=request.context)
view.write(request.cr, request.uid, views, {'inherit_id': False},
context=request.context)
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)
if theme_id:
module, xml_id = theme_id.split('.')
view_model, view_id = imd.get_object_reference(
_, view_id = imd.get_object_reference(
request.cr, request.uid, module, xml_id)
view.write(request.cr, request.uid, [view_id],
{'inherit_id': view_option_id}, context=request.context)
Views.write(request.cr, request.uid, [view_id], {
'application': 'enabled'
}, context=request.context)
return request.render('website.themes', {'theme_changed': True})
@ -197,20 +200,6 @@ class Website(openerp.addons.web.controllers.main.Home):
module_obj.button_immediate_upgrade(request.cr, request.uid, module_ids, context=request.context)
return request.redirect(redirect)
@http.route('/website/customize_template_toggle', type='json', auth='user', website=True)
def customize_template_set(self, view_id):
view_obj = request.registry.get("ir.ui.view")
view = view_obj.browse(request.cr, request.uid, int(view_id),
context=request.context)
if view.inherit_id:
value = False
else:
value = view.inherit_option_id and view.inherit_option_id.id or False
view_obj.write(request.cr, request.uid, [view_id], {
'inherit_id': value
}, context=request.context)
return True
@http.route('/website/customize_template_get', type='json', auth='user', website=True)
def customize_template_get(self, xml_id, full=False):
""" Lists the templates customizing ``xml_id``. By default, only
@ -221,34 +210,35 @@ class Website(openerp.addons.web.controllers.main.Home):
view_model, view_theme_id = imd.get_object_reference(
request.cr, request.uid, 'website', 'theme')
user = request.registry['res.users'].browse(request.cr, request.uid, request.uid, request.context)
user = request.registry['res.users']\
.browse(request.cr, request.uid, request.uid, request.context)
user_groups = set(user.groups_id)
view = request.registry["ir.ui.view"]
views = view._views_get(request.cr, request.uid, xml_id, context=request.context)
views = request.registry["ir.ui.view"]\
._views_get(request.cr, request.uid, xml_id, context=request.context)
done = set()
result = []
for v in views:
if not user_groups.issuperset(v.groups_id):
continue
if full or v.inherit_option_id and v.inherit_option_id.id != view_theme_id:
if v.inherit_option_id.id not in done:
if full or (v.application != 'always' and v.inherit_id.id != view_theme_id):
if v.inherit_id not in done:
result.append({
'name': v.inherit_option_id.name,
'name': v.inherit_id.name,
'id': v.id,
'xml_id': v.xml_id,
'inherit_id': v.inherit_id.id,
'header': True,
'active': False
})
done.add(v.inherit_option_id.id)
done.add(v.inherit_id)
result.append({
'name': v.name,
'id': v.id,
'xml_id': v.xml_id,
'inherit_id': v.inherit_id.id,
'header': False,
'active': (v.inherit_id.id == v.inherit_option_id.id) or (full and v.inherit_id.id)
'active': v.application in ('always', 'enabled'),
})
return result

View File

@ -13,8 +13,6 @@ from openerp.osv import osv, fields
class view(osv.osv):
_inherit = "ir.ui.view"
_columns = {
'inherit_option_id': fields.many2one('ir.ui.view','Optional Inheritancy'),
'inherited_option_ids': fields.one2many('ir.ui.view','inherit_option_id','Optional Inheritancies'),
'page': fields.boolean("Whether this view is a web page template (complete)"),
'website_meta_title': fields.char("Website meta title", size=70, translate=True),
'website_meta_description': fields.text("Website meta description", size=160, translate=True),
@ -66,16 +64,18 @@ class view(osv.osv):
if called_view not in result:
result += self._views_get(cr, uid, called_view, options=options, context=context)
extensions = set(view.inherit_children_ids)
if options:
extensions.update(view.inherited_option_ids)
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'))
# 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=bool(extension.inherit_id),
options=extension.application in ('always', 'enabled'),
context=context, root=False):
if r not in result:
result.append(r)

View File

@ -470,8 +470,14 @@
});
menu.on('click', 'a[data-action!=ace]', function (event) {
var view_id = $(event.currentTarget).data('view-id');
openerp.jsonRpc('/website/customize_template_toggle', 'call', {
'view_id': view_id
return openerp.jsonRpc('/web/dataset/call_kw', 'call', {
model: 'ir.ui.view',
method: 'toggle',
args: [],
kwargs: {
ids: [parseInt(view_id, 10)],
context: website.get_context()
}
}).then( function() {
window.location.reload();
});

View File

@ -203,82 +203,82 @@
All Default Themes
-->
<template id="website.theme_amelia" name="Amelia" inherit_option_id="website.theme">
<template id="website.theme_amelia" name="Amelia" inherit_id="website.theme" optional="disabled">
<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_option_id="website.theme">
<template id="website.theme_cerulean" name="Cerulean" inherit_id="website.theme" optional="disabled">
<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_option_id="website.theme">
<template id="website.theme_cosmo" name="Cosmo" inherit_id="website.theme" optional="disabled">
<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_option_id="website.theme">
<template id="website.theme_cyborg" name="Cyborg" inherit_id="website.theme" optional="disabled">
<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_option_id="website.theme">
<template id="website.theme_flatly" name="Flatly" inherit_id="website.theme" optional="disabled">
<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_option_id="website.theme">
<template id="website.theme_journal" name="Journal" inherit_id="website.theme" optional="disabled">
<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_option_id="website.theme">
<template id="website.theme_readable" name="Readable" inherit_id="website.theme" optional="disabled">
<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_option_id="website.theme">
<template id="website.theme_simplex" name="Simplex" inherit_id="website.theme" optional="disabled">
<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_option_id="website.theme">
<template id="website.theme_slate" name="Slate" inherit_id="website.theme" optional="disabled">
<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_option_id="website.theme">
<template id="website.theme_spacelab" name="Spacelab" inherit_id="website.theme" optional="disabled">
<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_option_id="website.theme">
<template id="website.theme_united" name="United" inherit_id="website.theme" optional="disabled">
<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_option_id="website.theme">
<template id="website.theme_yeti" name="Yeti" inherit_id="website.theme" optional="disabled">
<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"/>

View File

@ -220,7 +220,7 @@
</html>
</template>
<template id="layout_logo_show" inherit_id="website.layout" inherit_option_id="website.layout" name="Show Logo">
<template id="layout_logo_show" inherit_id="website.layout" optional="enabled" name="Show Logo">
<xpath expr="//header//a[@class='navbar-brand']" position="replace">
<a href="/" class="navbar-brand logo">
<img src="/logo.png"/>
@ -304,7 +304,7 @@
<script type="text/javascript" src="/website/static/src/js/jQuery.transfo.js"></script>
</template>
<template id="debugger" inherit_option_id="website.layout" name="Debugger &amp; Tests">
<template id="debugger" inherit_id="website.layout" optional="disabled" name="Debugger &amp; Tests">
<xpath expr='//t[@name="layout_head"]' position="after">
<script type="text/javascript" src="/website/static/src/js/website.tour.js"></script>
</xpath>
@ -318,7 +318,7 @@
</xpath>
</template>
<template id="show_sign_in" inherit_option_id="website.layout" inherit_id="website.layout" name="Show Sign In" groups="base.group_public">
<template id="show_sign_in" optional="enabled" inherit_id="website.layout" name="Show Sign In" groups="base.group_public">
<xpath expr="//ul[@id='top_menu']" position="inside">
<li class="divider"/>
<li>
@ -329,7 +329,7 @@
</xpath>
</template>
<template id="footer_custom" inherit_option_id="website.layout" name="Custom Footer">
<template id="footer_custom" inherit_id="website.layout" optional="disabled" name="Custom Footer">
<xpath expr="//div[@id='footer_container']" position="before">
<div class="oe_structure">
<section data-snippet-id='three-columns' class="mt16 mb16">

View File

@ -161,7 +161,7 @@
<!-- Option: Blog Post List: show tags -->
<template id="opt_blog_post_short_tags" name="Tags"
inherit_option_id="website_blog.blog_post_short" inherit_id="website_blog.blog_post_short">
optional="enabled" 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_option_id="website_blog.blog_post_complete">
inherit_id="website_blog.blog_post_complete" optional="disabled">
<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_option_id="website_blog.blog_post_complete"
inherit_id="website_blog.blog_post_complete" optional="disabled"
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_option_id="website_blog.blog_post_complete">
inherit_id="website_blog.blog_post_complete" optional="disabled">
<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_option_id="website_blog.blog_post_complete">
inherit_id="website_blog.blog_post_complete" optional="disabled">
<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"
inherit_option_id="website_blog.blog_post_complete" inherit_id="website_blog.blog_post_complete">
optional="enabled" 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"/>
@ -355,7 +355,7 @@
<!-- Option:Right Column for extra info -->
<template id="index_right" name="Right Column"
inherit_option_id="website_blog.blog_post_short">
inherit_id="website_blog.blog_post_short" optional="disabled">
<xpath expr="//div[@id='main_column']" position="attributes">
<attribute name="class">col-sm-8</attribute>
</xpath>
@ -366,7 +366,7 @@
<!-- Option:Right Column: tags -->
<template id="opt_blog_rc_tags" name="Tags"
inherit_option_id="website_blog.index_right">
inherit_id="website_blog.index_right" optional="disabled">
<xpath expr="//div[@id='blog_right_column']" position="inside">
<section class="mt32">
<h4>Tags</h4>
@ -383,7 +383,7 @@
<!-- Option:Right Column: archives -->
<template id="opt_blog_rc_history" name="Archives"
inherit_option_id="website_blog.index_right">
inherit_id="website_blog.index_right" optional="disabled">
<xpath expr="//div[@id='blog_right_column']" position="inside">
<section class="mt32">
<h4>Archives</h4>
@ -400,7 +400,7 @@
<!-- Option:Right Column: about us -->
<template id="opt_blog_rc_about_us" name="About Us" priority="2"
inherit_option_id="website_blog.index_right">
inherit_id="website_blog.index_right" optional="disabled">
<xpath expr="//div[@id='blog_right_column']" position="inside">
<section class="mt32">
<h4>About us</h4>
@ -417,7 +417,7 @@
<!-- Option:Right Column: follow us -->
<template id="opt_blog_rc_follow_us" name="Follow us" priority="4"
inherit_option_id="website_blog.index_right">
inherit_id="website_blog.index_right" optional="disabled">
<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>
@ -444,7 +444,7 @@
<!-- Option:Right Column: blogs -->
<template id="opt_blog_rc_blogs" name="Our Blogs" priority="6"
inherit_option_id="website_blog.index_right">
inherit_id="website_blog.index_right" optional="disabled">
<xpath expr="//div[@id='blog_right_column']" position="inside">
<section class="mt32 mb32">
<h4>Our Blogs</h4>

View File

@ -2,7 +2,7 @@
<openerp>
<data>
<template id="contactus_form" name="Contact Form" inherit_id="website.contactus" inherit_option_id="website.contactus">
<template id="contactus_form" name="Contact Form" inherit_id="website.contactus" optional="enabled">
<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" inherit_option_id="website_crm.contactus_form">
<template id="contactus_form_company_name" name="Company Name" inherit_id="website_crm.contactus_form" optional="enabled">
<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>

View File

@ -113,7 +113,7 @@
</t>
</template>
<template id="ref_country" inherit_id="website_crm_partner_assign.index" inherit_option_id="website_crm_partner_assign.index" name="Left World Map">
<template id="ref_country" inherit_id="website_crm_partner_assign.index" optional="enabled" name="Left World Map">
<xpath expr="//ul[@id='reseller_countries']" position="after">
<h3>World Map</h3>
<ul class="nav">

View File

@ -66,7 +66,7 @@
</template>
<!-- Option: left column: World Map -->
<template id="opt_country" inherit_option_id="website_customer.index" name="Show Map">
<template id="opt_country" inherit_id="website_customer.index" optional="disabled" name="Show Map">
<xpath expr="//div[@id='ref_left_column']" position="inside">
<iframe t-attf-src="/google_map/?partner_ids=#{ google_map_partner_ids }&amp;partner_url=/customers/&amp;output=embed"
@ -74,7 +74,7 @@
</xpath>
</template>
<template id="opt_country_list" inherit_id="website_customer.index" inherit_option_id="website_customer.index" name="Filter on Countries">
<template id="opt_country_list" inherit_id="website_customer.index" optional="enabled" 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">

View File

@ -87,7 +87,7 @@
</t>
</template>
<template id="event_right_photos" inherit_option_id="website_event.index" name="Photos">
<template id="event_right_photos" inherit_id="website_event.index" optional="disabled" name="Photos">
<xpath expr="//div[@id='right_column']" position="inside">
<div class="row">
<div class="col-md-12 mb16">
@ -106,7 +106,7 @@
</xpath>
</template>
<template id="event_right_quotes" inherit_option_id="website_event.index" name="Quotes">
<template id="event_right_quotes" inherit_id="website_event.index" optional="disabled" name="Quotes">
<xpath expr="//div[@id='right_column']" position="inside">
<div class="row">
<div class="col-md-12 mb16">
@ -123,7 +123,7 @@
</xpath>
</template>
<template id="event_right_country_event" inherit_option_id="website_event.index" name="Country Events">
<template id="event_right_country_event" inherit_id="website_event.index" optional="disabled" name="Country Events">
<xpath expr="//div[@id='right_column']" position="inside">
<div class="row">
<div class="col-md-12 mb16 mt16 country_events">
@ -140,7 +140,7 @@
</xpath>
</template>
<template id="event_left_column" inherit_option_id="website_event.index" inherit_id="website_event.index" name="Filters">
<template id="event_left_column" optional="enabled" inherit_id="website_event.index" name="Filters">
<xpath expr="//div[@id='middle_column']" position="attributes">
<attribute name="class">col-md-6</attribute>
</xpath>
@ -159,7 +159,7 @@
</xpath>
</template>
<template id="event_category" inherit_option_id="website_event.event_left_column" name="Filter by Category">
<template id="event_category" inherit_id="website_event.event_left_column" optional="disabled" name="Filter by Category">
<xpath expr="//div[@id='left_column']" position="inside">
<ul class="nav nav-pills nav-stacked mt32">
<t t-foreach="types">
@ -173,7 +173,7 @@
</xpath>
</template>
<template id="event_location" inherit_option_id="website_event.event_left_column" name="Filter by Country">
<template id="event_location" inherit_id="website_event.event_left_column" optional="disabled" name="Filter by Country">
<xpath expr="//div[@id='left_column']" position="inside">
<ul class="nav nav-pills nav-stacked mt32">
<t t-foreach="countries">

View File

@ -26,7 +26,7 @@
</xpath>
</template>
<template id="event_description_full" inherit_id="website_event.event_description_full" inherit_option_id="website_event.event_description_full" name="Event's Ticket form">
<template id="event_description_full" inherit_id="website_event.event_description_full" optional="enabled" 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">

View File

@ -2,7 +2,7 @@
<openerp>
<data>
<template name="Sponsors" id="event_sponsor" inherit_option_id="website_event.layout" inherit_id="website_event.layout">
<template name="Sponsors" id="event_sponsor" optional="enabled" 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'/>
@ -157,7 +157,7 @@
</t>
</template>
<template id="tracks_filter" inherit_id="website_event_track.tracks" inherit_option_id="website_event_track.tracks" name="Filter on Tags">
<template id="tracks_filter" inherit_id="website_event_track.tracks" optional="enabled" 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>
@ -246,7 +246,7 @@
</t>
</template>
<template id="event_track_social" name="Social Widgets" inherit_option_id="website_event_track.track_view">
<template id="event_track_social" name="Social Widgets" inherit_id="website_event_track.track_view" optional="disabled">
<xpath expr="//div[@id='right_column']" position="inside">
<div class="panel panel-default">
<div class="panel-heading">

View File

@ -3,7 +3,7 @@
<data>
<!-- Page -->
<template id="aboutus" inherit_id="website.aboutus" inherit_option_id="website.aboutus" name="Our Team">
<template id="aboutus" inherit_id="website.aboutus" optional="enabled" 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)">

View File

@ -230,7 +230,7 @@
</t>
</template>
<template id="job_departments" inherit_option_id="website_hr_recruitment.index" name="Filter by Departments">
<template id="job_departments" inherit_id="website_hr_recruitment.index" optional="disabled" 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 href="/jobs">All Departments</a></li>
@ -249,7 +249,7 @@
</xpath>
</template>
<template id="job_offices" inherit_option_id="website_hr_recruitment.index" name="Filter by Offices">
<template id="job_offices" inherit_id="website_hr_recruitment.index" optional="disabled" 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 href="/jobs">All Offices</a></li>

View File

@ -84,7 +84,7 @@
</template>
<template id="opt_index_country" name="Location"
inherit_option_id="website_membership.index" inherit_id="website_membership.index">
optional="enabled" inherit_id="website_membership.index">
<xpath expr="//div[@id='left_column']/ul[last()]" 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"
inherit_option_id="website_membership.index" inherit_id="website_membership.index">
optional="enabled" inherit_id="website_membership.index">
<xpath expr="//div[@id='left_column']/ul[1]" position="before">
<ul class="nav nav-pills nav-stacked mt16">
<li class="nav-header"><h3>World Map</h3></li>

View File

@ -92,7 +92,7 @@
</section>
</template>
<template id="change_quantity" inherit_option_id="website_quote.pricing" name="Change Quantity">
<template id="change_quantity" inherit_id="website_quote.pricing" optional="disabled" 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" inherit_option_id="website_quote.chatter" inherit_id="website_quote.chatter">
<template id="opt_quotation_chatter_post_complete_comment" name="Allow Comments" optional="enabled" 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" inherit_option_id="website_quote.so_quotation" inherit_id="website_quote.so_quotation">
<template id="opt_quotation_signature" name="Ask Signature" optional="enabled" 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">

View File

@ -85,7 +85,7 @@
</div>
</template>
<template id="products_description" inherit_option_id="website_sale.products_item" name="Product Description">
<template id="products_description" inherit_id="website_sale.products_item" optional="disabled" 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>
@ -93,7 +93,7 @@
</xpath>
</template>
<template id="products_add_to_cart" inherit_option_id="website_sale.products_item" name="Add to Cart">
<template id="products_add_to_cart" inherit_id="website_sale.products_item" optional="disabled" name="Add to Cart">
<xpath expr="//div[@class='product_price']" position="inside">
<form action="/shop/cart/update" method="post" style="display: inline-block;">
<input name="product_id" t-att-value="product.product_variant_ids[0].id" type="hidden"/>
@ -246,7 +246,7 @@
</li>
</template>
<template id="products_categories" inherit_option_id="website_sale.products" name="Product Categories">
<template id="products_categories" inherit_id="website_sale.products" optional="disabled" 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>
@ -263,7 +263,7 @@
</xpath>
</template>
<template id="products_attributes" inherit_option_id="website_sale.products" name="Product Attribute's Filters" groups="product.group_product_attributes">
<template id="products_attributes" inherit_id="website_sale.products" optional="disabled" name="Product Attribute's Filters" groups="product.group_product_attributes">
<xpath expr="//div[@id='products_grid_before']" position="inside">
<form t-att-action="keep('shop',attrib=0)" class="attributes" method="get">
<ul class="nav nav-pills nav-stacked mt16">
@ -293,7 +293,7 @@
</xpath>
</template>
<template id="products_list_view" inherit_option_id="website_sale.products" name="List View">
<template id="products_list_view" inherit_id="website_sale.products" optional="disabled" 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'">
@ -389,7 +389,7 @@
</t>
</template>
<template id="recommended_products" inherit_id="website_sale.product" inherit_option_id="website_sale.product" name="Alternative Products">
<template id="recommended_products" inherit_id="website_sale.product" optional="enabled" 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>
@ -411,7 +411,7 @@
</xpath>
</template>
<template id="product_attributes" inherit_id="website_sale.product" inherit_option_id="website_sale.product" name="Product attributes" groups="product.group_product_attributes">
<template id="product_attributes" inherit_id="website_sale.product" optional="enabled" name="Product attributes" groups="product.group_product_attributes">
<xpath expr="//p[@t-field='product.description_sale']" position="after">
<hr t-if="product.attribute_lines"/>
<p class="text-muted">
@ -422,7 +422,7 @@
</xpath>
</template>
<template id="product_comment" inherit_option_id="website_sale.product" name="Discussion">
<template id="product_comment" inherit_id="website_sale.product" optional="disabled" name="Discussion">
<xpath expr="//div[@t-field='product.website_description']" position="after">
<hr class="mb32"/>
<section class="container">
@ -588,7 +588,7 @@
</t>
</template>
<template id="suggested_products_list" inherit_id="website_sale.cart" inherit_option_id="website_sale.cart" name="Suggested Products in my cart">
<template id="suggested_products_list" inherit_id="website_sale.cart" optional="enabled" 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>
@ -644,13 +644,13 @@
</xpath>
</template>
<template id="continue_shopping" inherit_id="website_sale.cart" inherit_option_id="website_sale.cart" name="Continue Shopping Button">
<template id="continue_shopping" inherit_id="website_sale.cart" optional="enabled" 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_option_id="website_sale.cart" name="Reduction Code">
<template id="reduction_code" inherit_id="website_sale.cart" optional="disabled" name="Reduction Code">
<xpath expr="//div[@id='right_column']" position="inside">
<h4>Coupon Code</h4>
<p>

View File

@ -273,6 +273,21 @@ class view(osv.osv):
context)
return ret
def toggle(self, cr, uid, ids, context=None):
""" Switches between enabled and disabled application 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,
))
def copy(self, cr, uid, id, default=None, context=None):
if not default:
default = {}

View File

@ -218,8 +218,15 @@
<rng:choice>
<rng:group>
<rng:optional><rng:attribute name="inherit_id"/></rng:optional>
<rng:optional><rng:attribute name="inherit_option_id"/></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:group>
<rng:optional>
<rng:attribute name="page"><rng:value>True</rng:value></rng:attribute>

View File

@ -866,7 +866,7 @@ form: module.record_id""" % (xml_id,)
if '.' not in full_tpl_id:
full_tpl_id = '%s.%s' % (self.module, tpl_id)
# set the full template name for qweb <module>.<id>
if not (el.get('inherit_id') or el.get('inherit_option_id')):
if not el.get('inherit_id'):
el.set('t-name', full_tpl_id)
el.tag = 't'
else:
@ -889,9 +889,8 @@ form: module.record_id""" % (xml_id,)
record.append(Field("qweb", name='type'))
record.append(Field(el.get('priority', "16"), name='priority'))
record.append(Field(el, name="arch", type="xml"))
for field_name in ('inherit_id','inherit_option_id'):
value = el.attrib.pop(field_name, None)
if value: record.append(Field(name=field_name, ref=value))
if 'inherit_id' in el.attrib:
record.append(Field(name='inherit_id', ref=el.get('inherit_id')))
groups = el.attrib.pop('groups', None)
if groups:
grp_lst = map(lambda x: "ref('%s')" % x, groups.split(','))
@ -900,6 +899,8 @@ form: module.record_id""" % (xml_id,)
record.append(Field(name="page", eval="True"))
if el.get('primary') == 'True':
record.append(Field('primary', name='mode'))
if el.get('optional'):
record.append(Field(el.get('optional'), name='application'))
return self._tag_record(cr, record, data_node)