From c80f7589895fd2b53c4d32e73bc432648e46490c Mon Sep 17 00:00:00 2001 From: "Sunil Sharma (OpenERP Trainee)" Date: Thu, 8 Aug 2013 11:23:54 +0530 Subject: [PATCH 1/2] [IMP]:Account:account_invoice_report.py bzr revid: sunilsharma.sharma07@gmail.com-20130808055354-0379xbn60gbcmvsc --- addons/account/report/account_invoice_report.py | 15 ++++++++++++++- .../report/account_invoice_report_view.xml | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index d8dc45f9a3b..8674e71e109 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -29,7 +29,7 @@ class account_invoice_report(osv.osv): _auto = False _rec_name = 'date' - def _compute_amounts_in_user_currency(self, cr, uid, ids, field_names, args, context=None): + def _compute_amounts_in_user_currency(self, cr, uid, ids, field_names=[], args={}, context=None): """Compute the amounts in the currency of the user """ if context is None: @@ -103,6 +103,19 @@ class account_invoice_report(osv.osv): } _order = 'date desc' + #FIX:To show sum of values of function fields in groupby + def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False): + res = super(account_invoice_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby) + for group in res: + group['user_currency_price_total'] = 0 + group_ids = self.search(cr, uid, group.get('__domain'),context=context) + record = self._compute_amounts_in_user_currency(cr, uid, group_ids, context=context) + for id, rec in record.iteritems(): + group['user_currency_price_total'] += rec['user_currency_price_total'] + + return res + + def _select(self): select_str = """ SELECT sub.id, sub.date, sub.year, sub.month, sub.day, sub.product_id, sub.partner_id, sub.country_id, diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index 5f38db5e71f..4c297fd52e8 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -30,7 +30,7 @@ - + @@ -41,7 +41,7 @@ - + From 418c77da3026df95004ce98eca8a305fc04c0f42 Mon Sep 17 00:00:00 2001 From: "Sunil Sharma (OpenERP Trainee)" Date: Tue, 13 Aug 2013 12:03:15 +0530 Subject: [PATCH 2/2] [IMP]:User_Currency: bzr revid: sunilsharma.sharma07@gmail.com-20130813063315-i45q7dykm6sp3a94 --- addons/crm/crm.py | 10 ++++++++-- addons/sale_crm/sale_crm.py | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 137f619f2e3..0ac2e887e72 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -144,9 +144,15 @@ class crm_case_section(osv.osv): if inner_groupby: groupby_company = obj.read_group(cr, uid, group.get('__domain'), read_fields, inner_groupby, context=context) for groupby in groupby_company: - company = self.pool.get('res.company').browse(cr, uid, groupby['__domain'][0][2], context=context) + if inner_groupby[0] == 'company_id': + company = self.pool.get('res.company').browse(cr, uid, groupby['__domain'][0][2], context=context) + base_currency_id = company.currency_id.id + elif inner_groupby[0] == 'pricelist_id': + base_currency_id = self.pool.get('product.pricelist').browse(cr, uid, groupby['__domain'][0][2], context=context).currency_id.id + else : + base_currency_id = groupby['__domain'][0][2] user = self.pool.get('res.users').browse(cr, uid, uid, context=context) - value = self.pool.get('res.currency').compute(cr, uid, company.currency_id.id, user.company_id.currency_id.id, groupby.get(value_field, 0)) + value = self.pool.get('res.currency').compute(cr, uid, base_currency_id, user.company_id.currency_id.id, groupby.get(value_field, 0)) section_result[month]['value'] = section_result[month]['value'] + value return section_result diff --git a/addons/sale_crm/sale_crm.py b/addons/sale_crm/sale_crm.py index 634df104d34..5333016b620 100644 --- a/addons/sale_crm/sale_crm.py +++ b/addons/sale_crm/sale_crm.py @@ -52,9 +52,9 @@ class crm_case_section(osv.osv): for id in ids: res[id] = dict() created_domain = [('section_id', '=', id), ('state', 'in', ['draft', 'sent']), ('date_order', '>=', groupby_begin)] - res[id]['monthly_quoted'] = self.__get_bar_values(cr, uid, obj, created_domain, ['amount_total', 'date_order'], 'amount_total', 'date_order', context=context) + res[id]['monthly_quoted'] = self.__get_bar_values(cr, uid, obj, created_domain, ['amount_total', 'date_order','pricelist_id'], 'amount_total', ['date_order','pricelist_id'], context=context) validated_domain = [('section_id', '=', id), ('state', 'not in', ['draft', 'sent']), ('date_confirm', '>=', groupby_begin)] - res[id]['monthly_confirmed'] = self.__get_bar_values(cr, uid, obj, validated_domain, ['amount_total', 'date_confirm'], 'amount_total', 'date_confirm', context=context) + res[id]['monthly_confirmed'] = self.__get_bar_values(cr, uid, obj, validated_domain, ['amount_total', 'date_confirm','pricelist_id'], 'amount_total', ['date_confirm','pricelist_id'], context=context) return res def _get_invoices_data(self, cr, uid, ids, field_name, arg, context=None): @@ -64,7 +64,7 @@ class crm_case_section(osv.osv): groupby_begin = (month_begin + relativedelta.relativedelta(months=-4)).strftime(tools.DEFAULT_SERVER_DATE_FORMAT) for id in ids: created_domain = [('section_id', '=', id), ('state', 'not in', ['draft', 'cancel']), ('date', '>=', groupby_begin)] - res[id] = self.__get_bar_values(cr, uid, obj, created_domain, ['price_total', 'date'], 'price_total', 'date', context=context) + res[id] = self.__get_bar_values(cr, uid, obj, created_domain, ['price_total', 'date','currency_id'], 'price_total', ['date','currency_id'], context=context) return res def _compute_amounts_in_user_currency(self, cr, uid, ids, field_names, args, context=None):