[IMP] account: invoice analysis pivot quantities

In the report "Invoice Analysis", the view under the report is grouping
lines by invoice and also by product on this invoice.

Thus, quantities in the pivot view are not the real quantity of invoice
lines, but of invoice lines with different products.

eg:

invoice a:
- line 1: product X
- line 2: product Y
- line 3: product X

in the report there would appear to only be 2 invoice line, whilst there
is in realy three (this information is accessible via "# of Lines").

closes #11954
opw-676651
This commit is contained in:
Nicolas Lempereur
2016-05-12 13:11:47 +02:00
parent 53f86de70d
commit f41bcda03b
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ msgstr ""
#. module: account
#: model:ir.model.fields,field_description:account.field_account_invoice_report_nbr
msgid "# of Invoices"
msgid "# of Lines"
msgstr ""
#. module: account
@@ -46,7 +46,7 @@ class AccountInvoiceReport(models.Model):
price_average = fields.Float(string='Average Price', readonly=True, group_operator="avg")
user_currency_price_average = fields.Float(string="Average Price", compute='_compute_amounts_in_user_currency', digits=0)
currency_rate = fields.Float(string='Currency Rate', readonly=True)
nbr = fields.Integer(string='# of Invoices', readonly=True) # TDE FIXME master: rename into nbr_lines
nbr = fields.Integer(string='# of Lines', readonly=True) # TDE FIXME master: rename into nbr_lines
type = fields.Selection([
('out_invoice', 'Customer Invoice'),
('in_invoice', 'Vendor Bill'),
@@ -102,12 +102,12 @@ class AccountInvoiceReport(models.Model):
def _sub_select(self):
select_str = """
SELECT min(ail.id) AS id,
SELECT ail.id AS id,
ai.date_invoice AS date,
ail.product_id, ai.partner_id, ai.payment_term_id, ail.account_analytic_id,
u2.name AS uom_name,
ai.currency_id, ai.journal_id, ai.fiscal_position_id, ai.user_id, ai.company_id,
count(ail.*) AS nbr,
1 AS nbr,
ai.type, ai.state, pt.categ_id, ai.date_due, ai.account_id, ail.account_id AS account_line_id,
ai.partner_bank_id,
SUM(CASE
@@ -146,7 +146,7 @@ class AccountInvoiceReport(models.Model):
def _group_by(self):
group_by_str = """
GROUP BY ail.product_id, ail.account_analytic_id, ai.date_invoice, ai.id,
GROUP BY ail.id, ail.product_id, ail.account_analytic_id, ai.date_invoice, ai.id,
ai.partner_id, ai.payment_term_id, u2.name, u2.id, ai.currency_id, ai.journal_id,
ai.fiscal_position_id, ai.user_id, ai.company_id, ai.type, ai.state, pt.categ_id,
ai.date_due, ai.account_id, ail.account_id, ai.partner_bank_id, ai.residual_company_signed,