[IMP] website_sale: add price for variation and price_list for reduction

bzr revid: chm@openerp.com-20130822142735-n1aglt9wakj27dsb
This commit is contained in:
Christophe Matthieu
2013-08-22 16:27:35 +02:00
parent 141dcf577b
commit 370fa231bf
8 changed files with 43 additions and 19 deletions
+1 -1
View File
@@ -137,7 +137,7 @@
<section>
<div id="myCarousel" class="carousel slide" data-interval='1000000'>
<div class="oe_carousel_options js_carousel_options" t-ignore="1">
<div class="oe_carousel_options js_carousel_options" t-ignore="1" t-if="editable">
<span class="label js_add"><i class="icon-plus-sign"></i></span>
<span class="label js_remove"><i class="icon-minus-sign"></i></span>
</div>
+4 -4
View File
@@ -13,17 +13,17 @@ class website_contract(http.Controller):
account_obj = request.registry['account.analytic.account']
# public partner profile
project_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID, [('website_testimonial', "!=", False), ('website_published', '=', True)])
partner_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID, [('website_testimonial', "!=", False), ('website_published', '=', True)])
if request.uid != website.get_public_user().id:
contract_ids = account_obj.search(request.cr, openerp.SUPERUSER_ID, [(1, "=", 1)])
contract_project_ids = [contract.partner_id.id
for contract in account_obj.browse(request.cr, openerp.SUPERUSER_ID, contract_ids) if contract.partner_id]
# search for check access rules
project_ids += partner_obj.search(request.cr, request.uid, [('id', "in", contract_project_ids)])
project_ids = list(set(project_ids))
partner_ids += partner_obj.search(request.cr, request.uid, ['|', ('id', "in", contract_project_ids), ('id', "child_of", contract_project_ids)])
partner_ids = list(set(partner_ids))
values = website.get_rendering_context({
'partner_ids': partner_obj.browse(request.cr, openerp.SUPERUSER_ID, project_ids)
'partner_ids': partner_obj.browse(request.cr, openerp.SUPERUSER_ID, partner_ids)
})
return website.render("website_contract.index", values)
@@ -17,6 +17,7 @@
<t t-call="website.layout">
<t t-set="title">References</t>
<div class="container">
<h1>Testimonial</h1>
<div class="thumbnails grid grid-align-top">
<div t-foreach="partner_ids" t-as="partner" class="span6">
<div class="media thumbnail">
@@ -27,6 +28,8 @@
<t t-call="website.publish"><t t-set="object" t-value="partner"/></t>
<h5 class="media-heading" t-field="partner.name"/>
<pre t-field="partner.website_testimonial"/>
<small t-field="partner.country_id"/>
<small t-field="partner.parent_id"/>
</div>
</div>
</div>
+1 -2
View File
@@ -2,8 +2,7 @@
from openerp.osv import osv, fields
class hr(osv.osv):
class res_partner(osv.osv):
_inherit = 'res.partner'
_columns = {
'website_published': fields.boolean('Available in the website'),
+11 -3
View File
@@ -10,6 +10,7 @@ import werkzeug
def get_order(order_id=None):
order_obj = request.registry.get('sale.order')
# check if order allready exists
context = {}
if order_id:
try:
order = order_obj.browse(request.cr, SUPERUSER_ID, order_id)
@@ -23,7 +24,12 @@ def get_order(order_id=None):
order_value.update(order_obj.onchange_partner_id(request.cr, SUPERUSER_ID, [], request.uid, context={})['value'])
order_id = order_obj.create(request.cr, SUPERUSER_ID, order_value)
order = order_obj.browse(request.cr, SUPERUSER_ID, order_id)
return order
context = {
'pricelist': order.pricelist_id.id,
'partner': order.partner_id.id,
}
return order_obj.browse(request.cr, SUPERUSER_ID, order_id, context=context)
def get_current_order():
order = get_order(request.httprequest.session.get('ecommerce_order_id'))
@@ -93,7 +99,9 @@ class Ecommerce(http.Controller):
product_id = product_id and int(product_id) or 0
product_obj = request.registry.get('product.template')
product = product_obj.browse(request.cr, request.uid, product_id)
context = get_current_order()._context
product = product_obj.browse(request.cr, request.uid, product_id, context=context)
values = website.get_rendering_context({
'category_id': post.get('category_id') and int(post.get('category_id')) or None,
'search': post.get("search"),
@@ -161,7 +169,7 @@ class Ecommerce(http.Controller):
values['order_id'] = order.id
# change and record value
if quantity:
if quantity > 0:
pricelist_id = order.pricelist_id and order.pricelist_id.id or False
values.update(order_line_obj.product_id_change(request.cr, SUPERUSER_ID, [], pricelist_id, product_id,
partner_id=user_obj.browse(request.cr, SUPERUSER_ID, request.uid).partner_id.id,
@@ -3,7 +3,7 @@ $(document).ready(function () {
$(".oe_website_sale .js_shipping").toggle();
});
$(".oe_website_sale .oe_mycart input").change(function() {
$(".oe_website_sale .oe_mycart input.js_quantity").change(function() {
var value = parseInt($(this).val());
if (!isNaN(value)) {
window.location.href = window.location.origin + window.location.pathname + 'set_cart/' + $(this).data('id') + '/' + value + '/';
+15 -7
View File
@@ -152,12 +152,18 @@
<label class="radio" t-foreach="product.product_variant_ids" t-as="product">
<input type="radio" name="product_id" t-att-value="product.id" t-att-checked="product == product.product_variant_ids[0] or None"/>
<t t-esc="product.variants or ''">Standard</t>
<span class="badge" t-if="product.price_extra"><t t-esc="product.price_extra > 0 and '+' or ''"/><t t-esc="product.price_extra"/> €</span>
</label><br/>
<button class="btn btn-small btn-success">Add to cart</button>
</form>
<img class="media-object" t-att-src="product.img('image')"/>
<div t-field="product.description_website"></div>
<div><t t-field="product.list_price" />€</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;"><t t-esc="product.product_variant_ids[0].lst_price" /> €</h5>
</t>
<h4><t t-esc="product.product_variant_ids[0].price" /> €</h4>
</div>
</div>
</t>
</t>
@@ -211,20 +217,23 @@
<t t-foreach="order.order_line" t-as="line">
<tr>
<td>
<a t-attf-href="/shop/product/#{ line.product_id.id }/"><img class="img-rounded" t-att-src="line.product_id.img('image_small')"/></a>
<a t-attf-href="/shop/product/#{ line.product_id.product_tmpl_id.id }/"><img class="img-rounded" t-att-src="line.product_id.img('image_small')"/></a>
</td>
<td>
<a t-attf-href="/shop/product/#{ line.product_id.id }/">
<a t-attf-href="/shop/product/#{ line.product_id.product_tmpl_id.id }/">
<span t-field="line.product_id.name"/> <t t-if="line.product_id.variants">(<small t-field="line.product_id.variants"/>)</t>
</a><br/>
<small t-field="line.product_id.description_sale"/>
</td>
<td>
<span t-field="line.product_id.list_price"></span>€
<t t-if="line.product_id.lst_price != line.product_id.price">
<small class="text-error" style="text-decoration: line-through;"><t t-esc="line.product_id.lst_price" /> €</small>
</t>
<span t-field="line.product_id.price"></span> €
</td>
<td>
<div class="mb8 mt8 pull-right">
<input type="text" class="input-mini" t-att-data-id="line.product_id.id" t-att-value="line.product_uom_qty"/>
<input type="text" class="js_quantity input-mini" t-att-data-id="line.product_id.id" t-att-value="line.product_uom_qty"/>
<a t-attf-href="./remove_cart/#{ line.product_id.id }/" class="btn mb8 btn-small btn-inverse">-</a>
<a t-attf-href="./add_cart/#{ line.product_id.id }/" class="btn mb8 btn-small btn-success">+</a>
</div>
@@ -233,7 +242,6 @@
</t>
</tbody>
</table>
<table class='table table-hover table-condensed' id="mycart_total">
<colgroup>
<col width="80"/>
@@ -311,7 +319,7 @@
<template id="reduction_code" inherit_option_id="website_sale.mycart" name="Reduction Code">
<xpath expr="//table[@id='mycart_total']" position="after">
<form t-if="order.order_line" class="well form-search" action="/shop/mycart/" method="post">
<input name="code" class='input' type="text" placeholder="Reduction Code..."/>
<input name="code" class='input' type="text" placeholder="Reduction Code..." t-att-value="order.pricelist_id.code"/>
<button class="btn">Apply Code</button>
</form>
</xpath>
+7 -1
View File
@@ -28,7 +28,7 @@ class product_pricelist(osv.osv):
'code': fields.char('Promotionnal Code', size=64, translate=True),
}
class product_product(osv.osv):
class product_template(osv.osv):
_inherit = "product.template"
_columns = {
'website_published': fields.boolean('Available in the website'),
@@ -62,6 +62,12 @@ class product_product(osv.osv):
def img(self, cr, uid, ids, field='image_small', context=None):
return "/website/image?model=%s&field=%s&id=%s" % (self._name, field, ids[0])
class product_product(osv.osv):
_inherit = "product.product"
def img(self, cr, uid, ids, field='image_small', context=None):
return "/website/image?model=%s&field=%s&id=%s" % (self._name, field, ids[0])
class sale_order(osv.osv):
_inherit = "sale.order"