Merge branch 'master-akshar-05072018' into 'master-patch-july-2018'

Master akshar 05072018

See merge request flectra-hq/flectra!94
This commit is contained in:
Parthiv Patel 2018-07-13 09:28:02 +00:00
commit 89863abf7d
11 changed files with 50 additions and 16 deletions

View File

@ -16,7 +16,7 @@ class LivechatController(http.Controller):
# _get_asset return the bundle html code (script and link list) but we want to use the attachment content
xmlid = 'im_livechat.external_lib'
files, remains = request.env["ir.qweb"]._get_asset_content(xmlid, options=request.context)
asset = AssetsBundle(xmlid, files, remains)
asset = AssetsBundle(xmlid, files)
mock_attachment = getattr(asset, ext)()
if isinstance(mock_attachment, list): # suppose that CSS asset will not required to be split in pages

View File

@ -78,11 +78,14 @@ class IrTranslation(models.Model):
translation.transifex_url = False
continue
# e.g. 'https://www.transifex.com/flectra/flectra-10/translate/#fr/sale/42?q=Sale+Order'
# e.g. 'https://www.transifex.com/flectra/flectra-10/translate/#fr/sale/42?q=text'Sale+Order'
translation.transifex_url = "%(url)s/%(project)s/translate/#%(lang)s/%(module)s/42?q=%(src)s" % {
'url': base_url,
'project': project,
'lang': lang_code,
'module': translation.module,
'src': werkzeug.url_quote_plus(translation.source[:50]),
'src': werkzeug.url_quote_plus(
"text:'" +
translation.source[:50].replace("'", "\'") +
"'"),
}

View File

@ -434,6 +434,11 @@ class Post(models.Model):
raise KarmaError('User karma not sufficient to post an image or link.')
return content
@api.constrains('parent_id')
def _check_parent_id(self):
if not self._check_recursion():
raise ValidationError(_('You cannot create recursive forum posts.'))
@api.model
def create(self, vals):
if 'content' in vals and vals.get('forum_id'):

View File

