[MERGE] forward port branch 11.0 up to 1b234b1be7

This commit is contained in:
Christophe Simonis
2019-08-21 16:58:16 +02:00
10 changed files with 30 additions and 16 deletions
+7 -6
View File
@@ -515,12 +515,13 @@ class AccountMoveLine(models.Model):
#compute the default credit/debit of the next line in case of a manual entry
balance = 0
for line in self._context['line_ids']:
if line[2]: # in case of command 0: add a record with values
balance += line[2].get('debit', 0) - line[2].get('credit', 0)
elif line[0] == 2: # line has been deleted
line_obj = self.browse(line[1])
balance -= line_obj.debit - line_obj.credit
for line in self.move_id.resolve_2many_commands(
'line_ids', self._context['line_ids'], fields=['credit', 'debit']):
balance += line.get('debit', 0) - line.get('credit', 0)
# if we are here, line_ids is in context, so journal_id should also be.
currency = self._context.get('journal_id') and self.browse(self._context['journal_id']).company_id.currency_id
if currency:
balance = currency.round(balance)
if balance < 0:
rec.update({'debit': -balance})
if balance > 0:
+5 -2
View File
@@ -80,7 +80,6 @@ class LivechatController(http.Controller):
@http.route('/im_livechat/feedback', type='json', auth='public')
def feedback(self, uuid, rate, reason=None, **kwargs):
Channel = request.env['mail.channel']
Rating = request.env['rating.rating']
channel = Channel.sudo().search([('uuid', '=', uuid)], limit=1)
if channel:
# limit the creation : only ONE rating per session
@@ -101,7 +100,11 @@ class LivechatController(http.Controller):
# if logged in user, set its partner on rating
values['partner_id'] = request.env.user.partner_id.id if request.session.uid else False
# create the rating
rating = Rating.sudo().create(values)
channel.write({
'rating_ids': [(0, False, values)]
})
rating = channel.rating_ids[0]
else:
rating = channel.rating_ids[0]
rating.write(values)
+1 -1
View File
@@ -15,7 +15,7 @@ This is the latest UK Odoo localisation necessary to run Odoo accounting for UK
- InfoLogic UK counties listing
- a few other adaptations""",
'author': 'SmartMode LTD',
'website': 'http://www.smartmode.co.uk',
'website': 'https://www.odoo.com/page/accounting',
'depends': [
'account',
'base_iban',
+6
View File
@@ -699,6 +699,12 @@ class PurchaseOrderLine(models.Model):
if move.location_dest_id.usage == "supplier":
if move.to_refund:
total -= move.product_uom._compute_quantity(move.product_uom_qty, line.product_uom)
elif move.origin_returned_move_id._is_dropshipped() and not move._is_dropshipped_returned():
# Edge case: the dropship is returned to the stock, no to the supplier.
# In this case, the received quantity on the PO is set although we didn't
# receive the product physically in our stock. To avoid counting the
# quantity twice, we do nothing.
pass
else:
total += move.product_uom._compute_quantity(move.product_uom_qty, line.product_uom)
line.qty_received = total
+1 -1
View File
@@ -324,7 +324,7 @@ var utils = {
}
var normalized_value = value / precision;
var epsilon_magnitude = Math.log(Math.abs(normalized_value))/Math.log(2);
var epsilon = Math.pow(2, epsilon_magnitude - 53);
var epsilon = Math.pow(2, epsilon_magnitude - 52);
normalized_value += normalized_value >= 0 ? epsilon : -epsilon;
/**
@@ -2095,14 +2095,16 @@ $.summernote.pluginEvents.applyFont = function (event, editor, layoutInfo, color
}
// apply font: foreColor, backColor, size (the color can be use a class text-... or bg-...)
var font, $font, fonts = [], className;
var ancestors, font, $font, fonts = [], className;
var i;
if (color || bgcolor || size) {
for (i=0; i<nodes.length; i++) {
node = nodes[i];
font = dom.ancestor(node, dom.isFont);
if (!font) {
ancestors = dom.listAncestor(node, dom.isFont);
font = ancestors.slice(-1)[0];
// add font if node is not inside a font or inside an anchor firstly
if (!dom.isFont(font) || ancestors.filter(dom.isAnchor).length) {
if (node.textContent.match(/^[ ]|[ ]$/)) {
node.textContent = node.textContent.replace(/^[ ]|[ ]$/g, '\u00A0');
}
@@ -9,7 +9,7 @@ class ProductAttributeCategory(models.Model):
_description = "Product Attribute Category"
_order = 'sequence'
name = fields.Char("Category Name", required=True)
name = fields.Char("Category Name", required=True, translate=True)
sequence = fields.Integer("Sequence", default=10)
+1 -1
View File
@@ -1242,7 +1242,7 @@ class IrModelAccess(models.Model):
else:
msg_tail = _("Please contact your system administrator if you think this is an error.") + "\n\n(" + _("Document model") + ": %s)"
msg_params = (model,)
msg_tail += ' - ({} {}, {} {})'.format(_('Operation:'), mode, _('User:'), self._uid)
msg_tail += u' - ({} {}, {} {})'.format(_('Operation:'), mode, _('User:'), self._uid)
_logger.info('Access Denied by ACLs for operation: %s, uid: %s, model: %s', mode, self._uid, model)
msg = '%s %s' % (msg_heads[mode], msg_tail)
raise AccessError(msg % msg_params)
+2
View File
@@ -27,6 +27,8 @@ class TestFloatPrecision(TransactionCase):
try_round(0.0049,'0.00') # 0.0049 is closer to 0 than to 0.01, so should round down
try_round(0.005,'0.01') # the rule is to round half away from zero
try_round(-0.005,'-0.01') # the rule is to round half away from zero
try_round(6.6 * 0.175, '1.16') # 6.6 * 0.175 is rounded to 1.15 with epsilon = 53
try_round(-6.6 * 0.175, '-1.16')
def try_zero(amount, expected):
self.assertEqual(currency.is_zero(amount), expected,
+1 -1
View File
@@ -73,7 +73,7 @@ def float_round(value, precision_digits=None, precision_rounding=None, rounding_
normalized_value = value / rounding_factor # normalize
sign = math.copysign(1.0, normalized_value)
epsilon_magnitude = math.log(abs(normalized_value), 2)
epsilon = 2**(epsilon_magnitude-53)
epsilon = 2**(epsilon_magnitude-52)
# TIE-BREAKING: UP/DOWN (for ceiling[resp. flooring] operations)
# When rounding the value up[resp. down], we instead subtract[resp. add] the epsilon value