diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 137f619f2e3..6389341be16 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -144,9 +144,14 @@ 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': + base_currency_id = self.pool.get('res.company').browse(cr, uid, groupby['__domain'][0][2], context=context).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):