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
=== modified file 'account/report/account_invoice_report.py'
--- account/report/account_invoice_report.py 2011-02-01 14:25:28 +0000
+++ account/report/account_invoice_report.py 2011-04-13 08:55:51 +0000
@@ -69,6 +69,7 @@
69 'address_contact_id': fields.many2one('res.partner.address', 'Contact Address Name', readonly=True),69 'address_contact_id': fields.many2one('res.partner.address', 'Contact Address Name', readonly=True),
70 'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address Name', readonly=True),70 'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address Name', readonly=True),
71 'account_id': fields.many2one('account.account', 'Account',readonly=True),71 'account_id': fields.many2one('account.account', 'Account',readonly=True),
72 'account_line_id': fields.many2one('account.account', 'Account Line',readonly=True),
72 'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account',readonly=True),73 'partner_bank_id': fields.many2one('res.partner.bank', 'Bank Account',readonly=True),
73 'residual': fields.float('Total Residual', readonly=True),74 'residual': fields.float('Total Residual', readonly=True),
74 'delay_to_pay': fields.float('Avg. Delay To Pay', readonly=True, group_operator="avg"),75 'delay_to_pay': fields.float('Avg. Delay To Pay', readonly=True, group_operator="avg"),
@@ -106,44 +107,48 @@
106 ai.address_contact_id as address_contact_id,107 ai.address_contact_id as address_contact_id,
107 ai.address_invoice_id as address_invoice_id,108 ai.address_invoice_id as address_invoice_id,
108 ai.account_id as account_id,109 ai.account_id as account_id,
110 ail.account_id as account_line_id,
109 ai.partner_bank_id as partner_bank_id,111 ai.partner_bank_id as partner_bank_id,
110 sum(case when ai.type in ('out_refund','in_invoice') then112 sum(case when ai.type in ('out_refund','in_invoice') then
111 ail.quantity / u.factor * -1113 -ail.quantity / u.factor
112 else114 else
113 ail.quantity / u.factor115 ail.quantity / u.factor
114 end) as product_qty,116 end) as product_qty,
117
115 sum(case when ai.type in ('out_refund','in_invoice') then118 sum(case when ai.type in ('out_refund','in_invoice') then
116 ail.quantity*ail.price_unit * -1119 -ail.price_subtotal
117 else120 else
118 ail.quantity*ail.price_unit121 ail.price_subtotal
119 end) / cr.rate as price_total,122 end) / cr.rate as price_total,
123
124--
125-- FIXME the line total incl tax can't be caculated by deviding the invoice total / number of lines
126--
120 sum(case when ai.type in ('out_refund','in_invoice') then127 sum(case when ai.type in ('out_refund','in_invoice') then
121 ai.amount_total * -1128 -ai.amount_total
122 else129 else
123 ai.amount_total130 ai.amount_total
124 end) / (CASE WHEN 131 end) / (CASE WHEN
125 (select count(l.id) from account_invoice_line as l132 (select count(l.id) from account_invoice_line as l
126 left join account_invoice as a ON (a.id=l.invoice_id)133 left join account_invoice as a ON (a.id=l.invoice_id)
127 where a.id=ai.id) <> 0 134 where a.id=ai.id) <> 0
128 THEN 135 THEN
129 (select count(l.id) from account_invoice_line as l136 (select count(l.id) from account_invoice_line as l
130 left join account_invoice as a ON (a.id=l.invoice_id)137 left join account_invoice as a ON (a.id=l.invoice_id)
131 where a.id=ai.id) 138 where a.id=ai.id)
132 ELSE 1 139 ELSE 1
133 END) / cr.rate as price_total_tax,140 END) / cr.rate as price_total_tax,
141
134 (case when ai.type in ('out_refund','in_invoice') then142 (case when ai.type in ('out_refund','in_invoice') then
135 sum(ail.quantity*ail.price_unit*-1)143 sum(-ail.price_subtotal)
136 else144 else
137 sum(ail.quantity*ail.price_unit)145 sum(ail.price_subtotal)
138 end) / (CASE WHEN146 end) / (CASE WHEN sum(ail.quantity/u.factor) <> 0
139 (case when ai.type in ('out_refund','in_invoice') 147 THEN
140 then sum(ail.quantity/u.factor*-1)148 (case when ai.type in ('out_refund','in_invoice')
141 else sum(ail.quantity/u.factor) end) <> 0 149 then sum(-ail.quantity/u.factor)
142 THEN 150 else sum(ail.quantity/u.factor) end)
143 (case when ai.type in ('out_refund','in_invoice') 151 ELSE 1
144 then sum(ail.quantity/u.factor*-1)
145 else sum(ail.quantity/u.factor) end)
146 ELSE 1
147 END)152 END)
148 / cr.rate as price_average,153 / cr.rate as price_average,
149154
@@ -159,22 +164,23 @@
159 left join account_invoice_line as l ON (a.id=l.invoice_id)164 left join account_invoice_line as l ON (a.id=l.invoice_id)
160 where a.id=ai.id)) as due_delay,165 where a.id=ai.id)) as due_delay,
161 (case when ai.type in ('out_refund','in_invoice') then166 (case when ai.type in ('out_refund','in_invoice') then
162 ai.residual * -1167 -ai.residual
163 else168 else
164 ai.residual169 ai.residual
165 end)/ (CASE WHEN 170 end)/ (CASE WHEN
166 (select count(l.id) from account_invoice_line as l171 (select count(l.id) from account_invoice_line as l
167 left join account_invoice as a ON (a.id=l.invoice_id)172 left join account_invoice as a ON (a.id=l.invoice_id)
168 where a.id=ai.id) <> 0 173 where a.id=ai.id) <> 0
169 THEN174 THEN
170 (select count(l.id) from account_invoice_line as l175 (select count(l.id) from account_invoice_line as l
171 left join account_invoice as a ON (a.id=l.invoice_id)176 left join account_invoice as a ON (a.id=l.invoice_id)
172 where a.id=ai.id) 177 where a.id=ai.id)
173 ELSE 1 178 ELSE 1
174 END) / cr.rate as residual179 END) / cr.rate as residual
175 from account_invoice_line as ail180 from account_invoice_line as ail
176 left join account_invoice as ai ON (ai.id=ail.invoice_id)181 left join account_invoice as ai ON (ai.id=ail.invoice_id)
177 left join product_template pt on (pt.id=ail.product_id)182 left join product_product pr on (pr.id=ail.product_id)
183 left join product_template pt on (pt.id=pr.product_tmpl_id)
178 left join product_uom u on (u.id=ail.uos_id),184 left join product_uom u on (u.id=ail.uos_id),
179 res_currency_rate cr185 res_currency_rate cr
180 where cr.id in (select id from res_currency_rate cr2 where (cr2.currency_id = ai.currency_id)186 where cr.id in (select id from res_currency_rate cr2 where (cr2.currency_id = ai.currency_id)
@@ -202,6 +208,7 @@
202 ai.address_contact_id,208 ai.address_contact_id,
203 ai.address_invoice_id,209 ai.address_invoice_id,
204 ai.account_id,210 ai.account_id,
211 ail.account_id,
205 ai.partner_bank_id,212 ai.partner_bank_id,
206 ai.residual,213 ai.residual,
207 ai.amount_total,214 ai.amount_total,
208215
=== modified file 'account/report/account_invoice_report_view.xml'
--- account/report/account_invoice_report_view.xml 2011-02-22 17:02:26 +0000
+++ account/report/account_invoice_report_view.xml 2011-04-13 08:55:51 +0000
@@ -27,10 +27,10 @@
27 <field name="partner_bank_id" invisible="1"/>27 <field name="partner_bank_id" invisible="1"/>
28 <field name="date_due" invisible="1"/>28 <field name="date_due" invisible="1"/>
29 <field name="account_id" invisible="1"/>29 <field name="account_id" invisible="1"/>
30 <field name="account_line_id" invisible="1"/>
30 <field name="nbr" sum="# of Lines"/>31 <field name="nbr" sum="# of Lines"/>
31 <field name="product_qty" sum="Qty"/>32 <field name="product_qty" sum="Qty"/>
32 <!-- <field name="reconciled" sum="# Reconciled"/> -->33 <!-- <field name="reconciled" sum="# Reconciled"/> -->
33 <field name="price_average" sum="Average Price"/>
34 <field name="price_total" sum="Total Without Tax"/>34 <field name="price_total" sum="Total Without Tax"/>
35 <field name="price_total_tax" sum="Total With Tax"/>35 <field name="price_total_tax" sum="Total With Tax"/>
36 <field name="residual" sum="Total Residual" invisible="context.get('residual_invisible',False)"/>36 <field name="residual" sum="Total Residual" invisible="context.get('residual_invisible',False)"/>
@@ -103,6 +103,7 @@
103 <separator orientation="vertical"/>103 <separator orientation="vertical"/>
104 <field name="journal_id" widget="selection"/>104 <field name="journal_id" widget="selection"/>
105 <field name="account_id"/>105 <field name="account_id"/>
106 <field name="account_line_id"/>
106 <separator orientation="vertical"/>107 <separator orientation="vertical"/>
107 <field name="date_due"/>108 <field name="date_due"/>
108 <separator orientation="vertical" groups="base.group_multi_company"/>109 <separator orientation="vertical" groups="base.group_multi_company"/>
@@ -120,6 +121,7 @@
120 <filter string="Type" icon="terp-stock_symbol-selection" context="{'group_by':'type'}"/>121 <filter string="Type" icon="terp-stock_symbol-selection" context="{'group_by':'type'}"/>
121 <separator orientation="vertical"/>122 <separator orientation="vertical"/>
122 <filter string="Journal" icon="terp-folder-orange" context="{'group_by':'journal_id'}"/>123 <filter string="Journal" icon="terp-folder-orange" context="{'group_by':'journal_id'}"/>
124 <filter string="Account Line" icon="terp-folder-orange" context="{'group_by':'account_line_id'}"/>
123 <separator orientation="vertical"/>125 <separator orientation="vertical"/>
124 <filter string="Due Date" icon="terp-go-today" context="{'group_by':'date_due'}"/>126 <filter string="Due Date" icon="terp-go-today" context="{'group_by':'date_due'}"/>
125 <filter string="Period" icon="terp-go-month" context="{'group_by':'period_id'}"/>127 <filter string="Period" icon="terp-go-month" context="{'group_by':'period_id'}"/>

Subscribers

People subscribed via source and target branches

to all changes: