Merge lp:~openerp-dev/openobject-addons/trunk-bug-748178-pso into lp:openobject-addons

Proposed by Priyesh (OpenERP)
Status: Merged
Merged at revision: 4677
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-748178-pso
Merge into: lp:openobject-addons
Diff against target: 154 lines (+40/-31)
2 files modified
account/report/account_invoice_report.py (+37/-30)
account/report/account_invoice_report_view.xml (+3/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-748178-pso
Reviewer Review Type Date Requested Status
qdp (OpenERP) Approve
Mustufa Rangwala (Open ERP) (community) Approve
Review via email: mp+57449@code.launchpad.net

Description of the change

Fixed bug: 748178 (https://bugs.launchpad.net/openobject-addons/+bug/748178)
Improved invoice analysis report for computation of total without tax and removed average price from view

To post a comment you must log in.
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

@qdp:

We have to check: FIXME the line total incl tax can't be calculated by deviding the invoice total / number of lines.

But we can merge this branch other things are working.

thanks,
mra

review: Approve
Revision history for this message
qdp (OpenERP) (qdp) wrote :

why did you removed average_price from view?

Revision history for this message
Priyesh (OpenERP) (pso-openerp) wrote :

Hello Quentin,

As the average price field has "group_operator = avg" so in group by environment that field value will be totaled / the no of lines in that group which will result in a wrong value. because that field already has the average value. so it shows sum(average_value) / no of lines. now if we remove the group_operator then by default it show the sum of the two lines which is also incorrect.

So If you want, can I add that price_average field in invoice analysis view ?

Revision history for this message
qdp (OpenERP) (qdp) wrote :

i remember the problem, :-)

it's cool like this

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/report/account_invoice_report.py'
2--- account/report/account_invoice_report.py 2011-02-01 14:25:28 +0000
3+++ account/report/account_invoice_report.py 2011-04-13 08:55:51 +0000
4@@ -69,6 +69,7 @@
5 'address_contact_id': fields.many2one('res.partner.address', 'Contact Address Name', readonly=True),
6 'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address Name', readonly=True),
7 'account_id': fields.many2one('account.account', 'Account',readonly=True),
8+ 'account_line_id': fields.many2one('account.account', 'Account Line',readonly=True),
9 'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account',readonly=True),
10 'residual': fields.float('Total Residual', readonly=True),
11 'delay_to_pay': fields.float('Avg. Delay To Pay', readonly=True, group_operator="avg"),
12@@ -106,44 +107,48 @@
13 ai.address_contact_id as address_contact_id,
14 ai.address_invoice_id as address_invoice_id,
15 ai.account_id as account_id,
16+ ail.account_id as account_line_id,
17 ai.partner_bank_id as partner_bank_id,
18 sum(case when ai.type in ('out_refund','in_invoice') then
19- ail.quantity / u.factor * -1
20+ -ail.quantity / u.factor
21 else
22 ail.quantity / u.factor
23 end) as product_qty,
24+
25 sum(case when ai.type in ('out_refund','in_invoice') then
26- ail.quantity*ail.price_unit * -1
27+ -ail.price_subtotal
28 else
29- ail.quantity*ail.price_unit
30+ ail.price_subtotal
31 end) / cr.rate as price_total,
32+
33+--
34+-- FIXME the line total incl tax can't be caculated by deviding the invoice total / number of lines
35+--
36 sum(case when ai.type in ('out_refund','in_invoice') then
37- ai.amount_total * -1
38+ -ai.amount_total
39 else
40 ai.amount_total
41- end) / (CASE WHEN
42- (select count(l.id) from account_invoice_line as l
43- left join account_invoice as a ON (a.id=l.invoice_id)
44- where a.id=ai.id) <> 0
45- THEN
46- (select count(l.id) from account_invoice_line as l
47- left join account_invoice as a ON (a.id=l.invoice_id)
48- where a.id=ai.id)
49- ELSE 1
50+ end) / (CASE WHEN
51+ (select count(l.id) from account_invoice_line as l
52+ left join account_invoice as a ON (a.id=l.invoice_id)
53+ where a.id=ai.id) <> 0
54+ THEN
55+ (select count(l.id) from account_invoice_line as l
56+ left join account_invoice as a ON (a.id=l.invoice_id)
57+ where a.id=ai.id)
58+ ELSE 1
59 END) / cr.rate as price_total_tax,
60+
61 (case when ai.type in ('out_refund','in_invoice') then
62- sum(ail.quantity*ail.price_unit*-1)
63+ sum(-ail.price_subtotal)
64 else
65- sum(ail.quantity*ail.price_unit)
66- end) / (CASE WHEN
67- (case when ai.type in ('out_refund','in_invoice')
68- then sum(ail.quantity/u.factor*-1)
69- else sum(ail.quantity/u.factor) end) <> 0
70- THEN
71- (case when ai.type in ('out_refund','in_invoice')
72- then sum(ail.quantity/u.factor*-1)
73- else sum(ail.quantity/u.factor) end)
74- ELSE 1
75+ sum(ail.price_subtotal)
76+ end) / (CASE WHEN sum(ail.quantity/u.factor) <> 0
77+ THEN
78+ (case when ai.type in ('out_refund','in_invoice')
79+ then sum(-ail.quantity/u.factor)
80+ else sum(ail.quantity/u.factor) end)
81+ ELSE 1
82 END)
83 / cr.rate as price_average,
84
85@@ -159,22 +164,23 @@
86 left join account_invoice_line as l ON (a.id=l.invoice_id)
87 where a.id=ai.id)) as due_delay,
88 (case when ai.type in ('out_refund','in_invoice') then
89- ai.residual * -1
90+ -ai.residual
91 else
92 ai.residual
93- end)/ (CASE WHEN
94+ end)/ (CASE WHEN
95 (select count(l.id) from account_invoice_line as l
96 left join account_invoice as a ON (a.id=l.invoice_id)
97- where a.id=ai.id) <> 0
98+ where a.id=ai.id) <> 0
99 THEN
100 (select count(l.id) from account_invoice_line as l
101 left join account_invoice as a ON (a.id=l.invoice_id)
102- where a.id=ai.id)
103- ELSE 1
104+ where a.id=ai.id)
105+ ELSE 1
106 END) / cr.rate as residual
107 from account_invoice_line as ail
108 left join account_invoice as ai ON (ai.id=ail.invoice_id)
109- left join product_template pt on (pt.id=ail.product_id)
110+ left join product_product pr on (pr.id=ail.product_id)
111+ left join product_template pt on (pt.id=pr.product_tmpl_id)
112 left join product_uom u on (u.id=ail.uos_id),
113 res_currency_rate cr
114 where cr.id in (select id from res_currency_rate cr2 where (cr2.currency_id = ai.currency_id)
115@@ -202,6 +208,7 @@
116 ai.address_contact_id,
117 ai.address_invoice_id,
118 ai.account_id,
119+ ail.account_id,
120 ai.partner_bank_id,
121 ai.residual,
122 ai.amount_total,
123
124=== modified file 'account/report/account_invoice_report_view.xml'
125--- account/report/account_invoice_report_view.xml 2011-02-22 17:02:26 +0000
126+++ account/report/account_invoice_report_view.xml 2011-04-13 08:55:51 +0000
127@@ -27,10 +27,10 @@
128 <field name="partner_bank_id" invisible="1"/>
129 <field name="date_due" invisible="1"/>
130 <field name="account_id" invisible="1"/>
131+ <field name="account_line_id" invisible="1"/>
132 <field name="nbr" sum="# of Lines"/>
133 <field name="product_qty" sum="Qty"/>
134 <!-- <field name="reconciled" sum="# Reconciled"/> -->
135- <field name="price_average" sum="Average Price"/>
136 <field name="price_total" sum="Total Without Tax"/>
137 <field name="price_total_tax" sum="Total With Tax"/>
138 <field name="residual" sum="Total Residual" invisible="context.get('residual_invisible',False)"/>
139@@ -103,6 +103,7 @@
140 <separator orientation="vertical"/>
141 <field name="journal_id" widget="selection"/>
142 <field name="account_id"/>
143+ <field name="account_line_id"/>
144 <separator orientation="vertical"/>
145 <field name="date_due"/>
146 <separator orientation="vertical" groups="base.group_multi_company"/>
147@@ -120,6 +121,7 @@
148 <filter string="Type" icon="terp-stock_symbol-selection" context="{'group_by':'type'}"/>
149 <separator orientation="vertical"/>
150 <filter string="Journal" icon="terp-folder-orange" context="{'group_by':'journal_id'}"/>
151+ <filter string="Account Line" icon="terp-folder-orange" context="{'group_by':'account_line_id'}"/>
152 <separator orientation="vertical"/>
153 <filter string="Due Date" icon="terp-go-today" context="{'group_by':'date_due'}"/>
154 <filter string="Period" icon="terp-go-month" context="{'group_by':'period_id'}"/>

Subscribers

People subscribed via source and target branches

to all changes: