[IMP] Content->New Product asks for name of product
bzr revid: fme@openerp.com-20131119113822-ve7bl516xowa7u1f
This commit is contained in:
@@ -403,10 +403,10 @@ class Ecommerce(http.Controller):
|
||||
return request.website.render("website_sale.product", values)
|
||||
|
||||
@website.route(['/shop/add_product/', '/shop/category/<int:cat_id>/add_product/'], type='http', auth="user", multilang=True, methods=['POST'])
|
||||
def add_product(self, cat_id=0, **post):
|
||||
def add_product(self, name="New Product", cat_id=0, **post):
|
||||
Product = request.registry.get('product.product')
|
||||
product_id = Product.create(request.cr, request.uid, {
|
||||
'name': 'New Product', 'public_categ_id': cat_id
|
||||
'name': name, 'public_categ_id': cat_id
|
||||
}, context=request.context)
|
||||
product = Product.browse(request.cr, request.uid, product_id, context=request.context)
|
||||
|
||||
|
||||
@@ -3,4 +3,20 @@
|
||||
|
||||
var website = openerp.website;
|
||||
website.add_template_file('/website_sale/static/src/xml/website_sale.xml');
|
||||
|
||||
website.EditorBar.include({
|
||||
events: _.extend({}, website.EditorBar.prototype.events, {
|
||||
'click a[data-action=new_product]': function (ev) {
|
||||
ev.preventDefault();
|
||||
website.prompt({
|
||||
window_title: "New Product",
|
||||
input: "Product Name",
|
||||
}).then(function (name) {
|
||||
website.form('/shop/add_product', 'POST', {
|
||||
name: name
|
||||
});
|
||||
});
|
||||
}
|
||||
}),
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t t-extend="website.editorbar">
|
||||
<t t-jquery="ul.oe_content_menu" t-operation="append">
|
||||
<li><a href="/shop/add_product" class="js_link2post">New Product</a></li>
|
||||
<li><a href="#" data-action="new_product">New Product</a></li>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
||||
|
||||
Reference in New Issue
Block a user