From aad8079c73aa35ea70c7add456c3798e4eeff12c Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 22 Nov 2016 16:37:37 +0100 Subject: [PATCH 1/3] [FIX] website_sale: Empty quantity in website cart Empty quantity on a line in the website cart didn't delete the line. opw:694361 --- addons/website_sale/static/src/js/website_sale.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index a48483b5349..cc6a57e2796 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -143,7 +143,7 @@ $('.oe_website_sale').each(function () { if ($input.data('update_change')) { return; } - var value = parseInt($input.val(), 10); + var value = parseInt($input.val() || 0, 10); var $dom = $(this).closest('tr'); var default_price = parseFloat($dom.find('.text-danger > span.oe_currency_value').text()); var $dom_optional = $dom.nextUntil(':not(.optional_product.info)'); @@ -164,7 +164,7 @@ $('.oe_website_sale').each(function () { 'set_qty': value}) .then(function (data) { $input.data('update_change', false); - if (value !== parseInt($input.val(), 10)) { + if (value !== parseInt($input.val() || 0, 10)) { $input.trigger('change'); return; } @@ -211,7 +211,7 @@ $('.oe_website_sale').each(function () { var product_id = +$input.closest('*:has(input[name="product_id"])').find('input[name="product_id"]').val(); var min = parseFloat($input.data("min") || 0); var max = parseFloat($input.data("max") || Infinity); - var quantity = ($link.has(".fa-minus").length ? -1 : 1) + parseFloat($input.val(),10); + var quantity = ($link.has(".fa-minus").length ? -1 : 1) + parseFloat($input.val() || 0, 10); // if they are more of one input for this product (eg: option modal) $('input[name="'+$input.attr("name")+'"]').add($input).filter(function () { var $prod = $(this).closest('*:has(input[name="product_id"])'); From 1c58ff30bd5e61c644242292acec86ba1d5242a1 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 23 Nov 2016 09:44:55 +0100 Subject: [PATCH 2/3] [FIX] account: _get_analytic_amount_currency When creating a timesheet with several lines, it creates several analytic lines and it raised an error: "Expected singleton" opw:694722 --- addons/account/models/account_analytic_line.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_analytic_line.py b/addons/account/models/account_analytic_line.py index c5c0d5ed746..94a7cdb28eb 100644 --- a/addons/account/models/account_analytic_line.py +++ b/addons/account/models/account_analytic_line.py @@ -25,7 +25,8 @@ class AccountAnalyticLine(models.Model): partner_id = fields.Many2one('res.partner', related='account_id.partner_id', string='Partner', store=True, readonly=True) def _get_analytic_amount_currency(self): - self.analytic_amount_currency = abs(self.amount_currency) * copysign(1, self.amount) + for line in self: + line.analytic_amount_currency = abs(line.amount_currency) * copysign(1, line.amount) @api.v8 @api.onchange('product_id', 'product_uom_id', 'unit_amount', 'currency_id') From aa7d1ab9d1b14a68e421ee254d31d3eb6ef04207 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 23 Nov 2016 15:47:14 +0100 Subject: [PATCH 3/3] [FIX] account: invoice tracebacks When the company field is empty on an invoice, tracebacks occur. Fixes #14410 opw-694476 --- addons/account/models/account_invoice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 8a2b74b0083..3841f66e16d 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -49,7 +49,7 @@ class AccountInvoice(models.Model): self.amount_total = self.amount_untaxed + self.amount_tax amount_total_company_signed = self.amount_total amount_untaxed_signed = self.amount_untaxed - if self.currency_id and self.currency_id != self.company_id.currency_id: + if self.currency_id and self.company_id and self.currency_id != self.company_id.currency_id: currency_id = self.currency_id.with_context(date=self.date_invoice) amount_total_company_signed = currency_id.compute(self.amount_total, self.company_id.currency_id) amount_untaxed_signed = currency_id.compute(self.amount_untaxed, self.company_id.currency_id) @@ -1103,7 +1103,7 @@ class AccountInvoiceLine(models.Model): if self.invoice_line_tax_ids: taxes = self.invoice_line_tax_ids.compute_all(price, currency, self.quantity, product=self.product_id, partner=self.invoice_id.partner_id) self.price_subtotal = price_subtotal_signed = taxes['total_excluded'] if taxes else self.quantity * price - if self.invoice_id.currency_id and self.invoice_id.currency_id != self.invoice_id.company_id.currency_id: + if self.invoice_id.currency_id and self.invoice_id.company_id and self.invoice_id.currency_id != self.invoice_id.company_id.currency_id: price_subtotal_signed = self.invoice_id.currency_id.compute(price_subtotal_signed, self.invoice_id.company_id.currency_id) sign = self.invoice_id.type in ['in_refund', 'out_refund'] and -1 or 1 self.price_subtotal_signed = price_subtotal_signed * sign