[IMP] website_sale: no widget, all in xml
bzr revid: chm@openerp.com-20130723081813-wdsuv2g6uc62dm65
This commit is contained in:
parent
596c38e7d7
commit
f2610aa370
|
@ -36,7 +36,7 @@
|
|||
<li><a href="https://plus.google.com/+openerp/posts"><i class="icon-google-plus-sign"></i>Google+</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<div class="span4" name="about_us">
|
||||
<h5 t-esc="res_company.name">Company name</h5>
|
||||
<ul>
|
||||
<li><a href="/page/website.contactus">Contact us</a></li>
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
$(document).ready(function (){
|
||||
$('.oe_ecommerce').on('click', '.oe_product .btn-success,.oe_product .btn-primary, .oe_product .btn-inverse, .oe_product_detail .btn-success,.oe_product_detail .btn-primary, .oe_product_detail .btn-inverse', function (e) {
|
||||
var mycart = !!$('.oe_ecommerce .oe_mycart').size();
|
||||
var $button = $(e.currentTarget);
|
||||
var link = $button.hasClass('btn-inverse') ? '/shop/remove_cart' : '/shop/add_cart';
|
||||
var $add = $button.parent().find('.btn-success,.btn-primary');
|
||||
var $remove = $button.parent().find('.btn-inverse');
|
||||
|
||||
$.get(link, {'product_id': $button.data('id')}, function (result) {
|
||||
var result = JSON.parse(result);
|
||||
var quantity = parseInt(result.quantity);
|
||||
$add.find('.oe_quantity').html(quantity);
|
||||
$add.toggleClass('btn-primary', !quantity).toggleClass('btn-success', !!quantity);
|
||||
$remove.toggleClass('oe_hidden', !quantity);
|
||||
if (mycart && !quantity) {
|
||||
$button.parents('.oe_product:first').remove()
|
||||
}
|
||||
$('.oe_ecommerce .oe_total').replaceWith(''+result.totalHTML);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
openerp.website = function(instance) {
|
||||
|
||||
instance.website.sale = {};
|
||||
instance.website.sale.Checkout = instance.web.Widget.extend({
|
||||
template: 'Website.sale.Checkout',
|
||||
events: {
|
||||
'click .oe_error_payment': 'error_payment',
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
this._super.apply(this, arguments);
|
||||
this.$('input[name="shipping_different"]').on('change', function (ev) {
|
||||
self.$('.oe_shipping').toggle();
|
||||
});
|
||||
},
|
||||
get_payment_image: function () {
|
||||
// model: portal.payment.acquirer => form_template
|
||||
// see Setting => Accounting => Bank & Cash => Configure payment acquiring methods
|
||||
},
|
||||
save: function () {
|
||||
},
|
||||
error_payment: function () {
|
||||
alert("error_payment");
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
if (!$('.oe_checkout').size())
|
||||
return;
|
||||
// Init headless webclient
|
||||
// TODO: Webclient research : use iframe embedding mode
|
||||
// Meanwhile, let's HACK !!!
|
||||
var s = new openerp.init(['web', 'website']);
|
||||
s.web.WebClient.bind_hashchange = s.web.WebClient.show_common = s.web.blockUI = s.web.unblockUI = function() {};
|
||||
s.web.WebClient.include({ do_push_state: function() {} });
|
||||
var wc = new s.web.WebClient();
|
||||
wc.start();
|
||||
var instance = openerp.instances[wc.session.name];
|
||||
// Another hack since we have no callback when webclient has loaded modules.
|
||||
instance.web.qweb.add_template('/website_sale/static/src/xml/ecommerce.xml');
|
||||
|
||||
var editor = new instance.website.sale.Checkout(instance.webclient);
|
||||
editor.appendTo($('.oe_checkout'));
|
||||
});
|
|
@ -1,49 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="Website.sale.Checkout">
|
||||
<div class="oe_checkout">
|
||||
<div>
|
||||
<h3 class="span8">Billing Information</h3>
|
||||
<button class="btn btn-success">Log me, I have an account</button>
|
||||
<label class="span8">Name and firstname<input class="span7" type="text" name="name" placeholder="Name and firstname"/></label>
|
||||
<label class="span4">Telephone<input type="text" name="tel" placeholder="Telephone"/></label>
|
||||
<label class="span4">Fax<input type="text" name="fax" placeholder="Fax"/></label>
|
||||
<label class="span4">Company<input type="text" name="company" placeholder="Company"/></label>
|
||||
<label class="span4">Email address<input type="email" name="email" placeholder="Email address"/></label>
|
||||
<label class="span8">Street<input class="span7" type="text" name="street" placeholder="Street address"/></label>
|
||||
<label class="span4">City<input type="text" name="city" placeholder="City"/></label>
|
||||
<label class="span4">State/Province<input type="text" name="state" placeholder="State/Province"/></label>
|
||||
<label class="span4">Zip/Postal Code<input type="text" name="zip" placeholder="Zip/Postal Code"/></label>
|
||||
<label class="span4">Country<input type="text" name="state" placeholder="Country"/></label>
|
||||
<label class="checkbox">Ship to different address<input type="checkbox" name="shipping_different"/></label>
|
||||
</div>
|
||||
<div class="oe_shipping" style="display:none">
|
||||
<h3 class="span8 oe_shipping" style="display:none">Shipping Information</h3>
|
||||
<label class="span8">Name and firstname<input class="span7" type="text" name="name" placeholder="Name and firstname"/></label>
|
||||
<label class="span4">Telephone<input type="text" name="tel" placeholder="Telephone"/></label>
|
||||
<label class="span4">Fax<input type="text" name="fax" placeholder="Fax"/></label>
|
||||
<label class="span4">Company<input type="text" name="company" placeholder="Company"/></label>
|
||||
<label class="span8">Street<input class="span7" type="text" name="street" placeholder="Street address"/></label>
|
||||
<label class="span4">City<input type="text" name="city" placeholder="City"/></label>
|
||||
<label class="span4">State/Province<input type="text" name="state" placeholder="State/Province"/></label>
|
||||
<label class="span4">Zip/Postal Code<input type="text" name="zip" placeholder="Zip/Postal Code"/></label>
|
||||
<label class="span4">Country<input type="text" name="state" placeholder="Country"/></label>
|
||||
</div>
|
||||
<div class="oe_payment">
|
||||
<div class="oe_error_payment"></div>
|
||||
% if object.company_id.paypal_account:
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
|
||||
<input type="hidden" name="cmd" value="_xclick"/>
|
||||
<input type="hidden" name="business" value="${object.company_id.paypal_account}"/>
|
||||
<input type="hidden" name="item_name" value="${object.company_id.name} ${kind.title()} ${reference}"/>
|
||||
<input type="hidden" name="amount" value="${amount}"/>
|
||||
<input type="hidden" name="currency_code" value="${currency.name}"/>
|
||||
<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"/>
|
||||
</form>
|
||||
% endif
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<data>
|
||||
<!-- Layout add nav and footer -->
|
||||
|
||||
<!--record id="header_ecommerce" model="ir.ui.view">
|
||||
<record id="header_ecommerce" model="ir.ui.view">
|
||||
<field name="name">header_ecommerce</field>
|
||||
<field name="inherit_id" ref="website.header"/>
|
||||
<field name="arch" type="xml">
|
||||
|
@ -15,17 +15,6 @@
|
|||
</data>
|
||||
</field>
|
||||
</record>
|
||||
<record id="footer_ecommerce" model="ir.ui.view">
|
||||
<field name="name">footer_ecommerce</field>
|
||||
<field name="inherit_id" ref="website.footer"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="/div/div/div[3]" position="inside">
|
||||
SHOP Footer
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record-->
|
||||
|
||||
<!-- Page Shop -->
|
||||
|
||||
|
@ -100,6 +89,29 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$('.oe_ecommerce').on('click', '.oe_product .btn', function (e) {
|
||||
var $button = $(e.currentTarget);
|
||||
var $product = $button.parents('.oe_product:first');
|
||||
var link = $button.hasClass('btn-inverse') ? '/shop/remove_cart' : '/shop/add_cart';
|
||||
var $add = $product.find('.btn-success,.btn-primary');
|
||||
var $remove = $product.find('.btn-inverse');
|
||||
|
||||
$.get(link, {'product_id': $button.data('id')}, function (result) {
|
||||
var result = JSON.parse(result);
|
||||
var quantity = parseInt(result.quantity);
|
||||
$add.find('.oe_quantity')
|
||||
.html(quantity);
|
||||
$add.toggleClass('btn-primary', !quantity)
|
||||
.toggleClass('btn-success', !!quantity);
|
||||
$remove.toggleClass('oe_hidden', !quantity);
|
||||
if ($('.oe_mycart').size() && !quantity) {
|
||||
$product.remove()
|
||||
}
|
||||
$('.oe_ecommerce .oe_total').replaceWith(''+result.totalHTML);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</template>
|
||||
|
||||
<template id="product_recommended">
|
||||
|
@ -198,7 +210,51 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="span8 oe_checkout"></div>
|
||||
<div class="span8 oe_checkout">
|
||||
<div>
|
||||
<h3 class="span8">Billing Information</h3>
|
||||
<button class="btn btn-success">Log me, I have an account</button>
|
||||
<label class="span8">Name and firstname<input class="span7" type="text" name="name" placeholder="Name and firstname"/></label>
|
||||
<label class="span4">Telephone<input type="text" name="tel" placeholder="Telephone"/></label>
|
||||
<label class="span4">Fax<input type="text" name="fax" placeholder="Fax"/></label>
|
||||
<label class="span4">Company<input type="text" name="company" placeholder="Company"/></label>
|
||||
<label class="span4">Email address<input type="email" name="email" placeholder="Email address"/></label>
|
||||
<label class="span8">Street<input class="span7" type="text" name="street" placeholder="Street address"/></label>
|
||||
<label class="span4">City<input type="text" name="city" placeholder="City"/></label>
|
||||
<label class="span4">State/Province<input type="text" name="state" placeholder="State/Province"/></label>
|
||||
<label class="span4">Zip/Postal Code<input type="text" name="zip" placeholder="Zip/Postal Code"/></label>
|
||||
<label class="span4">Country<input type="text" name="state" placeholder="Country"/></label>
|
||||
<label class="checkbox">Ship to different address<input type="checkbox" name="shipping_different"/></label>
|
||||
</div>
|
||||
<div class="oe_shipping" style="display:none">
|
||||
<h3 class="span8 oe_shipping" style="display:none">Shipping Information</h3>
|
||||
<label class="span8">Name and firstname<input class="span7" type="text" name="name" placeholder="Name and firstname"/></label>
|
||||
<label class="span4">Telephone<input type="text" name="tel" placeholder="Telephone"/></label>
|
||||
<label class="span4">Fax<input type="text" name="fax" placeholder="Fax"/></label>
|
||||
<label class="span4">Company<input type="text" name="company" placeholder="Company"/></label>
|
||||
<label class="span8">Street<input class="span7" type="text" name="street" placeholder="Street address"/></label>
|
||||
<label class="span4">City<input type="text" name="city" placeholder="City"/></label>
|
||||
<label class="span4">State/Province<input type="text" name="state" placeholder="State/Province"/></label>
|
||||
<label class="span4">Zip/Postal Code<input type="text" name="zip" placeholder="Zip/Postal Code"/></label>
|
||||
<label class="span4">Country<input type="text" name="state" placeholder="Country"/></label>
|
||||
</div>
|
||||
<div class="oe_payment">
|
||||
<div class="oe_error_payment"></div>
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
|
||||
<input type="hidden" name="cmd" value="_xclick"/>
|
||||
<input type="hidden" name="business" value="${object.company_id.paypal_account}"/>
|
||||
<input type="hidden" name="item_name" value="${object.company_id.name} ${kind.title()} ${reference}"/>
|
||||
<input type="hidden" name="amount" value="${amount}"/>
|
||||
<input type="hidden" name="currency_code" value="${currency.name}"/>
|
||||
<input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(".oe_ecommerce input[name='shipping_different']").change(function() {
|
||||
$(".oe_ecommerce .oe_shipping").toggle();
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
|
Loading…
Reference in New Issue