@ -118,6 +118,7 @@ a.no-decoration {
.close.comment_delete {
font-size: 16px;
float: none;
}
.country_flag {

View File

@ -25,13 +25,14 @@ flectra.define('website_forum.website_forum', function (require) {
if ($('a[href*="/login"]').length) {
msg = _t('Sorry you must be logged in to perform this action');
}
var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert" id="karma_alert">'+
var $warning = $('<div class="alert alert-danger alert-dismissable oe_forum_alert mt8" id="karma_alert">'+
'<button type="button" class="close notification_close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
msg + '</div>');
var vote_alert = $(ev.currentTarget).parent().find("#vote_alert");
if (vote_alert.length === 0) {
$(ev.currentTarget).parent().append($warning);
var $voteAlert = $('#karma_alert');
if ($voteAlert.length) {
$voteAlert.remove();
}
$(ev.currentTarget).after($warning);
}
});

View File

@ -30,7 +30,7 @@
<!-- helper -->
<template id="link_button">
<form method="POST" t-att-action="url">
<form method="POST" t-att-action="url" t-attf-class="#{form_classes}">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<button t-attf-class="fa btn-link #{classes} #{karma and 'karma_required text-muted' or ''}" t-attf-data-karma="#{karma}">
<t t-esc="label"/></button>
@ -1096,6 +1096,7 @@
<t t-set="label"> </t>
<t t-set="karma" t-value="user.karma&lt;required_karma and required_karma or 0"/>
<t t-set="classes" t-value="'close comment_delete fa-times'"/>
<t t-set="form_classes" t-value="'pull-right'"/>
</t>
<div><span t-field="message.body" class="oe_no_empty"/></div>
@ -1108,7 +1109,8 @@
<t t-set="url" t-value="'/forum/' + slug(forum) + '/post/' + slug(object) + '/comment/' + slug(message) + '/convert_to_answer'"/>
<t t-set="label">Convert as an answer</t>
<t t-set="karma" t-value="user.karma&lt;required_karma and required_karma or 0"/>
<t t-set="classes" t-value="'fa-magic pull-right'"/>
<t t-set="classes" t-value="'fa-magic'"/>
<t t-set="form_classes" t-value="'pull-right'"/>
</t>
</t>
<a t-attf-href="/forum/#{slug(forum)}/partner/#{message.author_id.id}"
@ -1289,6 +1291,10 @@
<!--Private profile-->
<template id="private_profile">
<t t-call="website_forum.header">
<t t-set='head'>
<t t-raw='head'/>
<meta name="robots" content="noindex follow"/>
</t>
<h1 class="mt32">This profile is private!</h1>
<p>
<a t-attf-href="/forum/#{slug(forum)}">Return to the question list.</a>

View File

@ -67,8 +67,15 @@ class WebsiteSaleDelivery(WebsiteSale):
return {'status': order.delivery_rating_success,
'error_message': order.delivery_message,
'carrier_id': carrier_id,
'new_amount_delivery': float_repr(currency.round(order.delivery_price), currency.decimal_places),
'new_amount_untaxed': order.amount_untaxed,
'new_amount_tax': order.amount_tax,
'new_amount_total': order.amount_total,
'new_amount_delivery': self._format_amount(order.delivery_price, currency),
'new_amount_untaxed': self._format_amount(order.amount_untaxed, currency),
'new_amount_tax': self._format_amount(order.amount_tax, currency),
'new_amount_total': self._format_amount(order.amount_total, currency),
}
def _format_amount(self, amount, currency):
fmt = "%.{0}f".format(currency.decimal_places)
lang = request.env['res.lang']._lang_get(request.env.context.get('lang') or 'en_US')
return lang.format(fmt, currency.round(amount), grouping=True, monetary=True)\
.replace(r' ', u'\N{NO-BREAK SPACE}').replace(r'-', u'\u2011')

View File

@ -65,6 +65,7 @@ class SaleOrder(models.Model):
carrier = delivery
break
self.write({'carrier_id': carrier.id})
self._remove_delivery_line()
if carrier:
self.get_delivery_price()
if self.delivery_rating_success:

View File

@ -27,6 +27,10 @@ flectra.define('website_sale_delivery.checkout', function (require) {
else {
console.error(result.error_message);
$compute_badge.text(result.error_message);
$amount_delivery.text(result.new_amount_delivery);
$amount_untaxed.text(result.new_amount_untaxed);
$amount_tax.text(result.new_amount_tax);
$amount_total.text(result.new_amount_total);
}
};
@ -40,6 +44,12 @@ flectra.define('website_sale_delivery.checkout', function (require) {
var $carriers = $("#delivery_carrier input[name='delivery_type']");
$carriers.click(_onCarrierClick);
// Workaround to:
// - update the amount/error on the label at first rendering
// - prevent clicking on 'Pay Now' if the shipper rating fails
if ($carriers.length > 0) {
$carriers.filter(':checked').click();
}
/* Handle stuff */
$(".oe_website_sale select[name='shipping_id']").on('change', function () {

View File

@ -3,7 +3,7 @@
<template id="cart_delivery" name="Delivery Costs" inherit_id="website_sale.total">
<xpath expr="//div[@id='order_total_untaxed']" position="before">
<div class="row" id="order_delivery" t-if="website_sale_order and website_sale_order.has_delivery">
<div class="row" id="order_delivery" t-if="website_sale_order and website_sale_order.carrier_id">
<span class="col-xs-6 text-right text-muted" title="Delivery will be updated after choosing a new delivery method"> Delivery:</span>
<span class="col-xs-6 text-right-not-xs text-left-xs text-muted">
<span t-field="website_sale_order.amount_delivery" style="white-space: nowrap;" t-options='{

View File

@ -9,7 +9,7 @@ require('website_sale.website_sale');
$('.oe_website_sale #add_to_cart, .oe_website_sale #products_grid .a-submit')
.off('click')
.removeClass('a-submit')
.click(function (event) {
.click(_.debounce(function (event) {
var $form = $(this).closest('form');
var quantity = parseFloat($form.find('input[name="add_qty"]').val() || 1);
var product_id = parseInt($form.find('input[type="hidden"][name="product_id"], input[type="radio"][name="product_id"]:checked').first().val(),10);
@ -96,6 +96,6 @@ $('.oe_website_sale #add_to_cart, .oe_website_sale #products_grid .a-submit')
});
});
return false;
});
}, 200, true));
});