From c5c66ed258e5d33c4967a6ed712f933c53cd367a Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Wed, 7 Apr 2010 14:37:16 +0530 Subject: [PATCH] [IMP]:sale,purchase,account:Improved SQL reports. bzr revid: apa@tinyerp.com-20100407090716-t2mf8cd54peqs4pp --- .../account/report/account_invoice_report.py | 26 ++++++++++++++++--- .../report/account_invoice_report_view.xml | 11 ++++++++ addons/purchase/report/purchase_report.py | 17 +++++++++--- addons/sale/report/sale_report.py | 13 +++++++--- 4 files changed, 57 insertions(+), 10 deletions(-) diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index 0d4ac30323d..548e6eb50a6 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -35,6 +35,11 @@ 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), + '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), + '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), 'user_id':fields.many2one('res.users', 'Salesman', readonly=True), @@ -69,6 +74,11 @@ class account_invoice_report(osv.osv): l.product_id as product_id, sum(l.quantity * u.factor) as product_qty, s.partner_id as partner_id, + s.payment_term as payment_term, + s.period_id as period_id, + 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, @@ -82,9 +92,19 @@ class account_invoice_report(osv.osv): account_invoice s on (s.id=l.invoice_id) left join product_uom u on (u.id=l.uos_id) group by - s.type,s.date_invoice, s.partner_id, l.product_id, - l.uos_id, s.user_id, s.state, - s.company_id + s.type, + s.date_invoice, + s.partner_id, + l.product_id, + l.uos_id, + s.user_id, + s.state, + s.company_id, + s.payment_term, + s.period_id, + s.fiscal_position, + s.currency_id, + s.journal_id ) """) account_invoice_report() diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index 6dbb5f336aa..00dd2b1304d 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -21,6 +21,11 @@ + + + + + @@ -88,11 +93,17 @@ + + + + + + diff --git a/addons/purchase/report/purchase_report.py b/addons/purchase/report/purchase_report.py index f5338e93723..d357e7c9aa5 100644 --- a/addons/purchase/report/purchase_report.py +++ b/addons/purchase/report/purchase_report.py @@ -90,10 +90,19 @@ class report_purchase_order(osv.osv): left join purchase_order_line l on (s.id=l.order_id) left join product_uom u on (u.id=l.product_uom) where l.product_id is not null - group by s.company_id,s.create_uid,s.partner_id, - s.location_id,l.product_id,s.date_order, - to_char(s.date_order, 'YYYY'),to_char(s.date_order, 'MM'),s.state, - s.warehouse_id,s.fiscal_position,s.invoice_method + group by + s.company_id, + s.create_uid, + s.partner_id, + s.location_id, + l.product_id, + s.date_order, + to_char(s.date_order, 'YYYY'), + to_char(s.date_order, 'MM'), + s.state, + s.warehouse_id, + s.fiscal_position, + s.invoice_method ) """) report_purchase_order() diff --git a/addons/sale/report/sale_report.py b/addons/sale/report/sale_report.py index 77cdb4d4cc3..6db3b9e044b 100644 --- a/addons/sale/report/sale_report.py +++ b/addons/sale/report/sale_report.py @@ -86,9 +86,16 @@ class sale_report(osv.osv): sale_order s on (s.id=l.order_id) left join product_uom u on (u.id=l.product_uom) group by - s.date_order, s.partner_id, l.product_id, - l.product_uom, s.user_id, s.state, s.shop_id, - s.company_id,s.fiscal_position,s.payment_term + s.date_order, + s.partner_id, + l.product_id, + l.product_uom, + s.user_id, + s.state, + s.shop_id, + s.company_id, + s.fiscal_position, + s.payment_term ) """) sale_report()