[RMV] removed code to convert forcast and target amount in user currency.

bzr revid: tpa@tinyerp.com-20131023054254-gw4mjjighbbn1unm
This commit is contained in:
Turkesh Patel (Open ERP) 2013-10-23 11:12:54 +05:30
parent ce3722b044
commit f684f68173
2 changed files with 14 additions and 34 deletions

View File

@ -70,35 +70,12 @@ class crm_case_section(osv.osv):
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):
"""Compute the amounts in the currency of the user """
res = {}
currency_obj = self.pool.get('res.currency')
user_currency_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id
for item in self.browse(cr, uid, ids, context=context):
base_currency_id = item.user_id.company_id.currency_id.id if item.user_id else item.create_uid.company_id.currency_id.id
res[item.id] = {
'user_currency_invoiced_forecast': currency_obj.compute(cr, uid, base_currency_id, user_currency_id, item.invoiced_forecast, context=context),
'user_currency_invoiced_target': currency_obj.compute(cr, uid, base_currency_id, user_currency_id, item.invoiced_target, context=context),
}
return res
def _set_forecast_target(self, cr, uid, team_id, name, value, arg, context=None):
user_currency_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.currency_id.id
team = self.browse(cr, uid, team_id, context=context)
base_currency_id = team.user_id.company_id.currency_id.id if team.user_id else team.create_uid.company_id.currency_id.id
amount = self.pool.get('res.currency').compute(cr, uid, user_currency_id, base_currency_id, value, context=context)
self.write(cr, uid, [team_id], {name.strip("user_currency"): amount}, context=context)
return True
_columns = {
'invoiced_forecast': fields.integer("Invoice Forecast"),
'user_currency_invoiced_forecast': fields.function(_compute_amounts_in_user_currency, fnct_inv=_set_forecast_target, string='Invoice Forecast',type='integer', multi="_compute_amounts",
'invoiced_forecast': fields.integer("Invoice Forecast",
help="Forecast of the invoice revenue for the current month. This is the amount the sales \n"
"team should invoice this month. It is used to compute the progression ratio \n"
" of the current and forecast revenue on the kanban view."),
'invoiced_target': fields.integer("Invoice Target"),
'user_currency_invoiced_target': fields.function(_compute_amounts_in_user_currency, fnct_inv=_set_forecast_target, string='Invoice Target',type='integer', multi="_compute_amounts",
'invoiced_target': fields.integer("Invoice Target",
help="Target of invoice revenue for the current month. This is the amount the sales \n"
"team estimates to be able to invoice this month."),
'monthly_quoted': fields.function(_get_sale_orders_data,
@ -111,10 +88,12 @@ class crm_case_section(osv.osv):
type='string', readonly=True,
string='Rate of sent invoices per duration'),
'create_uid': fields.many2one('res.users', 'Create User'),
'company_id': fields.related('create_uid', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
'currency_id': fields.related('company_id', 'currency_id', type='many2one', relation='res.currency', required=True, readonly=True, string='Currency'),
}
def action_forecast(self, cr, uid, id, value, context=None):
return self.write(cr, uid, [id], {'user_currency_invoiced_forecast': round(float(value))}, context=context)
return self.write(cr, uid, [id], {'invoiced_forecast': round(float(value))}, context=context)
class res_users(osv.Model):
_inherit = 'res.users'

View File

@ -248,8 +248,9 @@
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='code']" position="after">
<field name="user_currency_invoiced_target" readonly="0"/>
<field name="user_currency_invoiced_forecast" readonly="0"/>
<field name="currency_id" invisible="1"/>
<field name="invoiced_target" readonly="0" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="invoiced_forecast" readonly="0" widget="monetary" options="{'currency_field': 'currency_id'}"/>
</xpath>
</data>
</field>
@ -265,8 +266,8 @@
<field name="monthly_quoted"/>
<field name="monthly_confirmed"/>
<field name="monthly_invoiced"/>
<field name="user_currency_invoiced_forecast"/>
<field name="user_currency_invoiced_target"/>
<field name="invoiced_forecast"/>
<field name="invoiced_target"/>
</xpath>
<xpath expr="//div[@class='oe_salesteams_leads']" position="after">
<div class="oe_salesteams_orders">
@ -297,11 +298,11 @@
</div>
</xpath>
<xpath expr="//div[@class='oe_items_list']" position="after">
<div class="oe_center oe_salesteams_justgage" t-if="record.user_currency_invoiced_target.raw_value">
<field name="monthly_invoiced" widget="gauge" style="width:160px; height: 120px;" options="{'max_field': 'user_currency_invoiced_target'}">Invoiced</field>
<field name="user_currency_invoiced_forecast" widget="gauge" style="width:160px; height: 120px; cursor: pointer;" options="{'max_field': 'user_currency_invoiced_target', 'action_change': 'action_forecast'}">Forecast</field>
<div class="oe_center oe_salesteams_justgage" t-if="record.invoiced_target.raw_value">
<field name="monthly_invoiced" widget="gauge" style="width:160px; height: 120px;" options="{'max_field': 'invoiced_target'}">Invoiced</field>
<field name="invoiced_forecast" widget="gauge" style="width:160px; height: 120px; cursor: pointer;" options="{'max_field': 'invoiced_target', 'action_change': 'action_forecast'}">Forecast</field>
</div>
<div class="oe_center oe_salesteams_help" style="color:#bbbbbb;" t-if="!record.user_currency_invoiced_target.raw_value">
<div class="oe_center oe_salesteams_help" style="color:#bbbbbb;" t-if="!record.invoiced_target.raw_value">
<br/>Define an invoicing target in the sales team settings to see the period's achievement and forecast at a glance.
</div>
</xpath>