From 2d524c947cc6ef51e1c2a40dd69a518c9586afc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Mon, 2 Feb 2015 16:22:42 +0100 Subject: [PATCH 1/2] [FIX] web: editable lists and read only fields bug when the user press tab in editable list views, the focus is supposed to go to the next cell unless it is at the last cell of the line. in that case, it is supposed to create a new record. Sadly, when the last cell is readonly, this does not work. This commit make sure that read only fields are properly ignored when computing the last_field state. --- addons/web/static/src/js/view_list_editable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 1fa3c0831b5..11a5d884f57 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -650,7 +650,7 @@ openerp.web.list_editable = function (instance) { var form = this.editor.form; var last_field = _(form.fields_order).chain() .map(function (name) { return form.fields[name]; }) - .filter(function (field) { return field.$el.is(':visible'); }) + .filter(function (field) { return field.$el.is(':visible') && !field.get('effective_readonly'); }) .last() .value(); // tabbed from last field in form From 9fe040e59237ebdacd4dd3c299a3e79428354651 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 11 Feb 2015 13:10:54 +0100 Subject: [PATCH 2/2] [FIX] account: invoice analysis residual amount When having an invoice with multiple lines having the same product_id and account_id, the residual amount was wrong. This is due to the fact the residual amount of each line was computed on the residual amount of the invoice divided by the number of lines of the invoice, and the fact the main select of the sql view was grouped by product_id, account_id. So, for an invoice defined as Product Account Total A 1 10 A 1 10 B 1 10 The invoice analysis, grouped by product, account, computed Product Account Total Residual A 1 20 10 B 1 10 10 The residual amount '10' of the first line being 30 (the residual amount of the invoice) divided by 3 (the number of lines in the invoice) The residual amount of the invoice should actually be divided by the number of lines in the invoice * the count of occurences in the group by clause So, in this case, (30 / 3) * 2 = 20 Replacing the big jointure by SELECT count(*) FROM account_invoice_line l where invoice_id = ai.id to get the number of lines in the invoice is just an optimization for performances opw-621672 --- addons/account/report/account_invoice_report.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 31725a46b46..0d2756ad23d 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -160,17 +160,8 @@ class account_invoice_report(osv.osv): WHEN ai.type::text = ANY (ARRAY['out_refund'::character varying::text, 'in_invoice'::character varying::text]) THEN - ai.residual ELSE ai.residual - END / CASE - WHEN (( SELECT count(l.id) AS count - FROM account_invoice_line l - LEFT JOIN account_invoice a ON a.id = l.invoice_id - WHERE a.id = ai.id)) <> 0 - THEN ( SELECT count(l.id) AS count - FROM account_invoice_line l - LEFT JOIN account_invoice a ON a.id = l.invoice_id - WHERE a.id = ai.id) - ELSE 1::bigint - END::numeric AS residual + END / (SELECT count(*) FROM account_invoice_line l where invoice_id = ai.id) * + count(*) AS residual """ return select_str