[IMP] optimize code

This commit is contained in:
Randhir Mayatra rma-openerp 2014-04-22 12:53:03 +05:30
parent d0df0175ec
commit 27ee024847
21 changed files with 77 additions and 119 deletions

View File

@ -120,17 +120,16 @@ class crm_case_section(osv.osv):
return res
_columns = {
'resource_calendar_id': fields.many2one('resource.calendar', "Working Time", help="Used to compute open days"),
'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'),
'use_leads': fields.boolean('Leads',
help="The first contact you get with a potential customer is a lead you qualify before converting it into a real business opportunity. Check this box to manage leads in this sales team."),
'monthly_open_leads': fields.function(_get_opportunities_data,
type="string", readonly=True, multi='_get_opportunities_data',
string='Open Leads per Month'),
'monthly_planned_revenue': fields.function(_get_opportunities_data,
type="string", readonly=True, multi='_get_opportunities_data',
string='Planned Revenue per Month'),
'resource_calendar_id': fields.many2one('resource.calendar', "Working Time", help="Used to compute open days"),
}
def _get_stage_common(self, cr, uid, context):

View File

@ -86,39 +86,38 @@
<field name="model">crm.case.section</field>
<field name="inherit_id" ref="sale_team.crm_case_section_salesteams_view_kanban"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='name']" position="after">
<field name="use_leads"/>
<field name="monthly_open_leads"/>
<field name="monthly_planned_revenue"/>
</xpath>
<xpath expr="//div[@name='avtar']" position="after">
<div class="oe_kanban_alias oe_center" t-if="record.use_leads.raw_value and record.alias_id.value">
<small><span class="oe_e oe_e_alias" style="float: none;">%%</span><t t-raw="record.alias_id.raw_value[1]"/></small>
</div>
<div class="oe_items_list">
<div class="oe_salesteams_leads" t-if="record.use_leads.raw_value">
<a name="%(crm_case_form_view_salesteams_lead)d" type="action">Leads</a>
<a name="%(action_report_crm_lead_salesteam)d" type="action" class="oe_sparkline_bar_link">
<field name="monthly_open_leads" widget="sparkline_bar"
options="{'height': '20px', 'barWidth': 4, 'barSpacing': 1, 'delayIn': '3000', 'tooltip_suffix': ' Leads'}">Open Leads per Month<br/>Click to see a detailed analysis of leads.</field>
</a>
<data>
<xpath expr="//field[@name='name']" position="after">
<field name="use_leads"/>
<field name="monthly_open_leads"/>
<field name="monthly_planned_revenue"/>
</xpath>
<xpath expr="//div[@name='avtar']" position="after">
<div class="oe_kanban_alias oe_center" t-if="record.use_leads.raw_value and record.alias_id.value">
<small><span class="oe_e oe_e_alias" style="float: none;">%%</span><t t-raw="record.alias_id.raw_value[1]"/></small>
</div>
<div class="oe_salesteams_opportunities">
<a name="%(crm_case_form_view_salesteams_opportunity)d" type="action">Opportunities</a>
<a name="%(action_report_crm_opportunity_salesteam)d" type="action">
<field name="monthly_planned_revenue" widget="sparkline_bar"
options="{'height': '20px', 'barWidth': '4', 'barSpacing': '1', 'delayIn': '3000', 'tooltip_suffix': ' (Planned Revenue)'}">Planned Revenue per Month<br/>Click to see a detailed analysis of opportunities.</field>
</a>
<div class="oe_items_list">
<div class="oe_salesteams_leads" t-if="record.use_leads.raw_value">
<a name="%(crm_case_form_view_salesteams_lead)d" type="action">Leads</a>
<a name="%(action_report_crm_lead_salesteam)d" type="action" class="oe_sparkline_bar_link">
<field name="monthly_open_leads" widget="sparkline_bar"
options="{'height': '20px', 'barWidth': 4, 'barSpacing': 1, 'delayIn': '3000', 'tooltip_suffix': ' Leads'}">Open Leads per Month<br/>Click to see a detailed analysis of leads.</field>
</a>
</div>
<div class="oe_salesteams_opportunities">
<a name="%(crm_case_form_view_salesteams_opportunity)d" type="action">Opportunities</a>
<a name="%(action_report_crm_opportunity_salesteam)d" type="action">
<field name="monthly_planned_revenue" widget="sparkline_bar"
options="{'height': '20px', 'barWidth': '4', 'barSpacing': '1', 'delayIn': '3000', 'tooltip_suffix': ' (Planned Revenue)'}">Planned Revenue per Month<br/>Click to see a detailed analysis of opportunities.</field>
</a>
</div>
</div>
</div>
</xpath>
</data>
</field>
</xpath>
</data>
</field>
</record>
<!-- Case Sections Action -->
<record model="ir.actions.act_window.view" id="action_crm_tag_kanban_view_salesteams_oppor11">
<field name="sequence" eval="0"/>
<field name="view_mode">kanban</field>

