[MERGE] forward port of branch 8.0 up to 92183e5
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp import models, fields, api, _
|
||||
import openerp.addons.decimal_precision as dp
|
||||
from openerp.exceptions import Warning
|
||||
|
||||
|
||||
@@ -9,7 +10,7 @@ class event_event(models.Model):
|
||||
|
||||
event_ticket_ids = fields.One2many(
|
||||
'event.event.ticket', 'event_id', string='Event Ticket',
|
||||
default=lambda rec: rec._default_tickets())
|
||||
default=lambda rec: rec._default_tickets(), copy=True)
|
||||
seats_max = fields.Integer(
|
||||
string='Maximum Available Seats',
|
||||
help="The maximum registration level is equal to the sum of the maximum registration of event ticket. " +
|
||||
@@ -49,7 +50,9 @@ class event_ticket(models.Model):
|
||||
required=True, domain=[("event_type_id", "!=", False)],
|
||||
default=lambda self: self._default_product_id())
|
||||
registration_ids = fields.One2many('event.registration', 'event_ticket_id', 'Registrations')
|
||||
price = fields.Float('Price')
|
||||
price = fields.Float('Price', digits=dp.get_precision('Product Price'))
|
||||
price_reduce = fields.Float("Price Reduce", compute="_get_price_compute", store=False,
|
||||
digits=dp.get_precision('Product Price'))
|
||||
deadline = fields.Date("Sales End")
|
||||
is_expired = fields.Boolean('Is Expired', compute='_is_expired', store=True)
|
||||
|
||||
@@ -71,6 +74,13 @@ class event_ticket(models.Model):
|
||||
current_date = fields.Date.context_today(self.with_context({'tz': self.event_id.date_tz}))
|
||||
self.is_expired = self.deadline < current_date
|
||||
|
||||
@api.one
|
||||
@api.depends('price', 'product_id.lst_price', 'product_id.price')
|
||||
def _get_price_compute(self):
|
||||
product = self.product_id
|
||||
discount = product.lst_price and (product.lst_price - product.price) / product.lst_price or 0.0
|
||||
self.price_reduce = (1.0 - discount) * self.price
|
||||
|
||||
seats_max = fields.Integer('Maximum Available Seats', help="You can for each event define a maximum registration level. If you have too much registrations you are not able to confirm your event. (put 0 to ignore this rule )")
|
||||
seats_reserved = fields.Integer(string='Reserved Seats', compute='_compute_seats', store=True)
|
||||
seats_available = fields.Integer(string='Available Seats', compute='_compute_seats', store=True)
|
||||
|
||||
@@ -33,6 +33,13 @@ class sale_order_line(osv.osv):
|
||||
'event_ok': fields.related('product_id', 'event_ok', string='event_ok', type='boolean'),
|
||||
}
|
||||
|
||||
def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, context=None):
|
||||
res = super(sale_order_line, self)._prepare_order_line_invoice_line(cr, uid, line, account_id=account_id, context=context)
|
||||
if line.event_id:
|
||||
event = self.pool['event.event'].read(cr, uid, line.event_id.id, ['name'], context=context)
|
||||
res['name'] = '%s: %s' % (res.get('name', ''), event['name'])
|
||||
return res
|
||||
|
||||
def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False,
|
||||
qty_uos=0, uos=False, name='', partner_id=False, lang=False,
|
||||
update_tax=True, date_order=False, packaging=False,
|
||||
|
||||
@@ -880,7 +880,7 @@ openerp.mail = function (session) {
|
||||
self.parent_thread.message_fetch(this.domain, this.context, false, function (arg, data) {
|
||||
self.id = false;
|
||||
// insert the message on dom after this message
|
||||
self.parent_thread.switch_new_message( data, self.$el.parent() );
|
||||
self.parent_thread.switch_new_message(data, self.$el);
|
||||
self.animated_destroy(200);
|
||||
});
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
##############################################################################
|
||||
|
||||
from openerp import api
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.exceptions import AccessError
|
||||
from openerp.osv import osv
|
||||
from openerp.tools import config, which
|
||||
@@ -98,7 +99,7 @@ class Report(osv.Model):
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
context.update(inherit_branding=True) # Tell QWeb to brand the generated html
|
||||
context = dict(context, inherit_branding=True) # Tell QWeb to brand the generated html
|
||||
|
||||
view_obj = self.pool['ir.ui.view']
|
||||
|
||||
@@ -199,7 +200,8 @@ class Report(osv.Model):
|
||||
headerhtml = []
|
||||
contenthtml = []
|
||||
footerhtml = []
|
||||
base_url = self.pool['ir.config_parameter'].get_param(cr, uid, 'web.base.url')
|
||||
irconfig_obj = self.pool['ir.config_parameter']
|
||||
base_url = irconfig_obj.get_param(cr, SUPERUSER_ID, 'report.url') or irconfig_obj.get_param(cr, SUPERUSER_ID, 'web.base.url')
|
||||
|
||||
# Minimal page renderer
|
||||
view_obj = self.pool['ir.ui.view']
|
||||
|
||||
@@ -844,6 +844,11 @@ class sale_order_line(osv.osv):
|
||||
WHERE rel.invoice_id = ANY(%s)""", (list(ids),))
|
||||
return [i[0] for i in cr.fetchall()]
|
||||
|
||||
def _get_price_reduce(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(ids, 0.0)
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
res[line.id] = line.price_subtotal / line.product_uom_qty
|
||||
return res
|
||||
|
||||
_name = 'sale.order.line'
|
||||
_description = 'Sales Order Line'
|
||||
@@ -860,6 +865,7 @@ class sale_order_line(osv.osv):
|
||||
}),
|
||||
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price'), readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'price_subtotal': fields.function(_amount_line, string='Subtotal', digits_compute= dp.get_precision('Account')),
|
||||
'price_reduce': fields.function(_get_price_reduce, type='float', string='Price Reduce', digits_compute=dp.get_precision('Product Price')),
|
||||
'tax_id': fields.many2many('account.tax', 'sale_order_tax', 'order_line_id', 'tax_id', 'Taxes', readonly=True, states={'draft': [('readonly', False)]}),
|
||||
'address_allotment_id': fields.many2one('res.partner', 'Allotment Partner',help="A partner to whom the particular product needs to be allotted."),
|
||||
'product_uom_qty': fields.float('Quantity', digits_compute= dp.get_precision('Product UoS'), required=True, readonly=True, states={'draft': [('readonly', False)]}),
|
||||
|
||||
@@ -467,7 +467,6 @@ class Home(http.Controller):
|
||||
@http.route('/web', type='http', auth="none")
|
||||
def web_client(self, s_action=None, **kw):
|
||||
ensure_db()
|
||||
|
||||
if request.session.uid:
|
||||
if kw.get('redirect'):
|
||||
return werkzeug.utils.redirect(kw.get('redirect'), 303)
|
||||
@@ -479,6 +478,11 @@ class Home(http.Controller):
|
||||
else:
|
||||
return login_redirect()
|
||||
|
||||
@http.route('/web/dbredirect', type='http', auth="none")
|
||||
def web_db_redirect(self, redirect='/', **kw):
|
||||
ensure_db()
|
||||
return werkzeug.utils.redirect(redirect, 303)
|
||||
|
||||
@http.route('/web/login', type='http', auth="none")
|
||||
def web_login(self, redirect=None, **kw):
|
||||
ensure_db()
|
||||
|
||||
@@ -23,11 +23,22 @@ 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
|
||||
from openerp.addons.website_sale.controllers.main import get_pricelist
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
class website_event(website_event):
|
||||
|
||||
@http.route(['/event/<model("event.event"):event>/register'], type='http', auth="public", website=True)
|
||||
def event_register(self, event, **post):
|
||||
pricelist_id = int(get_pricelist())
|
||||
values = {
|
||||
'event': event.with_context(pricelist=pricelist_id),
|
||||
'main_object': event.with_context(pricelist=pricelist_id),
|
||||
'range': range,
|
||||
}
|
||||
return request.website.render("website_event.event_description_full", values)
|
||||
|
||||
def _process_tickets_details(self, data):
|
||||
ticket_post = {}
|
||||
for key, value in data.iteritems():
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.osv import osv, fields
|
||||
from openerp.tools.translate import _
|
||||
import openerp.addons.decimal_precision as dp
|
||||
|
||||
# defined for access rules
|
||||
class sale_order(osv.Model):
|
||||
|
||||
@@ -19,12 +19,6 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="cart" inherit_id="website_sale.cart" name="My Cart Event's Price">
|
||||
<xpath expr="//td[@name='price']/t" position="attributes">
|
||||
<attribute name="t-if">abs(line.product_id.lst_price - line.price_unit) > 0.2 and not line.product_id.event_ok</attribute>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="registration_template" inherit_id="website_event.registration_template" customize_show="True" name="Event's Ticket form">
|
||||
<xpath expr="//tbody" position="replace">
|
||||
<tbody>
|
||||
@@ -43,7 +37,15 @@
|
||||
</t>
|
||||
</td>
|
||||
<td>
|
||||
<t t-if="ticket.price or editable"><span t-field="ticket.price" t-field-options='{
|
||||
<t t-if="ticket.price or editable">
|
||||
<t t-if="(ticket.price-ticket.price_reduce) > 1">
|
||||
<del class="text-danger" style="white-space: nowrap;" t-field="ticket.price" t-field-options='{
|
||||
"widget": "monetary",
|
||||
"from_currency": "website.currency_id",
|
||||
"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"
|
||||
}'/>&nbsp;
|
||||
</t>
|
||||
<span t-field="ticket.price_reduce" t-field-options='{
|
||||
"widget": "monetary",
|
||||
"display_currency": "website.pricelist_id.currency_id"
|
||||
}'/>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
this.$target.removeClass('has-error');
|
||||
|
||||
var email = $email.length ? $email.val() : false;
|
||||
if (email) {
|
||||
if (email || this.is_user) {
|
||||
openerp.jsonRpc('/website_mail/follow', 'call', {
|
||||
'id': +this.$target.data('id'),
|
||||
'object': this.$target.data('object'),
|
||||
@@ -53,7 +53,6 @@
|
||||
}
|
||||
},
|
||||
toggle_subscription: function(follow, email) {
|
||||
console.log(follow, email);
|
||||
follow = follow || (!email && this.$target.attr('data-unsubscribe'));
|
||||
if (follow) {
|
||||
this.$target.find(".js_follow_btn").addClass("hidden");
|
||||
|
||||
@@ -102,17 +102,20 @@ class QueryURL(object):
|
||||
return path
|
||||
|
||||
|
||||
def get_pricelist():
|
||||
cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
|
||||
sale_order = context.get('sale_order')
|
||||
if sale_order:
|
||||
pricelist = sale_order.pricelist_id
|
||||
else:
|
||||
partner = pool['res.users'].browse(cr, SUPERUSER_ID, uid, context=context).partner_id
|
||||
pricelist = partner.property_product_pricelist
|
||||
return pricelist
|
||||
|
||||
class website_sale(http.Controller):
|
||||
|
||||
def get_pricelist(self):
|
||||
cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
|
||||
sale_order = context.get('sale_order')
|
||||
if sale_order:
|
||||
pricelist = sale_order.pricelist_id
|
||||
else:
|
||||
partner = pool['res.users'].browse(cr, SUPERUSER_ID, uid, context=context).partner_id
|
||||
pricelist = partner.property_product_pricelist
|
||||
return pricelist
|
||||
return get_pricelist()
|
||||
|
||||
def get_attribute_value_ids(self, product):
|
||||
cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
|
||||
|
||||
@@ -624,15 +624,15 @@
|
||||
<div class="text-muted" t-field="line.name"/>
|
||||
</td>
|
||||
<td class="text-center" name="price">
|
||||
<t t-if="(compute_currency(line.product_id.lst_price) - line.price_unit) > 0.01">
|
||||
<t t-if="(line.price_unit - line.price_reduce) > 1">
|
||||
<del class="text-danger" style="white-space: nowrap;"
|
||||
t-field="line.product_id.lst_price" t-field-options='{
|
||||
t-field="line.price_unit" t-field-options='{
|
||||
"widget": "monetary",
|
||||
"from_currency": "website.currency_id",
|
||||
"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"
|
||||
}'/>&nbsp;
|
||||
</t>
|
||||
<span t-field="line.price_unit" style="white-space: nowrap;" t-field-options='{
|
||||
<span t-field="line.price_reduce" style="white-space: nowrap;" t-field-options='{
|
||||
"widget": "monetary",
|
||||
"display_currency": "user_id.partner_id.property_product_pricelist.currency_id"
|
||||
}'/>
|
||||
|
||||
@@ -57,6 +57,7 @@ addresses belonging to this country.\n\nYou can use the python-style string pate
|
||||
\n%(country_code)s: the code of the country"""),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency'),
|
||||
'image': fields.binary("Image"),
|
||||
'country_group_ids': fields.many2many('res.country.group', 'res_country_res_country_group_rel', 'res_country_id', 'res_country_group_id', string='Country Groups'),
|
||||
}
|
||||
_sql_constraints = [
|
||||
('name_uniq', 'unique (name)',
|
||||
@@ -89,7 +90,7 @@ class CountryGroup(osv.osv):
|
||||
_name = 'res.country.group'
|
||||
_columns = {
|
||||
'name': fields.char('Name', required=True),
|
||||
'country_ids': fields.many2many('res.country', string='Countries'),
|
||||
'country_ids': fields.many2many('res.country', 'res_country_res_country_group_rel', 'res_country_group_id', 'res_country_id', string='Countries'),
|
||||
}
|
||||
|
||||
class CountryState(osv.osv):
|
||||
|
||||
Reference in New Issue
Block a user