[FIX] improved code for invoice sparkline bar
bzr revid: tpa@tinyerp.com-20130905071404-dlgdeovxarfa9pg6
This commit is contained in:
parent
6e1b899aa9
commit
e7764209b7
|
@ -129,13 +129,15 @@ class crm_case_section(osv.osv):
|
|||
if type == "Lead" or not inner_groupby:
|
||||
section_result[month]['value'] = group.get(value_field, 0)
|
||||
continue
|
||||
if inner_groupby:
|
||||
groupby_company = obj.read_group(cr, uid, group.get('__domain'), read_fields, inner_groupby, context=context)
|
||||
for groupby in groupby_company:
|
||||
elif inner_groupby:
|
||||
inner_group_obj = obj.read_group(cr, uid, group.get('__domain'), read_fields, inner_groupby, context=context)
|
||||
for groupby in inner_group_obj:
|
||||
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
|
||||
elif inner_groupby[0] == 'currency_id':
|
||||
base_currency_id = self.pool.get('res.currency.rate').search_read(cr, uid, [('rate', '=', 1)], ['currency_id'], limit=1, context=context)[0]['currency_id'][0]
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
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
|
||||
|
|
|
@ -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','pricelist_id'], 'amount_total', ['date_order','pricelist_id'], 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','pricelist_id'], 'amount_total', ['date_confirm','pricelist_id'], 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, ['date'], 'user_currency_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):
|
||||
|
|
Loading…
Reference in New Issue