View File

@ -195,7 +195,6 @@ class crm_lead(format_address, osv.osv):
resource_id = resource_ids[0]
duration = float(ans.days)
if lead.section_id and lead.section_id.resource_calendar_id:
duration = float(ans.days) * 24
new_dates = cal_obj.interval_get(cr,
@ -351,7 +350,7 @@ class crm_lead(format_address, osv.osv):
if user.default_section_id and user.default_section_id.id:
return {'value': {'section_id': user.default_section_id.id}}
return {'value': {'section_id': section_id}}
def stage_find(self, cr, uid, cases, section_id, domain=None, order='sequence', context=None):
""" Override of the base.stage method
Parameter of the stage search taken from the lead:

View File

@ -24,7 +24,6 @@
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
<record id="group_fund_raising" model="res.groups">
<field name="name">Manage Fund Raising</field>
<field name="category_id" ref="base.module_category_hidden"/>

View File

@ -282,6 +282,7 @@ class gamification_goal(osv.Model):
_logger.exception(_('Invalid return content from the evaluation of code for definition %s' % definition.name))
else: # count or sum
obj = self.pool.get(definition.model_id.model)
field_date_name = definition.field_date_id and definition.field_date_id.name or False
@ -345,6 +346,7 @@ class gamification_goal(osv.Model):
if not value:
continue
goal = all_goals[goal_id]
# check goal target reached
if (goal.definition_condition == 'higher' and value.get('current', goal.current) >= goal.target_goal) \
or (goal.definition_condition == 'lower' and value.get('current', goal.current) <= goal.target_goal):

View File

@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import sales_crm_account_invoice_report
import sale_report
import sale_analysis_report

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<data>
<record id="view_order_product_search_sale_crm_inherit" model="ir.ui.view">
<field name="name">sale.report.search.sale.crm</field>
<field name="model">sale.report</field>
@ -12,5 +12,5 @@
</filter>
</field>
</record>
</data>
</data>
</openerp>

View File

@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import calendar
from openerp import tools
from datetime import date, datetime, timedelta
@ -389,7 +390,6 @@ class sale_order(osv.osv):
# Care for deprecated _inv_get() hook - FIXME: to be removed after 6.1
invoice_vals.update(self._inv_get(cr, uid, order, context=context))
return invoice_vals
def _make_invoice(self, cr, uid, order, lines, context=None):
inv_obj = self.pool.get('account.invoice')
@ -1012,10 +1012,10 @@ class mail_compose_message(osv.Model):
context = dict(context, mail_post_autofollow=True)
self.pool.get('sale.order').signal_quotation_sent(cr, uid, [context['default_res_id']])
return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
class account_invoice(osv.Model):
_inherit = 'account.invoice'
_columns = {
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
}

View File

@ -565,9 +565,7 @@
</field>
</record>
<!-- search by Salesteams -->
<record id="action_orders_salesteams" model="ir.actions.act_window">
<field name="name">Sales Orders</field>
<field name="type">ir.actions.act_window</field>

View File

@ -21,6 +21,5 @@
import wizard
import sale_crm
import report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,26 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -31,5 +31,5 @@
</field>
</field>
</record>
</data>
</data>
</openerp>

View File

@ -21,5 +21,4 @@
import sale_team
import sale_team_config
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -28,8 +28,8 @@
'website': 'http://www.openerp.com',
'depends' : ['base','mail','web_kanban_sparkline',],
'data': ['security/sale_team_security.xml',
'security/ir.model.access.csv',
'res_config_view.xml',
'ir.model.access.csv',
'sale_team_data.xml',
'sale_team.xml',],
'demo': ['sale_team_demo.xml'],

View File

@ -1,27 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_sale_config_settings" model="ir.ui.view">
<field name="name">crm settings</field>
<field name="model">sale.team.config.settings</field>
<field name="inherit_id" ref="base_setup.view_sale_config_settings"/>
<field name="arch" type="xml">
<data>
<div name="config_sale" position="before">
<separator string="Sales Teams"/>
<group>
<label for="id" string="Manage Sales Teams"/>
<div>
<div name="config_sale" position="before">
<separator string="Sales Teams"/>
<group>
<label for="id" string="Manage Sales Teams"/>
<div>
<field name="group_multi_salesteams" class="oe_inline"/>
<label for="group_multi_salesteams"/>
<div>
<field name="group_multi_salesteams" class="oe_inline"/>
<label for="group_multi_salesteams"/>
</div>
</div>
</div>
</group>
</div>
</data></field>
</group>
</div>
</data>
</field>
</record>
</data>
</data>
</openerp>

View File

@ -19,17 +19,13 @@
#
##############################################################################
import calendar
from datetime import date, datetime
from dateutil import relativedelta
from openerp import tools
from openerp.osv import fields
from openerp.osv import osv
class crm_case_section(osv.osv):
_name = "crm.case.section"
_inherit = ['mail.thread', 'ir.needaction_mixin']
@ -145,7 +141,4 @@ class res_users(osv.Model):
# duplicate list to avoid modifying the original reference
self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
self.SELF_WRITEABLE_FIELDS.extend(['default_section_id'])
return init_res
return init_res

View File

@ -24,7 +24,7 @@
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form_simple_modif"/>
<field name="arch" type="xml">
<data>
<data>
<xpath expr="//field[@name='company_id']" position="before">
<field name="default_section_id" readonly="0"/>
</xpath>
@ -75,10 +75,7 @@
</field>
</record>
<!-- Case Sections Search view -->
<record id="crm_case_section_salesteams_search" model="ir.ui.view">
<field name="name">Case Sections - Search</field>
<field name="model">crm.case.section</field>
@ -99,7 +96,6 @@
</record>
<!-- Case Sections Action -->
<record id="crm_case_section_salesteams_act" model="ir.actions.act_window">
<field name="name">Sales Teams</field>
<field name="res_model">crm.case.section</field>
@ -175,7 +171,6 @@
</record>
<!-- Case Sections Tree View -->
<record id="crm_case_section_view_tree" model="ir.ui.view">
<field name="name">crm.case.section.tree</field>
<field name="model">crm.case.section</field>
@ -189,15 +184,6 @@
</field>
</record>
<!-- Case Sections Action -->
<!--<record model="ir.actions.act_window.view" id="action_crm_tag_kanban_view_salesteams_oppor11">
<field name="sequence" eval="0"/>
<field name="view_mode">kanban</field>
<field name="view_id" ref="crm_case_kanban_view_leads"/>
<field name="act_window_id" ref="crm_case_form_view_salesteams_opportunity"/>
</record>-->
<record id="crm_case_section_act" model="ir.actions.act_window">
<field name="name">Sales Teams</field>
<field name="res_model">crm.case.section</field>
@ -213,7 +199,6 @@
</p>
</field>
</record>
<menuitem id="sale_team.menu_sale_team_act" action="crm_case_section_salesteams_act" sequence="1" parent="base.menu_sales"/>
</data>
</data>
</openerp>

View File

@ -1,8 +1,27 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-today OpenERP SA (<http://www.openerp.com>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import SUPERUSER_ID
from openerp.osv import fields, osv
class sala_team_configuration(osv.TransientModel):
_name = 'sale.team.config.settings'
_inherit = ['sale.config.settings', 'fetchmail.config.settings']
@ -35,11 +54,7 @@ class sala_team_configuration(osv.TransientModel):
return True
_columns = {
'group_multi_salesteams': fields.boolean("Organize Sales activities into multiple Sales Teams",
implied_group='base.group_multi_salesteams',
help="""Allows you to use Sales Teams to manage your leads and opportunities."""),
}
}

View File

@ -15,6 +15,5 @@
<field name="code">SPD</field>
<field name="member_ids" eval="[(4, ref('base.user_root')),(4, ref('base.user_demo'))]"/>
</record>
</data>
</openerp>

View File

@ -1,5 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_crm_case_section,crm.case.section,model_crm_case_section,base.group_user,1,0,0,0
access_crm_case_section_user,crm.case.section.user,model_crm_case_section,base.group_sale_salesman,1,0,0,0
access_crm_case_section_manager,crm.case.section.manager,model_crm_case_section,base.group_sale_manager,1,1,1,1
access_crm_case_section_manager,crm.case.section.manager,model_crm_case_section,base.group_sale_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_crm_case_section crm.case.section model_crm_case_section base.group_user 1 0 0 0
3 access_crm_case_section_user crm.case.section.user model_crm_case_section base.group_sale_salesman 1 0 0 0
4 access_crm_case_section_manager crm.case.section.manager model_crm_case_section base.group_sale_manager 1 1 1 1

View File

@ -35,6 +35,5 @@
<record model="ir.ui.menu" id="base.menu_base_config">
<field eval="[(4, ref('base.group_sale_manager'))]" name="groups_id"/>
</record>
</data>
</openerp>