[MERGE] Forward-port 8.0 up to 46c5f93b6c
This commit is contained in:
@@ -204,11 +204,7 @@ class TxPaypal(osv.Model):
|
||||
|
||||
def _paypal_form_get_invalid_parameters(self, cr, uid, tx, data, context=None):
|
||||
invalid_parameters = []
|
||||
if data.get('notify_version')[0] != '3.4':
|
||||
_logger.warning(
|
||||
'Received a notification from Paypal with version %s instead of 2.6. This could lead to issues when managing it.' %
|
||||
data.get('notify_version')
|
||||
)
|
||||
_logger.info('Received a notification from Paypal with IPN version %s', data.get('notify_version'))
|
||||
if data.get('test_ipn'):
|
||||
_logger.warning(
|
||||
'Received a notification from Paypal using sandbox'
|
||||
|
||||
@@ -6187,13 +6187,20 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
|
||||
val = $li.data("id");
|
||||
}
|
||||
if (val != self.get('value')) {
|
||||
this.view.recursive_save().done(function() {
|
||||
var change = {};
|
||||
change[self.name] = val;
|
||||
self.view.dataset.write(self.view.datarecord.id, change).done(function() {
|
||||
self.view.reload();
|
||||
if(!this.view.datarecord.id ||
|
||||
this.view.datarecord.id.toString().match(instance.web.BufferedDataSet.virtual_id_regex)) {
|
||||
// don't save, only set value for not-yet-saved many2ones
|
||||
self.set_value(val);
|
||||
}
|
||||
else {
|
||||
this.view.recursive_save().done(function() {
|
||||
var change = {};
|
||||
change[self.name] = val;
|
||||
self.view.dataset.write(self.view.datarecord.id, change).done(function() {
|
||||
self.view.reload();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ 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.addons.website_sale.controllers.main import get_pricelist, website_sale
|
||||
from openerp.tools.translate import _
|
||||
|
||||
|
||||
@@ -89,3 +89,23 @@ class website_event(website_event):
|
||||
except ValueError:
|
||||
pass
|
||||
return super(website_event, self)._add_event(event_name, context, **kwargs)
|
||||
|
||||
|
||||
class website_sale(website_sale):
|
||||
|
||||
@http.route(['/shop/get_unit_price'], type='json', auth="public", methods=['POST'], website=True)
|
||||
def get_unit_price(self, product_ids, add_qty, use_order_pricelist=False, **kw):
|
||||
cr, uid, context, pool = request.cr, request.uid, request.context, request.registry
|
||||
res_ticket = {}
|
||||
if 'line_id' in kw:
|
||||
line = pool['sale.order.line'].browse(cr, SUPERUSER_ID, kw['line_id'])
|
||||
if line.event_ticket_id:
|
||||
if line.order_id.pricelist_id:
|
||||
ticket = pool['event.event.ticket'].browse(cr, SUPERUSER_ID, line.event_ticket_id.id, context=dict(context, pricelist=line.order_id.pricelist_id.id))
|
||||
else:
|
||||
ticket = line.event_ticket_id
|
||||
res_ticket = {ticket.product_id.id: ticket.price_reduce or ticket.price}
|
||||
product_ids.remove(ticket.product_id.id)
|
||||
res_options = super(website_sale, self).get_unit_price(product_ids, add_qty, use_order_pricelist, **kw)
|
||||
return dict(res_ticket.items() + res_options.items())
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import logging
|
||||
|
||||
from openerp import SUPERUSER_ID
|
||||
from openerp.osv import orm, fields
|
||||
from openerp.tools import float_compare
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -26,10 +27,20 @@ class PaymentTransaction(orm.Model):
|
||||
tx_find_method_name = '_%s_form_get_tx_from_data' % acquirer_name
|
||||
if hasattr(self, tx_find_method_name):
|
||||
tx = getattr(self, tx_find_method_name)(cr, uid, data, context=context)
|
||||
if tx and tx.state == 'done' and tx.acquirer_id.auto_confirm == 'at_pay_confirm' and tx.sale_order_id and tx.sale_order_id.state in ['draft', 'sent']:
|
||||
self.pool['sale.order'].action_button_confirm(cr, SUPERUSER_ID, [tx.sale_order_id.id], context=dict(context, send_email=True))
|
||||
elif tx and tx.state not in ['cancel'] and tx.sale_order_id and tx.sale_order_id.state in ['draft']:
|
||||
self.pool['sale.order'].force_quotation_send(cr, SUPERUSER_ID, [tx.sale_order_id.id], context=context)
|
||||
_logger.info('<%s> transaction processed: tx ref:%s, tx amount: %s', acquirer_name, tx.reference if tx else 'n/a', tx.amount if tx else 'n/a')
|
||||
|
||||
if tx and tx.sale_order_id:
|
||||
# verify SO/TX match, excluding tx.fees which are currently not included in SO
|
||||
amount_matches = (tx.sale_order_id.state in ['draft', 'sent'] and float_compare(tx.amount, tx.sale_order_id.amount_total, 2) == 0)
|
||||
if amount_matches:
|
||||
if tx.state == 'done' and tx.acquirer_id.auto_confirm == 'at_pay_confirm':
|
||||
_logger.info('<%s> transaction completed, auto-confirming order %s (ID %s)', acquirer_name, tx.sale_order_id.name, tx.sale_order_id.id)
|
||||
self.pool['sale.order'].action_button_confirm(cr, SUPERUSER_ID, [tx.sale_order_id.id], context=dict(context, send_email=True))
|
||||
elif tx.state != 'cancel' and tx.sale_order_id.state == 'draft':
|
||||
_logger.info('<%s> transaction pending/to confirm manually, sending quote email for order %s (ID %s)', acquirer_name, tx.sale_order_id.name, tx.sale_order_id.id)
|
||||
self.pool['sale.order'].force_quotation_send(cr, SUPERUSER_ID, [tx.sale_order_id.id], context=context)
|
||||
else:
|
||||
_logger.warning('<%s> transaction MISMATCH for order %s (ID %s)', acquirer_name, tx.sale_order_id.name, tx.sale_order_id.id)
|
||||
except Exception:
|
||||
_logger.exception('Fail to confirm the order or send the confirmation email%s', tx and ' for the transaction %s' % tx.reference or '')
|
||||
|
||||
|
||||
@@ -73,7 +73,8 @@ $('.oe_website_sale').each(function () {
|
||||
openerp.jsonRpc("/shop/get_unit_price", 'call', {
|
||||
'product_ids': product_ids,
|
||||
'add_qty': value,
|
||||
'use_order_pricelist': true})
|
||||
'use_order_pricelist': true,
|
||||
'line_id': line_id})
|
||||
.then(function (res) {
|
||||
//basic case
|
||||
$dom.find('span.oe_currency_value').last().text(res[product_id].toFixed(2));
|
||||
|
||||
Reference in New Issue
Block a user