diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py
index cd1477e79cf..523d77c84e3 100644
--- a/addons/account/report/account_invoice_report.py
+++ b/addons/account/report/account_invoice_report.py
@@ -36,10 +36,12 @@ class account_invoice_report(osv.osv):
('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
'product_id':fields.many2one('product.product', 'Product', readonly=True),
'product_qty':fields.float('Qty', readonly=True),
+ 'uom_name': fields.char('Default UoM', size=128, readonly=True),
'payment_term': fields.many2one('account.payment.term', 'Payment Term',readonly=True),
'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')],readonly=True),
'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position',readonly=True),
'currency_id': fields.many2one('res.currency', 'Currency', readonly=True),
+ 'categ_id': fields.many2one('product.category','Category of Product', readonly=True),
'journal_id': fields.many2one('account.journal', 'Journal',readonly=True),
'partner_id':fields.many2one('res.partner', 'Partner', readonly=True),
'company_id':fields.many2one('res.company', 'Company', readonly=True),
@@ -81,46 +83,64 @@ class account_invoice_report(osv.osv):
to_char(s.date_invoice, 'MM') as month,
to_char(s.date_invoice, 'YYYY-MM-DD') as day,
l.product_id as product_id,
- sum(l.quantity * u.factor) as product_qty,
+ sum(case when s.type in ('out_refund','in_invoice') then
+ l.quantity * u.factor * -1
+ else
+ l.quantity * u.factor
+ end) as product_qty,
s.partner_id as partner_id,
s.payment_term as payment_term,
s.period_id as period_id,
+ u.name as uom_name,
s.currency_id as currency_id,
s.journal_id as journal_id,
s.fiscal_position as fiscal_position,
s.user_id as user_id,
s.company_id as company_id,
- sum(l.quantity*l.price_unit) as price_total,
- (sum(l.quantity*l.price_unit)/sum(l.quantity * u.factor))::decimal(16,2) as price_average,
+ sum(case when s.type in ('out_refund','in_invoice') then
+ l.quantity*l.price_unit * -1
+ else
+ l.quantity*l.price_unit
+ end) as price_total,
+ sum(case when s.type in ('out_refund','in_invoice') then
+ l.quantity*l.price_unit * -1
+ else
+ l.quantity*l.price_unit
+ end) / sum(l.quantity * u.factor)::decimal(16,2) as price_average,
count(*) as nbr,
s.type as type,
s.state,
+ pt.categ_id,
s.date_due as date_due,
s.address_contact_id as address_contact_id,
s.address_invoice_id as address_invoice_id,
s.account_id as account_id,
s.partner_bank as partner_bank,
- s.residual as residual,
+ sum(case when s.type in ('out_refund','in_invoice') then
+ s.residual * -1
+ else
+ s.residual
+ end) as residual,
case when s.state != 'paid' then null else
- extract(epoch from avg(am.date_created-l.create_date))/(24*60*60)::decimal(16,2)
+ extract(epoch from avg(am.date_created-l.create_date))/(24*60*60)::decimal(16,2)
end as delay_to_pay
- from
- account_invoice_line l
- left join
- account_invoice s on (s.id=l.invoice_id)
- left join product_uom u on (u.id=l.uos_id),
+ from account_invoice_line l
+ left join account_invoice s on (s.id=l.invoice_id)
+ left join product_template pt on (pt.id=l.product_id)
+ left join product_uom u on (u.id=l.uos_id),
account_move_line am left join account_invoice i on (i.move_id=am.move_id)
- where
- am.account_id=i.account_id
+ where am.account_id=i.account_id
group by
s.type,
s.date_invoice,
s.partner_id,
l.product_id,
+ u.name,
l.uos_id,
s.user_id,
s.state,
s.residual,
+ pt.categ_id,
s.company_id,
s.payment_term,
s.period_id,
diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml
index 94f181cd587..965d5078ae9 100644
--- a/addons/account/report/account_invoice_report_view.xml
+++ b/addons/account/report/account_invoice_report_view.xml
@@ -16,8 +16,10 @@
-
+
+
+
@@ -97,16 +99,17 @@
-
+
+
-
+