[IMP] website_event: split module: remove depends with sale and move event's ticket form into a bridge: website_event_sale

bzr revid: chm@openerp.com-20140128113101-aon81actmpahyn58
This commit is contained in:
Christophe Matthieu 2014-01-28 12:31:01 +01:00
parent f959685bc7
commit 07adc071df
25 changed files with 301 additions and 191 deletions

View File

@ -175,7 +175,6 @@ class crm_lead2opportunity_partner(osv.osv_memory):
ctx['active_id'] = lead_id ctx['active_id'] = lead_id
partner_id = self._find_matching_partner(cr, uid, context=ctx) partner_id = self._find_matching_partner(cr, uid, context=ctx)
action = 'create' action = 'create'
print partner_id
res = lead.handle_partner_assignation(cr, uid, [lead_id], action, partner_id, context=context) res = lead.handle_partner_assignation(cr, uid, [lead_id], action, partner_id, context=context)
return res.get(lead_id) return res.get(lead_id)

View File

@ -111,7 +111,7 @@ class event_event(osv.osv):
"""Get reserved, available, reserved but unconfirmed and used seats. """Get reserved, available, reserved but unconfirmed and used seats.
@return: Dictionary of function field values. @return: Dictionary of function field values.
""" """
res = dict.fromkeys(ids, {}) res = dict([(id, {}) for id in ids])
for event in self.browse(cr, uid, ids, context=context): for event in self.browse(cr, uid, ids, context=context):
res[event.id]['seats_reserved'] = sum(reg.nb_register for reg in event.registration_ids if reg.state == "open") res[event.id]['seats_reserved'] = sum(reg.nb_register for reg in event.registration_ids if reg.state == "open")
res[event.id]['seats_used'] = sum(reg.nb_register for reg in event.registration_ids if reg.state == "done") res[event.id]['seats_used'] = sum(reg.nb_register for reg in event.registration_ids if reg.state == "done")

View File

@ -133,8 +133,7 @@ class event_event(osv.osv):
help="The maximum registration level is equal to the sum of the maximum registration of event ticket." + help="The maximum registration level is equal to the sum of the maximum registration of event ticket." +
"If you have too much registrations you are not able to confirm your event. (0 to ignore this rule )", "If you have too much registrations you are not able to confirm your event. (0 to ignore this rule )",
type='integer', type='integer',
readonly=True, readonly=True)
store=True)
} }
_defaults = { _defaults = {
'event_ticket_ids': _get_tickets 'event_ticket_ids': _get_tickets
@ -147,7 +146,7 @@ class event_ticket(osv.osv):
"""Get reserved, available, reserved but unconfirmed and used seats for each event tickets. """Get reserved, available, reserved but unconfirmed and used seats for each event tickets.
@return: Dictionary of function field values. @return: Dictionary of function field values.
""" """
res = dict.fromkeys(ids, {}) res = dict([(id, {}) for id in ids])
for ticket in self.browse(cr, uid, ids, context=context): for ticket in self.browse(cr, uid, ids, context=context):
res[ticket.id]['seats_reserved'] = sum(reg.nb_register for reg in ticket.registration_ids if reg.state == "open") res[ticket.id]['seats_reserved'] = sum(reg.nb_register for reg in ticket.registration_ids if reg.state == "open")
res[ticket.id]['seats_used'] = sum(reg.nb_register for reg in ticket.registration_ids if reg.state == "done") res[ticket.id]['seats_used'] = sum(reg.nb_register for reg in ticket.registration_ids if reg.state == "done")

View File

@ -11,7 +11,7 @@ Online Events
""", """,
'author': 'OpenERP SA', 'author': 'OpenERP SA',
'depends': ['website', 'website_partner', 'website_mail', 'event_sale', 'website_sale'], 'depends': ['website', 'website_partner', 'website_mail', 'event'],
'data': [ 'data': [
'data/event_data.xml', 'data/event_data.xml',
'views/website_event.xml', 'views/website_event.xml',

View File

@ -188,59 +188,6 @@ class website_event(http.Controller):
} }
return request.website.render("website_event.event_description_full", values) return request.website.render("website_event.event_description_full", values)
@http.route(['/event/add_cart'], type='http', auth="public", website=True, multilang=True)
def add_cart(self, event_id, **post):
user_obj = request.registry['res.users']
order_line_obj = request.registry.get('sale.order.line')
ticket_obj = request.registry.get('event.event.ticket')
order_obj = request.registry.get('sale.order')
website = request.registry['website']
order = website.ecommerce_get_current_order(request.cr, request.uid, context=request.context)
if not order:
order = website.ecommerce_get_new_order(request.cr, request.uid, context=request.context)
partner_id = user_obj.browse(request.cr, SUPERUSER_ID, request.uid,
context=request.context).partner_id.id
fields = [k for k, v in order_line_obj._columns.items()]
values = order_line_obj.default_get(request.cr, SUPERUSER_ID, fields,
context=request.context)
_values = None
for key, value in post.items():
try:
quantity = int(value)
except:
quantity = None
ticket_id = key.split("-")[0] == 'ticket' and int(key.split("-")[1]) or None
if not ticket_id or not quantity:
continue
ticket = ticket_obj.browse(request.cr, request.uid, ticket_id,
context=request.context)
values['product_id'] = ticket.product_id.id
values['event_id'] = ticket.event_id.id
values['event_ticket_id'] = ticket.id
values['product_uom_qty'] = quantity
values['price_unit'] = ticket.price
values['order_id'] = order.id
values['name'] = "%s: %s" % (ticket.event_id.name, ticket.name)
# change and record value
pricelist_id = order.pricelist_id and order.pricelist_id.id or False
_values = order_line_obj.product_id_change(
request.cr, SUPERUSER_ID, [], pricelist_id, ticket.product_id.id,
partner_id=partner_id, context=request.context)['value']
_values.update(values)
order_line_id = order_line_obj.create(request.cr, SUPERUSER_ID, _values, context=request.context)
order_obj.write(request.cr, SUPERUSER_ID, [order.id], {'order_line': [(4, order_line_id)]}, context=request.context)
if not _values:
return request.redirect("/event/%s/" % event_id)
return request.redirect("/shop/checkout")
@http.route(['/event/publish'], type='json', auth="public", website=True) @http.route(['/event/publish'], type='json', auth="public", website=True)
def publish(self, id, object): def publish(self, id, object):
# if a user publish an event, he publish all linked res.partner # if a user publish an event, he publish all linked res.partner

View File

@ -1,2 +1 @@
import event import event
import website

View File

@ -19,22 +19,13 @@
# #
############################################################################## ##############################################################################
from openerp.osv import orm, osv, fields from openerp.osv import osv, fields
from openerp import SUPERUSER_ID from openerp import SUPERUSER_ID
from openerp.addons.web.http import request
from openerp.tools.translate import _ from openerp.tools.translate import _
import re import re
# defined for access rules
class product(osv.osv):
_inherit = 'product.product'
_columns = {
'event_ticket_ids': fields.one2many('event.event.ticket', 'product_id', 'Event Tickets'),
}
class event(osv.osv): class event(osv.osv):
_name = 'event.event' _name = 'event.event'
_inherit = ['event.event','website.seo.metadata'] _inherit = ['event.event','website.seo.metadata']
@ -128,19 +119,3 @@ class event(osv.osv):
if partner.address_id: if partner.address_id:
return self.browse(cr, SUPERUSER_ID, ids[0], context=context).address_id.google_map_link() return self.browse(cr, SUPERUSER_ID, ids[0], context=context).address_id.google_map_link()
class sale_order_line(osv.osv):
_inherit = "sale.order.line"
def _recalculate_product_values(self, cr, uid, ids, product_id=0, context=None):
if not ids:
return super(sale_order_line, self)._recalculate_product_values(cr, uid, ids, product_id, context=context)
order_line = self.browse(cr, SUPERUSER_ID, ids[0], context=context)
assert order_line.order_id.website_session_id == request.httprequest.session['website_session_id']
product = product_id and self.pool.get('product.product').browse(cr, uid, product_id, context=context) or order_line.product_id
res = super(sale_order_line, self)._recalculate_product_values(cr, uid, ids, product.id, context=context)
if product.event_type_id and order_line.event_ticket_id and order_line.event_ticket_id.price != product.lst_price:
res.update({'price_unit': order_line.event_ticket_id.price})
return res

View File

@ -1,7 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_event_event_public,event.event.public,event.model_event_event,base.group_public,1,0,0,0 access_event_event_public,event.event.public,event.model_event_event,base.group_public,1,0,0,0
access_event_type_public,event.type.public,event.model_event_type,base.group_public,1,0,0,0 access_event_type_public,event.type.public,event.model_event_type,base.group_public,1,0,0,0
access_event_event_ticket_public,event.event.ticket.public,event_sale.model_event_event_ticket,,1,0,0,0
access_event_event_ticket_admin,event.event.ticket.admin,event_sale.model_event_event_ticket,event.group_event_manager,1,1,1,1
access_event_product_product_public,event.product.product.public,product.model_product_product,base.group_public,1,0,0,0
access_event_product_template_public,event.product.template.public,product.model_product_template,base.group_public,1,0,0,0

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_event_event_public event.event.public event.model_event_event base.group_public 1 0 0 0
3 access_event_type_public event.type.public event.model_event_type base.group_public 1 0 0 0
access_event_event_ticket_public event.event.ticket.public event_sale.model_event_event_ticket 1 0 0 0
access_event_event_ticket_admin event.event.ticket.admin event_sale.model_event_event_ticket event.group_event_manager 1 1 1 1
access_event_product_product_public event.product.product.public product.model_product_product base.group_public 1 0 0 0
access_event_product_template_public event.product.template.public product.model_product_template base.group_public 1 0 0 0

View File

@ -11,25 +11,5 @@
<field name="perm_create" eval="False"/> <field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/> <field name="perm_unlink" eval="False"/>
</record> </record>
<record id="event_event_ticket_public" model="ir.rule">
<field name="name">event ticket: Public</field>
<field name="model_id" ref="event_sale.model_event_event_ticket"/>
<field name="domain_force">[('event_id.website_published', '=', True)]</field>
<field name="groups" eval="[(4, ref('base.group_public')), (4, ref('base.group_portal'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
<record id="event_product_template_public" model="ir.rule">
<field name="name">Product template linked to event: Public</field>
<field name="model_id" ref="product.model_product_template"/>
<field name="domain_force">[('product_variant_ids.event_ticket_ids.event_id.website_published', '=', True)]</field>
<field name="groups" eval="[(4, ref('base.group_public')), (4, ref('base.group_portal'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
</data> </data>
</openerp> </openerp>

View File

@ -70,14 +70,14 @@
content: "This is your new event page. We will edit the event presentation page.", content: "This is your new event page. We will edit the event presentation page.",
template: self.popover({ next: "OK" }), template: self.popover({ next: "OK" }),
}, },
{ // {
stepId: 'event-price', // stepId: 'event-price',
element: '[data-oe-field=price]', // element: '[data-oe-field=price]',
placement: 'top', // placement: 'top',
title: "Ticket price", // title: "Ticket price",
content: "Edit your ticket price.", // content: "Edit your ticket price.",
template: self.popover({ next: "OK" }), // template: self.popover({ next: "OK" }),
}, // },
{ {
stepId: 'add-banner', stepId: 'add-banner',
element: 'button[data-action=snippet]', element: 'button[data-action=snippet]',

View File

@ -59,12 +59,6 @@
<ul class="media-list"> <ul class="media-list">
<li t-foreach="event_ids" t-as="event" class="media"> <li t-foreach="event_ids" t-as="event" class="media">
<div class="media-body"> <div class="media-body">
<t t-if="event.state in ['draft', 'confirm'] and event.event_ticket_ids">
<span t-if="not event.seats_available" class="label label-danger pull-right">Sold Out</span>
<span t-if="event.seats_available and event.seats_available &lt;= ((event.seats_max or 0) / 4)" class="label pull-right label-info">
Only <t t-esc="event.seats_available"/> Remaining
</span>
</t>
<h4 class="media-heading"> <h4 class="media-heading">
<a t-att-class="event.state == 'done' and 'text-success'" t-href="/event/#{ slug(event) }/#{(not event.menu_id) and 'register/' or ''}"><span t-field="event.name"> </span></a> <a t-att-class="event.state == 'done' and 'text-success'" t-href="/event/#{ slug(event) }/#{(not event.menu_id) and 'register/' or ''}"><span t-field="event.name"> </span></a>
<small t-if="not event.website_published" class="label label-danger">not published</small> <small t-if="not event.website_published" class="label label-danger">not published</small>
@ -274,52 +268,6 @@
<template id="event_description_full"> <template id="event_description_full">
<t t-call="website_event.event_details"> <t t-call="website_event.event_details">
<div class="col-md-8"> <div class="col-md-8">
<form t-action="/event/add_cart?event_id=#{ event.id }" method="post" t-if="event.event_ticket_ids">
<table class="table table-striped">
<thead>
<tr>
<th>Ticket Type</th>
<th style="min-width: 100px">Sales End</th>
<th style="min-width: 100px">Price</th>
<th></th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr t-foreach="event.event_ticket_ids" t-as="ticket">
<td>
<div t-field="ticket.name"/>
<div><small t-field="ticket.product_id.description_sale"/></div>
</td>
<td><span t-field="ticket.deadline"/></td>
<td>
<t t-if="ticket.price or editable"><span t-field="ticket.price" t-field-options='{
"widget": "monetary",
"display_currency": "website.pricelist_id.currency_id"
}'/>
</t>
<t t-if="not ticket.price and not editable">
<span>Free</span>
</t>
</td>
<td>
<span t-if="ticket.seats_max and ((ticket.seats_reserved or 0)*100 / ticket.seats_max)&gt;75" class="text-muted">
<t t-esc="ticket.seats_max - ticket.seats_reserved"/> <span>left</span>
</span>
</td>
<td>
<select t-if="ticket.seats_available" t-attf-name="ticket-#{ ticket.id }" class="form-control">
<t t-foreach="range(0, ticket.seats_available > 9 and 10 or ticket.seats_available+1 )" t-as="nb"><option t-esc="nb"/></t>
</select>
<span t-if="not ticket.seats_available">Sold Out</span>
</td>
</tr>
</tbody>
</table>
<button type="submit" class="btn btn-primary btn-lg pull-right" t-if="event.seats_available">Order Now</button>
<div class="clearfix"/>
<hr/>
</form>
<div t-field="event.description"></div> <div t-field="event.description"></div>
<div class="clearfix"/> <div class="clearfix"/>
<ul class="media-list" id="comment"> <ul class="media-list" id="comment">

View File

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import controllers
import models

View File

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
{
'name': "Online Event's Tickets",
'category': 'Hidden',
'summary': "Sell Your Event's Tickets",
'version': '1.0',
'description': """
Online Event's Tickets
======================
""",
'author': 'OpenERP SA',
'depends': ['website_event', 'event_sale', 'website_sale'],
'data': [
'views/website_event_sale.xml',
'security/ir.model.access.csv',
'security/website_event_sale.xml',
],
'qweb': ['static/src/xml/*.xml'],
'installable': True,
'auto_install': True
}

View File

@ -0,0 +1 @@
import main

View File

@ -0,0 +1,80 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2013-Today OpenERP SA (<http://www.openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import SUPERUSER_ID
from openerp.addons.web import http
from openerp.addons.web.http import request
from openerp.addons.website_event.controllers.main import website_event
class website_event(website_event):
@http.route(['/event/add_cart'], type='http', auth="public", website=True, multilang=True)
def add_cart(self, event_id, **post):
user_obj = request.registry['res.users']
order_line_obj = request.registry.get('sale.order.line')
ticket_obj = request.registry.get('event.event.ticket')
order_obj = request.registry.get('sale.order')
website = request.registry['website']
order = website.ecommerce_get_current_order(request.cr, request.uid, context=request.context)
if not order:
order = website.ecommerce_get_new_order(request.cr, request.uid, context=request.context)
partner_id = user_obj.browse(request.cr, SUPERUSER_ID, request.uid,
context=request.context).partner_id.id
fields = [k for k, v in order_line_obj._columns.items()]
values = order_line_obj.default_get(request.cr, SUPERUSER_ID, fields,
context=request.context)
_values = None
for key, value in post.items():
try:
quantity = int(value)
except:
quantity = None
ticket_id = key.split("-")[0] == 'ticket' and int(key.split("-")[1]) or None
if not ticket_id or not quantity:
continue
ticket = ticket_obj.browse(request.cr, request.uid, ticket_id,
context=request.context)
values['product_id'] = ticket.product_id.id
values['event_id'] = ticket.event_id.id
values['event_ticket_id'] = ticket.id
values['product_uom_qty'] = quantity
values['price_unit'] = ticket.price
values['order_id'] = order.id
values['name'] = "%s: %s" % (ticket.event_id.name, ticket.name)
# change and record value
pricelist_id = order.pricelist_id and order.pricelist_id.id or False
_values = order_line_obj.product_id_change(
request.cr, SUPERUSER_ID, [], pricelist_id, ticket.product_id.id,
partner_id=partner_id, context=request.context)['value']
_values.update(values)
order_line_id = order_line_obj.create(request.cr, SUPERUSER_ID, _values, context=request.context)
order_obj.write(request.cr, SUPERUSER_ID, [order.id], {'order_line': [(4, order_line_id)]}, context=request.context)
if not _values:
return request.redirect("/event/%s/" % event_id)
return request.redirect("/shop/checkout")

View File

@ -0,0 +1,3 @@
import product
import sale_order
import website

View File

@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
from openerp.osv import osv, fields
# defined for access rules
class product(osv.osv):
_inherit = 'product.product'
_columns = {
'event_ticket_ids': fields.one2many('event.event.ticket', 'product_id', 'Event Tickets'),
}

View File

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
from openerp.osv import osv
from openerp import SUPERUSER_ID
from openerp.addons.web.http import request
class sale_order_line(osv.osv):
_inherit = "sale.order.line"
def _recalculate_product_values(self, cr, uid, ids, product_id=0, context=None):
if not ids:
return super(sale_order_line, self)._recalculate_product_values(cr, uid, ids, product_id, context=context)
order_line = self.browse(cr, SUPERUSER_ID, ids[0], context=context)
assert order_line.order_id.website_session_id == request.httprequest.session['website_session_id']
product = product_id and self.pool.get('product.product').browse(cr, uid, product_id, context=context) or order_line.product_id
res = super(sale_order_line, self)._recalculate_product_values(cr, uid, ids, product.id, context=context)
if product.event_type_id and order_line.event_ticket_id and order_line.event_ticket_id.price != product.lst_price:
res.update({'price_unit': order_line.event_ticket_id.price})
return res

View File

@ -0,0 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_event_event_ticket_public,event.event.ticket.public,event_sale.model_event_event_ticket,,1,0,0,0
access_event_event_ticket_admin,event.event.ticket.admin,event_sale.model_event_event_ticket,event.group_event_manager,1,1,1,1
access_event_product_product_public,event.product.product.public,product.model_product_product,base.group_public,1,0,0,0
access_event_product_template_public,event.product.template.public,product.model_product_template,base.group_public,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_event_event_ticket_public event.event.ticket.public event_sale.model_event_event_ticket 1 0 0 0
3 access_event_event_ticket_admin event.event.ticket.admin event_sale.model_event_event_ticket event.group_event_manager 1 1 1 1
4 access_event_product_product_public event.product.product.public product.model_product_product base.group_public 1 0 0 0
5 access_event_product_template_public event.product.template.public product.model_product_template base.group_public 1 0 0 0

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="event_event_ticket_public" model="ir.rule">
<field name="name">event ticket: Public</field>
<field name="model_id" ref="event_sale.model_event_event_ticket"/>
<field name="domain_force">[('event_id.website_published', '=', True)]</field>
<field name="groups" eval="[(4, ref('base.group_public')), (4, ref('base.group_portal'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
<record id="event_product_template_public" model="ir.rule">
<field name="name">Product template linked to event: Public</field>
<field name="model_id" ref="product.model_product_template"/>
<field name="domain_force">[('product_variant_ids.event_ticket_ids.event_id.website_published', '=', True)]</field>
<field name="groups" eval="[(4, ref('base.group_public')), (4, ref('base.group_portal'))]"/>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="False"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
</data>
</openerp>

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="index" inherit_id="website_event.index" name="Event's Ticket">
<xpath expr="//li[@t-foreach='event_ids']/div/h4" position="before">
<t t-if="event.state in ['draft', 'confirm'] and event.event_ticket_ids">
<span t-if="not event.seats_available" class="label label-danger pull-right">Sold Out</span>
<span t-if="event.seats_available and event.seats_available &lt;= ((event.seats_max or 0) / 4)" class="label pull-right label-info">
Only <t t-esc="event.seats_available"/> Remaining
</span>
</t>
</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">
<xpath expr="//div[@t-field='event.description']" position="before">
<form t-action="/event/add_cart?event_id=#{ event.id }" method="post" t-if="event.event_ticket_ids">
<table class="table table-striped">
<thead>
<tr>
<th>Ticket Type</th>
<th style="min-width: 100px">Sales End</th>
<th style="min-width: 100px">Price</th>
<th></th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr t-foreach="event.event_ticket_ids" t-as="ticket">
<td>
<div t-field="ticket.name"/>
<div><small t-field="ticket.product_id.description_sale"/></div>
</td>
<td><span t-field="ticket.deadline"/></td>
<td>
<t t-if="ticket.price or editable"><span t-field="ticket.price" t-field-options='{
"widget": "monetary",
"display_currency": "website.pricelist_id.currency_id"
}'/>
</t>
<t t-if="not ticket.price and not editable">
<span>Free</span>
</t>
</td>
<td>
<span t-if="ticket.seats_max and ((ticket.seats_reserved or 0)*100 / ticket.seats_max)&gt;75" class="text-muted">
<t t-esc="ticket.seats_max - ticket.seats_reserved"/> <span>left</span>
</span>
</td>
<td>
<select t-if="ticket.seats_available" t-attf-name="ticket-#{ ticket.id }" class="form-control">
<t t-foreach="range(0, ticket.seats_available > 9 and 10 or ticket.seats_available+1 )" t-as="nb"><option t-esc="nb"/></t>
</select>
<span t-if="not ticket.seats_available">Sold Out</span>
</td>
</tr>
</tbody>
</table>
<button type="submit" class="btn btn-primary btn-lg pull-right" t-if="event.seats_available">Order Now</button>
<div class="clearfix"/>
<hr/>
</form>
</xpath>
</template>
</data>
</openerp>

View File

@ -355,7 +355,7 @@ class Ecommerce(http.Controller):
context=request.context) context=request.context)
return request.redirect("/shop/mycart/") return request.redirect("/shop/mycart/")
@http.route(['/shop/add_cart_json/'], type='json', auth="public", website=True) @http.route(['/shop/add_cart_json/'], type='json', auth="public", website=True, multilang=True)
def add_cart_json(self, product_id=None, order_line_id=None, remove=None): def add_cart_json(self, product_id=None, order_line_id=None, remove=None):
quantity = request.registry['website']._ecommerce_add_product_to_cart(request.cr, request.uid, quantity = request.registry['website']._ecommerce_add_product_to_cart(request.cr, request.uid,
product_id=product_id, order_line_id=order_line_id, number=(remove and -1 or 1), product_id=product_id, order_line_id=order_line_id, number=(remove and -1 or 1),
@ -366,11 +366,12 @@ class Ecommerce(http.Controller):
order.amount_total, order.amount_total,
request.website._render("website_sale.total", {'website_sale_order': order})] request.website._render("website_sale.total", {'website_sale_order': order})]
@http.route(['/shop/set_cart_json/'], type='json', auth="public", website=True) @http.route(['/shop/set_cart_json/'], type='json', auth="public")
def set_cart_json(self, path=None, product_id=None, order_line_id=None, set_number=0, json=None): def set_cart_json(self, path=None, product_id=None, order_line_id=None, set_number=0, json=None):
return request.registry['website']._ecommerce_add_product_to_cart(request.cr, request.uid, quantity = request.registry['website']._ecommerce_add_product_to_cart(request.cr, request.uid,
product_id=product_id, order_line_id=order_line_id, set_number=set_number, product_id=product_id, order_line_id=order_line_id, set_number=set_number,
context=request.context) context=request.context)
return quantity
@http.route(['/shop/checkout/'], type='http', auth="public", website=True, multilang=True) @http.route(['/shop/checkout/'], type='http', auth="public", website=True, multilang=True)
def checkout(self, **post): def checkout(self, **post):
@ -724,7 +725,7 @@ class Ecommerce(http.Controller):
return request.website.render("website_sale.confirmation", {'order': order}) return request.website.render("website_sale.confirmation", {'order': order})
@http.route(['/shop/change_sequence/'], type='json', auth="public", website=True) @http.route(['/shop/change_sequence/'], type='json', auth="public")
def change_sequence(self, id, sequence): def change_sequence(self, id, sequence):
product_obj = request.registry.get('product.template') product_obj = request.registry.get('product.template')
if sequence == "top": if sequence == "top":
@ -736,7 +737,7 @@ class Ecommerce(http.Controller):
elif sequence == "down": elif sequence == "down":
product_obj.set_sequence_down(request.cr, request.uid, [id], context=request.context) product_obj.set_sequence_down(request.cr, request.uid, [id], context=request.context)
@http.route(['/shop/change_styles/'], type='json', auth="public", website=True) @http.route(['/shop/change_styles/'], type='json', auth="public")
def change_styles(self, id, style_id): def change_styles(self, id, style_id):
product_obj = request.registry.get('product.template') product_obj = request.registry.get('product.template')
product = product_obj.browse(request.cr, request.uid, id, context=request.context) product = product_obj.browse(request.cr, request.uid, id, context=request.context)
@ -758,7 +759,7 @@ class Ecommerce(http.Controller):
return not active return not active
@http.route(['/shop/change_size/'], type='json', auth="public", website=True) @http.route(['/shop/change_size/'], type='json', auth="public")
def change_size(self, id, x, y): def change_size(self, id, x, y):
product_obj = request.registry.get('product.template') product_obj = request.registry.get('product.template')
product = product_obj.browse(request.cr, request.uid, id, context=request.context) product = product_obj.browse(request.cr, request.uid, id, context=request.context)

View File

@ -87,6 +87,7 @@ class Website(orm.Model):
# values initialisation # values initialisation
quantity = 0 quantity = 0
values = {} values = {}
order_line_ids = []
if order_line_id: if order_line_id:
order_line_val = order_line_obj.read(cr, SUPERUSER_ID, [order_line_id], [], context=context)[0] order_line_val = order_line_obj.read(cr, SUPERUSER_ID, [order_line_id], [], context=context)[0]
if not product_id: if not product_id:
@ -102,23 +103,22 @@ class Website(orm.Model):
fields = [k for k, v in order_line_obj._columns.items()] fields = [k for k, v in order_line_obj._columns.items()]
values = order_line_obj.default_get(cr, SUPERUSER_ID, fields, context=context) values = order_line_obj.default_get(cr, SUPERUSER_ID, fields, context=context)
quantity = 1 quantity = 1
order_line_ids = []
# change and record value # change and record value
vals = order_line_obj._recalculate_product_values(cr, uid, order_line_ids, product_id, context=context) if quantity:
values.update(vals) vals = order_line_obj._recalculate_product_values(cr, uid, order_line_ids, product_id, context=context)
values.update(vals)
values['product_uom_qty'] = quantity
values['product_id'] = product_id
values['order_id'] = order.id
values['product_uom_qty'] = quantity if order_line_id:
values['product_id'] = product_id order_line_obj.write(cr, SUPERUSER_ID, order_line_ids, values, context=context)
values['order_id'] = order.id else:
order_line_id = order_line_obj.create(cr, SUPERUSER_ID, values, context=context)
if order_line_id: order_obj.write(cr, SUPERUSER_ID, [order.id], {'order_line': [(4, order_line_id)]}, context=context)
order_line_obj.write(cr, SUPERUSER_ID, [order_line_id], values, context=context) elif order_line_ids:
if not quantity: order_line_obj.unlink(cr, SUPERUSER_ID, order_line_ids, context=context)
order_line_obj.unlink(cr, SUPERUSER_ID, [order_line_id], context=context)
else:
order_line_id = order_line_obj.create(cr, SUPERUSER_ID, values, context=context)
order_obj.write(cr, SUPERUSER_ID, [order.id], {'order_line': [(4, order_line_id)]}, context=context)
order = self.ecommerce_get_current_order(cr, uid, context=context) order = self.ecommerce_get_current_order(cr, uid, context=context)
if not order or not order.order_line: if not order or not order.order_line:

View File

@ -534,7 +534,6 @@
</table> </table>
<t t-call="website_sale.total"/> <t t-call="website_sale.total"/>
<div class="clearfix"/> <div class="clearfix"/>
<a href="/shop" class="btn btn-default mb32"><span class="fa fa-long-arrow-left"/> Continue Shopping</a>
<a t-if="website_sale_order and website_sale_order.website_order_line" href="/shop/checkout/" class="btn btn-primary pull-right mb32">Process Checkout <span class="fa fa-long-arrow-right"/></a> <a t-if="website_sale_order and website_sale_order.website_order_line" href="/shop/checkout/" class="btn btn-primary pull-right mb32">Process Checkout <span class="fa fa-long-arrow-right"/></a>
<div class="oe_structure"/> <div class="oe_structure"/>
</div> </div>
@ -558,6 +557,14 @@
</t> </t>
</template> </template>
<template id="continue_shopping" inherit_id="website_sale.mycart" inherit_option_id="website_sale.mycart" 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>
<!-- Page Shop --> <!-- Page Shop -->
<template id="products_categories" inherit_option_id="website_sale.products" name="Product Categories"> <template id="products_categories" inherit_option_id="website_sale.products" name="Product Categories">