Commit Graph

64 Commits

Author SHA1 Message Date
Olivier Dony caf333eb59 [FIX] account.invoice.report: performance problem in currency rate computation
The SQL view implementing the "Invoice Analysis" report
JOINs the res.currency.rate table in order to obtain the
correct currency rate to convert each invoice line amount
in the same currency.

The matching of the rate needs to be done on the date
of that rate (`name` column) - the last rate preceding
the invoice date is presumed to be the right one.
However there is no simple way to make a direct JOIN between
account.invoice.line and res.currency.rate with a single
match, without using an ORDER BY clause and LIMIT 1.
This requires a costly SUBSELECT query for each invoice
line, quickly becoming prohibitive.

Through the use of PostgreSQL's Common Table Expressions
(CTE) it is possible to construct a temporary table
with the rates' start and end date of application.
This temporary table can then be used in a direct
JOIN with account.invoice.line, delivering much better
performance (no SUBSELECT needed for each invoice line)

On a database with 50k invoice lines this makes invoice
analysis return results in less than 800 ms instead of
10+ seconds.
2015-04-30 00:20:12 +02:00
Christophe Simonis 33a8989d77 [MERGE] forward port of branch saas-3 up to d73eeab 2015-02-11 16:40:01 +01:00
Christophe Simonis d73eeab5ba [MERGE] forward port of branch 7.0 up to 9fe040e 2015-02-11 16:39:11 +01:00
Denis Ledoux 9fe040e592 [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
2015-02-11 13:10:54 +01:00
Martin Trigaux 3c3f54549a [FIX] account: typo in 45485fe
My bad, blame the heat
2015-02-10 14:11:08 +05:30
Alexis de Lattre 45485fe1d6 [FIX] account: multicompany with currency rates
A record rule exists on currencies but not on rates.
If creates multiple currencies with rate = 1, we could fetch the wrong one in
the search and get a security exception while trying to convert rates.
Fixes #3323, opw 626353
2015-02-10 14:06:29 +05:30
Denis Ledoux c331e963cd [FIX] account: invoice analysis product quantity
This rev. is related to 6641c61ce6

During the above revision, a new jointure has been added
with product_uom, on product template uom_id
The join link was wrong, it was:
 - LEFT JOIN product_uom u2 ON u.id = pt.uom_id
and it must be:
 - LEFT JOIN product_uom u2 ON u2.id = pt.uom_id

 as the alias 'u' is the previous jointure, not this new one.

Besides, the uom_name is now the name
of the product uom of this second jointure
As the uom is now the product default uom
instead of the category reference uom

The groupby clause has been adapted, as the selection was slightly altered
Besides, grouping by u.uom_type, u.category_id was pointless
2015-02-04 20:28:48 +01:00
Goffin Simon 6641c61ce6 [FIX]report:wrong uom for "product_qty in invoices analysis
opw:626411
2015-02-03 08:52:42 +01:00
qdc f57787e07e [IMP] Cleaning of reporting (group_by, filters), adding new favourites and default views, some renaming (py and xml files) 2014-08-26 11:56:49 +02:00
Christophe Simonis 5a5f811d23 [REVERT] commit 5e5c73e
Branch 8.0 is a **stable** branch. This mean no database schema
changes.
2014-08-22 13:59:22 +02:00
qdc 5e5c73e7ba [IMP] Cleaning of reporting (group_by, filters), adding new favourites and default views, some renaming (py and xml files) 2014-08-22 09:49:09 +02:00
Raphael Collet 2398f480cd [IMP] addons: add _depends on models backed up by an sql view and used by other models 2014-07-08 15:32:38 +02:00
Gery Debongnie 4b3076e955 [IMP] improves the reporting views in account module (work on the Pivot tables, and remove some useless day/month/year attributes) (addon account)
bzr revid: ged@openerp.com-20140129160348-230nvcutbdqh1hx1
2014-01-29 17:03:48 +01:00
Quentin (OpenERP) f2e942ac44 [IMP] account: added the possibility to group by country in invoice analysis, uppon urgent request of fp
bzr revid: qdp-launchpad@openerp.com-20130514120518-2u7j3xaslxj8j1c7
2013-05-14 14:05:18 +02:00
Quentin (OpenERP) 33f27b362b [MERGE] forward port of addons v7 up to revision 9045
bzr revid: qdp-launchpad@openerp.com-20130422153449-c62emljfa4a49758
2013-04-22 17:34:49 +02:00
Vo Minh Thu e69326ee3b [REF] removed explicit model instanciations.
bzr revid: vmt@openerp.com-20130415102349-vgcrfok2k5y10cwz
2013-04-15 12:23:49 +02:00
Quentin (OpenERP) 50c9f116a5 [FIX] account: fixed invoice analysis in multi-currency.
bzr revid: qdp-launchpad@openerp.com-20130321185541-21uce7bzo82y059g
2013-03-21 19:55:41 +01:00
Cecile Tonglet a3939acfa5 [FIX] replace from/import decimal_precision by from/import openerp.addons.decimal_precision
bzr revid: cto@openerp.com-20121217152303-8e3b1x30rlw9cb0d
2012-12-17 16:23:03 +01:00
Vo Minh Thu e7f4891d46 [IMP] use the openerp namespace.
bzr revid: vmt@openerp.com-20121206145632-0h1coh5aaem65wsy
2012-12-06 15:56:32 +01:00
Quentin (OpenERP) b75fde3773 [FIX] account, sale_crm: fixed invoices analysis
bzr revid: qdp-launchpad@openerp.com-20121129134842-cro77z9siesjifdm
2012-11-29 14:48:42 +01:00
Quentin (OpenERP) b6997b7c74 [FIX] account: not enough argument given during format string
bzr revid: qdp-launchpad@openerp.com-20121129130346-ewydqj74l8h9qrby
2012-11-29 14:03:46 +01:00
Quentin (OpenERP) 7a50367e84 [IMP] account: optimized the account invoice analysis report to lower the response time. Removed the fields due_delay and delay_to_pay that were the reasons of the bad performances besides being a bit useless and having wrong values computed
bzr revid: qdp-launchpad@openerp.com-20121129101228-6cxv07svxnbabfr0
2012-11-29 11:12:28 +01:00
Vijaykumar Baladaniya d17568d572 [IMP] Add section_id in the invoice analysis report.
bzr revid: vba@tinyerp.com-20121121101909-hez6fxcqcyn3njy8
2012-11-21 15:49:09 +05:30
Vijaykumar Baladaniya 4cbd5c58fc [IMP]Add section_id in the invoice analysis report.
bzr revid: vba@tinyerp.com-20121121055817-3sw9yoac1xv12l2i
2012-11-21 11:28:17 +05:30
Mayur Maheshwari (OpenERP) 8346293d72 [MERGE]: Merge with lp:openobject-addons
bzr revid: mma@tinyerp.com-20121015090200-irfaskfn9i1p68j9
bzr revid: mma@tinyerp.com-20121016052513-vl56jxtp7xbpa2ry
2012-10-16 10:55:13 +05:30
Quentin (OpenERP) b5b9bc9872 [FIX] account, invoice analysis report: fixed 2 bugs in multi-currency environments (1) wrong currency rate chosen for transformation into base currency because of missing 'order by' statement; (2) re-transformation of amounts into user's currency instead of leaving them in base currency (rate=1)
bzr revid: qdp-launchpad@openerp.com-20121015112530-6bbo1xia2f3i5fzf
2012-10-15 13:25:30 +02:00
Mayur Maheshwari (OpenERP) 0b87880029 [IMP]all: imporve string state to status
bzr revid: mma@tinyerp.com-20121012114258-w2q3hg1wb5wlt8wi
2012-10-12 17:12:58 +05:30
Fabien Pinckaers 5c791531aa [IMP] improved typos
bzr revid: fp@tinyerp.com-20120522161055-6013qr1s4p773hoj
2012-05-22 18:10:55 +02:00
Saurang Suthar (OpenERP) 2ad3b32160 [IMP]:improved title Minimum Salesman by Salesperson everywhere
bzr revid: ssu@tinyerp.com-20120504121326-nqpx2eyqc1qrp04w
2012-05-04 17:43:26 +05:30
Jagdish Panchal (Open ERP) 7f9855ee2c [IMP] UOM to Unit of Measure everywhere in account and Picking and Invoicing Policy to Invoicing Policy in sale/res_config.py
bzr revid: jap@tinyerp.com-20120425070825-r8z56xhz42dpthep
2012-04-25 12:38:25 +05:30
Kuldeep Joshi (OpenERP) a082f8a977 [IMP] account: remove address filed
bzr revid: kjo@tinyerp.com-20120305101605-swk7at0hi1ghcr4c
2012-03-05 15:46:05 +05:30
Kuldeep Joshi (OpenERP) fd384fe645 [IMP] account : remove invoice address
bzr revid: kjo@tinyerp.com-20120305064845-aezglwmj86fi2ndc
2012-03-05 12:18:45 +05:30
ARA (OpenERP) ba5429610f [REM] account: removing total with tax field from invoice anlysis report
bzr revid: ara@tinyerp.com-20110510115133-r34pmomampl983x5
2011-05-10 17:21:33 +05:30
Quentin (OpenERP) 4d24d51f03 [MERGE] lp: 748178 (+ improved button label)
bzr revid: qdp-launchpad@openerp.com-20110506113252-24701a0nxguw4jaz
2011-05-06 13:32:52 +02:00
Ferdinand @ Camptocamp 0cf43b7857 [FIX] account: Improved invoice analysis report for calculation of total without tax
lp bug: https://launchpad.net/bugs/748178 fixed

bzr revid: pso@tinyerp.com-20110413073211-nktkleb1izezr7o0
2011-04-13 13:02:11 +05:30
Jay Vora (OpenERP) 3b75f9a266 [MERGE] Merged Tejas' branch for the fix of invoice analysis query (Ref : Cases 4963,5061
bzr revid: jvo@tinyerp.com-20110407122955-oa38ldo2abtfxbr4
2011-04-07 17:59:55 +05:30
Tejas (OpenERP) 787f38b5c5 FIX : Account Invoice Report, append active and limit 1 with subquery
bzr revid: tta@openerp.com-20110407115220-f1qp273vl3gpa6ke
2011-04-07 17:22:20 +05:30
qdp-launchpad@tinyerp.com afca671b1b [FIX] account: invoice analysis enhanced in order to avoid having crashes because of zero division (if a line has qtty = 0..)
bzr revid: qdp-launchpad@tinyerp.com-20110125162808-v8c5y97800szf741
2011-01-25 17:28:08 +01:00
qdp-launchpad@tinyerp.com da2b68f725 [FIX] account: invoice analysis enhanced in order to avoid having crashes because of zero division (if a line has qtty = 0..)
bzr revid: qdp-launchpad@tinyerp.com-20110125141833-0ih3owdepldifts3
2011-01-25 15:18:33 +01:00
pso a0c6493743 [FIX] account, sale, purchase: Improved analysis report
lp bug: https://launchpad.net/bugs/673835 fixed

bzr revid: pso@tinyerp.com-20101220122422-kqao990cf3q582df
2010-12-20 17:54:22 +05:30
Fabien Pinckaers 256bca359d [IMP] better useability
bzr revid: fp@tinyerp.com-20101009160143-rrcfgoyudey22zv4
2010-10-09 18:01:43 +02:00
ARA(OpenERP) 78862490d1 [IMP] Account: invoice analysis report with new field => avg due delay
bzr revid: mra@mra-laptop-20100924115017-qxjexskl8v99xtrs
2010-09-24 17:20:17 +05:30
pap (openerp) 8117491765 [IMP] Account: renamed term fiscal position to term fiscal mapping and other related terms accordingly in all the files
bzr revid: pap@tinyerp.co.in-20100916135102-w2wb0au8kdijabkt
2010-09-16 19:21:02 +05:30
qdp-launchpad@tinyerp.com e20699efa6 [FIX] account, invoice analysis: 1) price_total_tax was wrongly computed 2) invoices in other currency than the company currency are now correclty computed
bzr revid: qdp-launchpad@tinyerp.com-20100908092435-fez0zyv7wql4r651
2010-09-08 11:24:35 +02:00
vra 754a0cec0d [FIX] account: Fixed AVG calculation in invoice analysis statistic report.
bzr revid: vra@tinyerp.com-20100831070148-fyyz311ind2kizne
2010-08-31 12:31:48 +05:30
Mustufa Rangwala 451388d0b9 [IMP] Account: Invoice analysis report improved
bzr revid: mra@mra-laptop-20100814032558-ze1d30hpkczh5duj
2010-08-14 08:55:58 +05:30
Mustufa Rangwala 3eb486b62a [IMP] Account: invoice analysis=> remove reconciled field
bzr revid: mra@mra-laptop-20100813120607-6xdp3ay212y3kcdq
2010-08-13 17:36:07 +05:30
Mantavya Gajjar 3adba48137 [FIX]: fix a problme bug/544287 - partner_bank to be partner_bank_id
lp bug: https://launchpad.net/bugs/544287 fixed

bzr revid: mga@tinyerp.com-20100719134709-7vuwjnto8s5p43jz
2010-07-19 19:17:09 +05:30
apa-tiny 2e8f20a49c [FIX]:account:Invoice Analysis:improved avereage delay
bzr revid: apa@tinyerp.com-20100708120706-93lfy7hbbvhv9d40
2010-07-08 17:37:06 +05:30
apa-tiny 86d52f1a90 [FIX]:account:Invoice Analysis:improved average price
bzr revid: apa@tinyerp.com-20100708113913-xjk08pc4zi5qoly3
2010-07-08 17:09:13 +05:30