-
+
diff --git a/addons/base_address_city/models/res_partner.py b/addons/base_address_city/models/res_partner.py
index f8f01119e7d..c9ee67f2c7b 100644
--- a/addons/base_address_city/models/res_partner.py
+++ b/addons/base_address_city/models/res_partner.py
@@ -31,13 +31,13 @@ class Partner(models.Model):
replacement_xml = """
-
- sale
-
+
diff --git a/addons/mass_mailing/wizard/mail_compose_message.py b/addons/mass_mailing/wizard/mail_compose_message.py
index 8f28f6b5244..6545a239bdb 100644
--- a/addons/mass_mailing/wizard/mail_compose_message.py
+++ b/addons/mass_mailing/wizard/mail_compose_message.py
@@ -62,7 +62,8 @@ class MailComposeMessage(models.TransientModel):
if mail_values.get('email_to'):
recips = tools.email_split(mail_values['email_to'])
else:
- recips = tools.email_split(partners_email.get(res_id))
+ partner_id = (mail_values.get('recipient_ids') or [(False, '')])[0][1]
+ recips = tools.email_split(partners_email.get(partner_id))
mail_to = recips[0].lower() if recips else False
if (blacklist and mail_to in blacklist) or (seen_list and mail_to in seen_list):
# prevent sending to blocked addresses that were included by mistake
diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py
index a30f33228f7..becca5a266a 100644
--- a/addons/point_of_sale/models/pos_order.py
+++ b/addons/point_of_sale/models/pos_order.py
@@ -506,7 +506,13 @@ class PosOrder(models.Model):
'|',
('credit_move_id.move_id', '=', move.id),
('debit_move_id.move_id', '=', move.id)], limit=1)
- partial_reconcile.create_tax_cash_basis_entry(cash_basis_percentage_before_rec[move])
+ if partial_reconcile:
+ # In case none of the order debit move lines have been reconciled
+ # there is no need to create the tax cash basis entries as nothing has been reconciled
+ # a known case is when the the bank journal credit account is set to a receivable account,
+ # which has as effect to fully reconcile the payment line with its counterpart,
+ # leaving no payment lines to reconcile with the order debit lines.
+ partial_reconcile.create_tax_cash_basis_entry(cash_basis_percentage_before_rec[move])
def _filtered_for_reconciliation(self):
filter_states = ['invoiced', 'done']
diff --git a/addons/point_of_sale/static/src/js/chrome.js b/addons/point_of_sale/static/src/js/chrome.js
index 5099e40989b..a049417d98d 100644
--- a/addons/point_of_sale/static/src/js/chrome.js
+++ b/addons/point_of_sale/static/src/js/chrome.js
@@ -742,9 +742,6 @@ var Chrome = PosBaseWidget.extend(AbstractAction.prototype, {
if(err.message === 'XmlHttpRequestError '){
title = 'Network Failure (XmlHttpRequestError)';
body = 'The Point of Sale could not be loaded due to a network problem.\n Please check your internet connection.';
- }else if(err.message === 'TLSError'){
- title = 'Https connection to IoT Box failed';
- body = 'Make sure you are using IoT Box v18.10 or higher.\n\n Navigate to ' + err.url + ' to accept the certificate of your IoT Box.';
}else if(err.code === 200){
title = err.data.message;
body = err.data.debug;
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js
index 27950760e5b..1b4ba84437c 100644
--- a/addons/point_of_sale/static/src/js/models.js
+++ b/addons/point_of_sale/static/src/js/models.js
@@ -135,11 +135,16 @@ exports.PosModel = Backbone.Model.extend({
done.resolve();
},
function(statusText, url){
- if (statusText == 'error' && window.location.protocol == 'https:') {
- var error = {message: 'TLSError', url: url};
- self.chrome.loading_error(error);
- } else {
- done.resolve();
+ var show_loading_error = (self.gui.current_screen === null);
+ done.resolve();
+ if (show_loading_error && statusText == 'error' && window.location.protocol == 'https:') {
+ self.gui.show_popup('alert', {
+ title: _t('HTTPS connection to IoT Box failed'),
+ body: _.str.sprintf(
+ _t('Make sure you are using IoT Box v18.12 or higher. Navigate to %s to accept the certificate of your IoT Box.'),
+ url
+ ),
+ });
}
});
return done;
diff --git a/addons/product/models/product.py b/addons/product/models/product.py
index 68adb54aaf4..551e8705ce3 100644
--- a/addons/product/models/product.py
+++ b/addons/product/models/product.py
@@ -12,6 +12,7 @@ from odoo.addons import decimal_precision as dp
from odoo.tools import float_compare, pycompat
+
class ProductCategory(models.Model):
_name = "product.category"
_description = "Product Category"
@@ -508,7 +509,10 @@ class ProductProduct(models.Model):
precision = self.env['decimal.precision'].precision_get('Product Unit of Measure')
res = self.env['product.supplierinfo']
- for seller in self._prepare_sellers(params):
+ sellers = self._prepare_sellers(params)
+ if self.env.context.get('force_company'):
+ sellers = sellers.filtered(lambda s: not s.company_id or s.company_id.id == self.env.context['force_company'])
+ for seller in sellers:
# Set quantity in UoM of seller
quantity_uom_seller = quantity
if quantity_uom_seller and uom_id and uom_id != seller.product_uom:
diff --git a/addons/product/views/product_views.xml b/addons/product/views/product_views.xml
index 1da4cdcc99e..465c84dddcc 100644
--- a/addons/product/views/product_views.xml
+++ b/addons/product/views/product_views.xml
@@ -237,8 +237,9 @@
-
+
+
diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py
index e039995505a..7840665bb64 100644
--- a/addons/purchase/models/purchase.py
+++ b/addons/purchase/models/purchase.py
@@ -999,7 +999,7 @@ class ProcurementRule(models.Model):
def _get_purchase_order_date(self, product_id, product_qty, product_uom, values, partner, schedule_date):
"""Return the datetime value to use as Order Date (``date_order``) for the
Purchase Order created to satisfy the given procurement. """
- seller = product_id._select_seller(
+ seller = product_id.with_context(force_company=values['company_id'].id)._select_seller(
partner_id=partner,
quantity=product_qty,
date=fields.Date.to_string(schedule_date),
@@ -1009,7 +1009,7 @@ class ProcurementRule(models.Model):
def _update_purchase_order_line(self, product_id, product_qty, product_uom, values, line, partner):
procurement_uom_po_qty = product_uom._compute_quantity(product_qty, product_id.uom_po_id)
- seller = product_id._select_seller(
+ seller = product_id.with_context(force_company=values['company_id'].id)._select_seller(
partner_id=partner,
quantity=line.product_qty + procurement_uom_po_qty,
date=line.order_id.date_order and line.order_id.date_order[:10],
diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py
index 15118b17096..cffed9290f6 100644
--- a/addons/stock/models/stock_inventory.py
+++ b/addons/stock/models/stock_inventory.py
@@ -3,7 +3,7 @@
from odoo import api, fields, models, _
from odoo.addons import decimal_precision as dp
-from odoo.exceptions import UserError
+from odoo.exceptions import UserError, ValidationError
from odoo.tools import float_utils
@@ -148,13 +148,13 @@ class Inventory(models.Model):
if self.filter == 'none' and self.product_id and self.location_id and self.lot_id:
return
if self.filter not in ('product', 'product_owner') and self.product_id:
- raise UserError(_('The selected inventory options are not coherent.'))
+ raise ValidationError(_('The selected inventory options are not coherent.'))
if self.filter != 'lot' and self.lot_id:
- raise UserError(_('The selected inventory options are not coherent.'))
+ raise ValidationError(_('The selected inventory options are not coherent.'))
if self.filter not in ('owner', 'product_owner') and self.partner_id:
- raise UserError(_('The selected inventory options are not coherent.'))
+ raise ValidationError(_('The selected inventory options are not coherent.'))
if self.filter != 'pack' and self.package_id:
- raise UserError(_('The selected inventory options are not coherent.'))
+ raise ValidationError(_('The selected inventory options are not coherent.'))
def action_reset_product_qty(self):
self.mapped('line_ids').write({'product_qty': 0})
@@ -387,7 +387,7 @@ class InventoryLine(models.Model):
"""
for line in self:
if line.product_id.type != 'product':
- raise UserError(_("You can only adjust stockable products.") + '\n\n%s -> %s' % (line.product_id.display_name, line.product_id.type))
+ raise ValidationError(_("You can only adjust stockable products.") + '\n\n%s -> %s' % (line.product_id.display_name, line.product_id.type))
def _get_quants(self):
return self.env['stock.quant'].search([
diff --git a/addons/stock/wizard/stock_immediate_transfer.py b/addons/stock/wizard/stock_immediate_transfer.py
index 66a652ac795..9b46a91c585 100644
--- a/addons/stock/wizard/stock_immediate_transfer.py
+++ b/addons/stock/wizard/stock_immediate_transfer.py
@@ -22,7 +22,7 @@ class StockImmediateTransfer(models.TransientModel):
picking.action_assign()
if picking.state != 'assigned':
raise UserError(_("Could not reserve all requested products. Please use the \'Mark as Todo\' button to handle the reservation manually."))
- for move in picking.move_lines:
+ for move in picking.move_lines.filtered(lambda m: m.state not in ['done', 'cancel']):
for move_line in move.move_line_ids:
move_line.qty_done = move_line.product_uom_qty
if picking._check_backorder():
diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py
index 770fb443fe1..d8fa7d0aea1 100644
--- a/addons/stock_account/models/stock.py
+++ b/addons/stock_account/models/stock.py
@@ -303,7 +303,7 @@ class StockMove(models.Model):
if qty_to_take_on_candidates == 0:
move.write({
'value': -tmp_value if not quantity else move.value or -tmp_value, # outgoing move are valued negatively
- 'price_unit': -tmp_value / move.product_qty,
+ 'price_unit': -tmp_value / (move.product_qty or quantity),
})
elif qty_to_take_on_candidates > 0:
last_fifo_price = new_standard_price or move.product_id.standard_price
diff --git a/addons/survey/static/src/js/survey.js b/addons/survey/static/src/js/survey.js
index f2d5e50fbbe..e8d4972abcd 100644
--- a/addons/survey/static/src/js/survey.js
+++ b/addons/survey/static/src/js/survey.js
@@ -97,7 +97,7 @@ if(!the_form.length) {
}
// checkboxes and radios
- the_form.find("input[name^=" + key + "][type!='text']").each(function(){
+ the_form.find("input[name=" + key + "][type!='text']").each(function(){
$(this).val(value);
});
});
diff --git a/addons/web_editor/static/src/js/editor/rte.summernote.js b/addons/web_editor/static/src/js/editor/rte.summernote.js
index 614ab4bfcf0..fc4241689e7 100644
--- a/addons/web_editor/static/src/js/editor/rte.summernote.js
+++ b/addons/web_editor/static/src/js/editor/rte.summernote.js
@@ -883,7 +883,10 @@ eventHandler.attach = function (oLayoutInfo, options) {
show_tooltip = true;
setTimeout(function () {
- if (!show_tooltip) return;
+ // Do not show tooltip on double-click and if there is already one
+ if (!show_tooltip || $target.attr('title') !== undefined) {
+ return;
+ }
$target.tooltip({title: _t('Double-click to edit'), trigger: 'manuel', container: 'body'}).tooltip('show');
setTimeout(function () {
$target.tooltip('destroy');
diff --git a/addons/web_editor/static/src/js/widgets/widgets.js b/addons/web_editor/static/src/js/widgets/widgets.js
index b9e2a3289a0..27a5e41d06a 100644
--- a/addons/web_editor/static/src/js/widgets/widgets.js
+++ b/addons/web_editor/static/src/js/widgets/widgets.js
@@ -900,7 +900,7 @@ var VideoWidget = MediaWidget.extend({
options = options || {};
// Video url patterns(youtube, instagram, vimeo, dailymotion, youku, ...)
- var ytRegExp = /^(?:(?:https?:)?\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;
+ var ytRegExp = /^(?:(?:https?:)?\/\/)?(?:www\.)?(?:youtu\.be\/|youtube(-nocookie)?\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((?:\w|-){11})(?:\S+)?$/;
var ytMatch = url.match(ytRegExp);
var insRegExp = /(.*)instagram.com\/p\/(.[a-zA-Z0-9]*)/;
@@ -927,8 +927,8 @@ var VideoWidget = MediaWidget.extend({
var autoplay = options.autoplay ? '?autoplay=1' : '?autoplay=0';
- if (ytMatch && ytMatch[1].length === 11) {
- $video.attr('src', '//www.youtube.com/embed/' + ytMatch[1] + autoplay);
+ if (ytMatch && ytMatch[2].length === 11) {
+ $video.attr('src', '//www.youtube' + (ytMatch[1] || '') + '.com/embed/' + ytMatch[2] + autoplay);
} else if (insMatch && insMatch[2].length) {
$video.attr('src', '//www.instagram.com/p/' + insMatch[2] + '/embed/');
videoType = 'ins';
diff --git a/addons/website/models/ir_qweb.py b/addons/website/models/ir_qweb.py
index 0f73bc469f5..0c7900e9a47 100644
--- a/addons/website/models/ir_qweb.py
+++ b/addons/website/models/ir_qweb.py
@@ -4,6 +4,7 @@ import re
from collections import OrderedDict
from odoo import models
+from odoo.addons.http_routing.models.ir_http import url_for
from odoo.http import request
@@ -37,10 +38,16 @@ class QWeb(models.AbstractModel):
if not website and options.get('website_id'):
website = self.env['website'].browse(options['website_id'])
- if not website or not website.cdn_activated:
+ if not website:
return atts
name = self.URL_ATTRS.get(tagName)
+ if request and name and name in atts:
+ atts[name] = url_for(atts[name])
+
+ if not website.cdn_activated:
+ return atts
+
if name and name in atts:
atts = OrderedDict(atts)
atts[name] = website.get_cdn_url(atts[name])
diff --git a/addons/website/tests/test_qweb.py b/addons/website/tests/test_qweb.py
index e73083a66b2..5df4898487e 100644
--- a/addons/website/tests/test_qweb.py
+++ b/addons/website/tests/test_qweb.py
@@ -2,7 +2,9 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import re
+import werkzeug
+import odoo
from odoo import tools
from odoo.modules.module import get_module_resource
from odoo.tests.common import TransactionCase
@@ -63,3 +65,123 @@ class TestQweb(TransactionCase):
"css": attachments[1].url,
"user_id": demo.id,
}).encode('utf8'))
+
+class MockObject(object):
+ _log_call = []
+ def __init__(self, *args, **kwargs):
+ self.__dict__ = kwargs
+ def __call__(self, *args, **kwargs):
+ self._log_call.append((args, kwargs))
+ return self
+ def __getitem__(self, index):
+ return self
+
+def werkzeugRaiseNotFound(*args, **kwargs):
+ raise werkzeug.exceptions.NotFound()
+
+class MockRequest(object):
+ """ Class with context manager mocking odoo.http.request for tests """
+ def __init__(self, env, website=None, context=None, multilang=True, routing=True):
+ app = MockObject(routing={
+ 'type': 'http',
+ 'website': True,
+ 'multilang': multilang,
+ })
+ app.get_db_router = app.bind = app.match = app
+ if not routing:
+ app.match = werkzeugRaiseNotFound
+ self.request = MockObject(
+ env=env, context=context or {}, db=None, debug=False,
+ website=website, httprequest=MockObject(
+ path='/hello/',
+ app=app
+ )
+ )
+ odoo.http._request_stack.push(self.request)
+ def __enter__(self):
+ return self.request
+ def __exit__(self, exc_type, exc_value, traceback):
+ odoo.http._request_stack.pop()
+
+class TestQwebProcessAtt(TransactionCase):
+ def setUp(self):
+ super(TestQwebProcessAtt, self).setUp()
+ self.website = self.env['website'].browse(1)
+ self.website.language_ids = self.env.ref('base.lang_en') + self.env.ref('base.lang_fr')
+ self.website.default_lang_id = self.env.ref('base.lang_en')
+ self.website.cdn_activated = True
+ self.website.cdn_url = "http://test.cdn"
+ self.website.cdn_filters = "\n".join(["^(/[a-z]{2}_[A-Z]{2})?/a$", "^/b$"])
+
+ def _test_att(self, url, expect, tag='a', attribute='href'):
+ self.assertEqual(
+ self.env['ir.qweb']._post_processing_att(tag, {attribute: url}, {}),
+ expect
+ )
+
+ def test_process_att_no_request(self):
+ # no request so no URL rewriting
+ self._test_att('/', {'href': '/'})
+ self._test_att('/en_US/', {'href': '/en_US/'})
+ self._test_att('/fr_FR/', {'href': '/fr_FR/'})
+ # no URL rewritting for CDN
+ self._test_att('/a', {'href': '/a'})
+
+ def test_process_att_no_website(self):
+ with MockRequest(self.env) as request:
+ # no website so URL rewriting
+ self._test_att('/', {'href': '/'})
+ self._test_att('/en_US/', {'href': '/en_US/'})
+ self._test_att('/fr_FR/', {'href': '/fr_FR/'})
+ # no URL rewritting for CDN
+ self._test_att('/a', {'href': '/a'})
+
+ def test_process_att_monolang_route(self):
+ with MockRequest(self.env, website=self.website, multilang=False) as request:
+ # lang not changed in URL but CDN enabled
+ self._test_att('/a', {'href': 'http://test.cdn/a'})
+ self._test_att('/en_US/a', {'href': 'http://test.cdn/en_US/a'})
+ self._test_att('/b', {'href': 'http://test.cdn/b'})
+ self._test_att('/en_US/b', {'href': '/en_US/b'})
+
+ def test_process_att_no_request_lang(self):
+ with MockRequest(self.env, self.website) as request:
+ self._test_att('/', {'href': '/'})
+ self._test_att('/en_US/', {'href': '/'})
+ self._test_att('/fr_FR/', {'href': '/fr_FR/'})
+
+ def test_process_att_with_request_lang(self):
+ with MockRequest(self.env, self.website, context={'lang': 'fr_FR'}) as request:
+ self._test_att('/', {'href': '/fr_FR/'})
+ self._test_att('/en_US/', {'href': '/'})
+ self._test_att('/fr_FR/', {'href': '/fr_FR/'})
+
+ def test_process_att_matching_cdn_and_lang(self):
+ with MockRequest(self.env, self.website) as request:
+ # lang prefix is added before CDN
+ self._test_att('/a', {'href': 'http://test.cdn/a'})
+ self._test_att('/en_US/a', {'href': 'http://test.cdn/a'})
+ self._test_att('/fr_FR/a', {'href': 'http://test.cdn/fr_FR/a'})
+ self._test_att('/b', {'href': 'http://test.cdn/b'})
+ self._test_att('/en_US/b', {'href': 'http://test.cdn/b'})
+ self._test_att('/fr_FR/b', {'href': '/fr_FR/b'})
+
+ def test_process_att_no_route(self):
+ with MockRequest(self.env, self.website, context={'lang': 'fr_FR'}, routing=False) as request:
+ # default on multilang=True if route is not /{module}/static/
+ self._test_att('/web/static/hi', {'href': '/web/static/hi'})
+ self._test_att('/my-page', {'href': '/fr_FR/my-page'})
+
+ def test_process_att_url_crap(self):
+ with MockRequest(self.env, self.website) as request:
+ # #{fragment} is stripped from URL when testing route
+ self._test_att('/x#y?z', {'href': '/x#y?z'})
+ self.assertEqual(
+ request.httprequest.app._log_call[-1],
+ (('/x',), {'method': 'POST', 'query_args': None})
+ )
+ self._test_att('/x?y#z', {'href': '/x?y#z'})
+ self.assertEqual(
+ request.httprequest.app._log_call[-1],
+ (('/x',), {'method': 'POST', 'query_args': 'y'})
+ )
diff --git a/doc/cla/individual/bletourmy.md b/doc/cla/individual/bletourmy.md
new file mode 100644
index 00000000000..1d51fcaf71d
--- /dev/null
+++ b/doc/cla/individual/bletourmy.md
@@ -0,0 +1,11 @@
+Switzerland, 2019-03-25
+
+I hereby agree to the terms of the Odoo Individual Contributor License
+Agreement v1.0.
+
+I declare that I am authorized and able to make this agreement and sign this
+declaration.
+
+Signed,
+
+Bernard Letourmy bernard.letourmy@gmail.com https://github.com/bletourmy
diff --git a/doc/cla/individual/matthewdwatkins.md b/doc/cla/individual/matthewdwatkins.md
new file mode 100644
index 00000000000..75f773aa5a4
--- /dev/null
+++ b/doc/cla/individual/matthewdwatkins.md
@@ -0,0 +1,11 @@
+USA, 2019-04-04
+
+I hereby agree to the terms of the Odoo Individual Contributor License
+Agreement v1.0.
+
+I declare that I am authorized and able to make this agreement and sign this
+declaration.
+
+Signed,
+
+Matthew Watkins mwatkins.bulk@gmail.com https://github.com/matthewdwatkins
diff --git a/odoo/addons/base/models/ir_module.py b/odoo/addons/base/models/ir_module.py
index 33ecb666d40..12887a1d5c7 100644
--- a/odoo/addons/base/models/ir_module.py
+++ b/odoo/addons/base/models/ir_module.py
@@ -21,6 +21,7 @@ from docutils.core import publish_string
from docutils.transforms import Transform, writer_aux
from docutils.writers.html4css1 import Writer
import lxml.html
+import psycopg2
import odoo
from odoo import api, fields, models, modules, tools, _
@@ -528,6 +529,14 @@ class Module(models.Model):
@api.multi
def _button_immediate_function(self, function):
+ try:
+ # This is done because the installation/uninstallation/upgrade can modify a currently
+ # running cron job and prevent it from finishing, and since the ir_cron table is locked
+ # during execution, the lock won't be released until timeout.
+ self._cr.execute("SELECT * FROM ir_cron FOR UPDATE NOWAIT")
+ except psycopg2.OperationalError:
+ raise UserError(_("The server is busy right now, module operations are not possible at"
+ " this time, please try again later."))
function(self)
self._cr.commit()
diff --git a/odoo/fields.py b/odoo/fields.py
index be097509072..0acacc0a6d3 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -922,7 +922,11 @@ class Field(MetaField('DummyField', (object,), {})):
"""
indexname = '%s_%s_index' % (model._table, self.name)
if self.index:
- sql.create_index(model._cr, indexname, model._table, ['"%s"' % self.name])
+ try:
+ with model._cr.savepoint():
+ sql.create_index(model._cr, indexname, model._table, ['"%s"' % self.name])
+ except psycopg2.OperationalError:
+ _schema.error("Unable to add index for %s", self)
else:
sql.drop_index(model._cr, indexname, model._table)