[IMP] improved code.
bzr revid: tpa@tinyerp.com-20131025094512-m0mx0a0s94h1ldjg
This commit is contained in:
parent
f48db35788
commit
29214f0894
|
@ -105,12 +105,6 @@ class crm_case_section(osv.osv):
|
|||
base_currency_id = user.company_id.currency_id.id
|
||||
if relation_field == 'company_id':
|
||||
base_currency_id = self.pool.get('res.company').browse(cr, uid, relation_id, context=context).currency_id.id
|
||||
elif relation_field == 'pricelist_id':
|
||||
base_currency_id = self.pool.get('product.pricelist').browse(cr, uid, relation_id, context=context).currency_id.id
|
||||
elif relation_field == 'currency_id':
|
||||
currency_rates = self.pool.get('res.currency.rate').search_read(cr, uid, [('rate', '=', 1)], ['currency_id'], limit=1, context=context)
|
||||
if currency_rates:
|
||||
base_currency_id = currency_rates[0]['currency_id'][0]
|
||||
return self.pool.get('res.currency').compute(cr, uid, base_currency_id, user.company_id.currency_id.id, amount, context=context)
|
||||
|
||||
def __get_bar_values(self, cr, uid, obj, domain, read_fields, value_field, groupby_field, context=None):
|
||||
|
@ -146,7 +140,7 @@ class crm_case_section(osv.osv):
|
|||
if 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:
|
||||
section_result[month]['value'] += self._currency_conversation(cr, uid, groupby.get(value_field, 0), groupby['__domain'][0][2],inner_groupby[0], context=context)
|
||||
section_result[month]['value'] += self._currency_conversation(cr, uid, groupby.get(value_field, 0), groupby['__domain'][0][2], inner_groupby[0], context=context)
|
||||
return section_result
|
||||
|
||||
def _get_opportunities_data(self, cr, uid, ids, field_name, arg, context=None):
|
||||
|
|
|
@ -45,6 +45,19 @@ class sale_order(osv.osv):
|
|||
class crm_case_section(osv.osv):
|
||||
_inherit = 'crm.case.section'
|
||||
|
||||
def _currency_conversation(self, cr, uid, amount, relation_id, relation_field, context=None):
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
base_currency_id = user.company_id.currency_id.id
|
||||
if relation_field not in ['pricelist_id', 'currency_id']:
|
||||
return super(crm_case_section, self)._currency_conversation(cr, uid, amount, relation_id, relation_field, context=context)
|
||||
if relation_field == 'pricelist_id':
|
||||
base_currency_id = self.pool.get('product.pricelist').browse(cr, uid, relation_id, context=context).currency_id.id
|
||||
elif relation_field == 'currency_id':
|
||||
currency_rates = self.pool.get('res.currency.rate').search_read(cr, uid, [('rate', '=', 1)], ['currency_id'], limit=1, context=context)
|
||||
if currency_rates:
|
||||
base_currency_id = currency_rates[0]['currency_id'][0]
|
||||
return self.pool.get('res.currency').compute(cr, uid, base_currency_id, user.company_id.currency_id.id, amount, context=context)
|
||||
|
||||
def _get_sale_orders_data(self, cr, uid, ids, field_name, arg, context=None):
|
||||
obj = self.pool.get('sale.order')
|
||||
res = dict.fromkeys(ids, False)
|
||||
|
|
Loading…
Reference in New Issue