[IMP] website: auto open editor when create new product (use ?unable_editor in url)

bzr revid: chm@openerp.com-20130910122646-ug8dn61rqgbm3eq3
This commit is contained in:
Christophe Matthieu 2013-09-10 14:26:46 +02:00
parent cb8bdad1ec
commit f61e65539e
5 changed files with 19 additions and 25 deletions

View File

@ -193,6 +193,8 @@ a[data-publish][data-publish='on']:hover .css_published {
[data-publish]:not(a) {
position: relative;
overflow: visible;
/*&:hover > [data-publish] */
/* display: block */
}
[data-publish]:not(a) > [data-publish] {
position: absolute;
@ -200,6 +202,3 @@ a[data-publish][data-publish='on']:hover .css_published {
top: -10px;
display: none;
}
[data-publish]:not(a):hover > [data-publish] {
display: block;
}

View File

@ -156,5 +156,5 @@ a[data-publish]
right: -6px
top: -10px
display: none
&:hover > [data-publish]
display: block
/*&:hover > [data-publish]*/
/* display: block*/

View File

@ -118,7 +118,11 @@
var editor = new website.EditorBar();
var $body = $(document.body);
editor.prependTo($body);
editor.prependTo($body).then(function () {
if (location.search.indexOf("unable_editor") >= 0) {
editor.edit();
}
});
$body.css('padding-top', '50px'); // Not working properly: editor.$el.outerHeight());
};
/* ----- TOP EDITOR BAR FOR ADMIN ---- */
@ -240,7 +244,7 @@
defs.push(def);
});
return $.when.apply(null, defs).then(function () {
window.location.reload();
window.location.href = window.location.href.replace(/unable_editor(=[^&]*)?/, '');
});
},
saveElement: function ($el) {
@ -263,7 +267,7 @@
});
},
cancel: function () {
window.location.reload();
window.location.href = window.location.href.replace(/unable_editor(=[^&]*)?/, '');
},
});

View File

@ -122,10 +122,11 @@ class Ecommerce(http.Controller):
}
return request.webcontext.render("website_sale.product", values)
@website.route(['/shop/add_product/'], type='http', auth="public")
def add_product(self, **post):
product_id = request.registry.get('product.product').create(request.cr, request.uid, {'name': 'New Product'}, request.context)
return werkzeug.utils.redirect("/shop/product/%s/" % product_id)
@website.route(['/shop/add_product/', '/shop/category/<cat_id>/add_product/'], type='http', auth="public")
def add_product(self, cat_id=0, **post):
product_id = request.registry.get('product.product').create(request.cr, request.uid,
{'name': 'New Product', 'public_categ_id': cat_id}, request.context)
return werkzeug.utils.redirect("/shop/product/%s/?unable_editor=1" % product_id)
@website.route(['/shop/change_category/<product_id>/'], type='http', auth="public")
def edit_product(self, product_id=0, **post):

View File

@ -73,7 +73,6 @@
</t>
<t t-set="title">Shop - <t t-raw="title">Categories</t></t>
<div class="container oe_website_sale">
<a t-if="editable" href="/shop/add_product/" class="btn btn-default pull-right">Create New Product</a>
<div class="row">
<div class="col-md-12" id="shop_content">
<t t-raw="shop_content" />
@ -121,6 +120,8 @@
</t>
<t t-set="title">Product</t>
<t t-set="shop_content">
<a t-if="editable" t-attf-href="/shop/#{ category_id and ('category/%s/' % category_id) or ''}add_product/" class="btn btn-default pull-right">Create New Product</a>
<div t-if="editable" class="clearfix"/>
<t t-call="website.pager">
<t t-set="classname">pull-left</t>
</t>
@ -182,18 +183,7 @@
<button class="btn btn-sm btn-success">Add to basket</button>
</form>
<img class="media-object img-responsive" t-att-src="product.img('image_medium')"/>
<div t-if="editable" t-att-class="'well css_non_editable_mode_hidden'">
<h2>Category<br/><small>Select the public category</small></h2>
<select name="public_categ_id" class="form-control" t-att-data-id="product.id">
<option value="0">Choose a Category</option>
<t t-foreach="category_list" t-as="cat">
<option t-att-value="cat[0]" t-att-selected="cat[0] == product.public_categ_id.id and 'selected'"><t t-esc="cat[1]"/></option>
</t>
</select>
<h2>Short Description for Quotations<br/><small>Displayed in your shop categories and for quotations</small></h2>
<div class="form-control" t-field="product.description_sale">Enter a short description for this product</div>
</div>
<div t-field="product.website_description">Enter a short Website description for this product</div>
<div t-field="product.website_description">Replace this text with your Website product description</div>
<div>
<t t-if="product.product_variant_ids[0].lst_price != product.product_variant_ids[0].price">
<h5 class="text-error" style="text-decoration: line-through;" title="Price without reduction"><t t-field="product.product_variant_ids[0].lst_price" /></h5>