[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 return res
_columns = { _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'), 'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'),
'use_leads': fields.boolean('Leads', '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."), 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, 'monthly_open_leads': fields.function(_get_opportunities_data,
type="string", readonly=True, multi='_get_opportunities_data', type="string", readonly=True, multi='_get_opportunities_data',
string='Open Leads per Month'), string='Open Leads per Month'),
'monthly_planned_revenue': fields.function(_get_opportunities_data, 'monthly_planned_revenue': fields.function(_get_opportunities_data,
type="string", readonly=True, multi='_get_opportunities_data', type="string", readonly=True, multi='_get_opportunities_data',
string='Planned Revenue per Month'), 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): def _get_stage_common(self, cr, uid, context):

View File

@ -118,7 +118,6 @@
</record> </record>
<!-- Case Sections Action --> <!-- Case Sections Action -->
<record model="ir.actions.act_window.view" id="action_crm_tag_kanban_view_salesteams_oppor11"> <record model="ir.actions.act_window.view" id="action_crm_tag_kanban_view_salesteams_oppor11">
<field name="sequence" eval="0"/> <field name="sequence" eval="0"/>
<field name="view_mode">kanban</field> <field name="view_mode">kanban</field>

View File

@ -195,7 +195,6 @@ class crm_lead(format_address, osv.osv):
resource_id = resource_ids[0] resource_id = resource_ids[0]
duration = float(ans.days) duration = float(ans.days)
if lead.section_id and lead.section_id.resource_calendar_id: if lead.section_id and lead.section_id.resource_calendar_id:
duration = float(ans.days) * 24 duration = float(ans.days) * 24
new_dates = cal_obj.interval_get(cr, new_dates = cal_obj.interval_get(cr,

View File

@ -24,7 +24,6 @@
<field name="users" eval="[(4, ref('base.user_root'))]"/> <field name="users" eval="[(4, ref('base.user_root'))]"/>
</record> </record>
<record id="group_fund_raising" model="res.groups"> <record id="group_fund_raising" model="res.groups">
<field name="name">Manage Fund Raising</field> <field name="name">Manage Fund Raising</field>
<field name="category_id" ref="base.module_category_hidden"/> <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)) _logger.exception(_('Invalid return content from the evaluation of code for definition %s' % definition.name))
else: # count or sum else: # count or sum
obj = self.pool.get(definition.model_id.model) obj = self.pool.get(definition.model_id.model)
field_date_name = definition.field_date_id and definition.field_date_id.name or False 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: if not value:
continue continue
goal = all_goals[goal_id] goal = all_goals[goal_id]
# check goal target reached # check goal target reached
if (goal.definition_condition == 'higher' and value.get('current', goal.current) >= goal.target_goal) \ 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): 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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
import sales_crm_account_invoice_report import sales_crm_account_invoice_report
import sale_report import sale_report
import sale_analysis_report import sale_analysis_report

View File

@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
import calendar import calendar
from openerp import tools from openerp import tools
from datetime import date, datetime, timedelta from datetime import date, datetime, timedelta
@ -390,7 +391,6 @@ class sale_order(osv.osv):
invoice_vals.update(self._inv_get(cr, uid, order, context=context)) invoice_vals.update(self._inv_get(cr, uid, order, context=context))
return invoice_vals return invoice_vals
def _make_invoice(self, cr, uid, order, lines, context=None): def _make_invoice(self, cr, uid, order, lines, context=None):
inv_obj = self.pool.get('account.invoice') inv_obj = self.pool.get('account.invoice')
obj_invoice_line = self.pool.get('account.invoice.line') obj_invoice_line = self.pool.get('account.invoice.line')
@ -1013,9 +1013,9 @@ class mail_compose_message(osv.Model):
self.pool.get('sale.order').signal_quotation_sent(cr, uid, [context['default_res_id']]) 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) return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context)
class account_invoice(osv.Model): class account_invoice(osv.Model):
_inherit = 'account.invoice' _inherit = 'account.invoice'
_columns = { _columns = {
'section_id': fields.many2one('crm.case.section', 'Sales Team'), 'section_id': fields.many2one('crm.case.section', 'Sales Team'),
} }

View File

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

View File

@ -21,6 +21,5 @@
import wizard import wizard
import sale_crm import sale_crm
import report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # 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

@ -22,4 +22,3 @@ import sale_team
import sale_team_config 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', 'website': 'http://www.openerp.com',
'depends' : ['base','mail','web_kanban_sparkline',], 'depends' : ['base','mail','web_kanban_sparkline',],
'data': ['security/sale_team_security.xml', 'data': ['security/sale_team_security.xml',
'security/ir.model.access.csv',
'res_config_view.xml', 'res_config_view.xml',
'ir.model.access.csv',
'sale_team_data.xml', 'sale_team_data.xml',
'sale_team.xml',], 'sale_team.xml',],
'demo': ['sale_team_demo.xml'], 'demo': ['sale_team_demo.xml'],

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<openerp> <openerp>
<data> <data>
<record id="view_sale_config_settings" model="ir.ui.view"> <record id="view_sale_config_settings" model="ir.ui.view">
<field name="name">crm settings</field> <field name="name">crm settings</field>
<field name="model">sale.team.config.settings</field> <field name="model">sale.team.config.settings</field>
@ -17,11 +16,11 @@
<field name="group_multi_salesteams" class="oe_inline"/> <field name="group_multi_salesteams" class="oe_inline"/>
<label for="group_multi_salesteams"/> <label for="group_multi_salesteams"/>
</div> </div>
</div> </div>
</group> </group>
</div> </div>
</data></field> </data>
</field>
</record> </record>
</data> </data>
</openerp> </openerp>

View File

@ -19,17 +19,13 @@
# #
############################################################################## ##############################################################################
import calendar import calendar
from datetime import date, datetime from datetime import date, datetime
from dateutil import relativedelta from dateutil import relativedelta
from openerp import tools from openerp import tools
from openerp.osv import fields from openerp.osv import fields
from openerp.osv import osv from openerp.osv import osv
class crm_case_section(osv.osv): class crm_case_section(osv.osv):
_name = "crm.case.section" _name = "crm.case.section"
_inherit = ['mail.thread', 'ir.needaction_mixin'] _inherit = ['mail.thread', 'ir.needaction_mixin']
@ -146,6 +142,3 @@ class res_users(osv.Model):
self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS) self.SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
self.SELF_WRITEABLE_FIELDS.extend(['default_section_id']) self.SELF_WRITEABLE_FIELDS.extend(['default_section_id'])
return init_res return init_res

View File

@ -75,10 +75,7 @@
</field> </field>
</record> </record>
<!-- Case Sections Search view --> <!-- Case Sections Search view -->
<record id="crm_case_section_salesteams_search" model="ir.ui.view"> <record id="crm_case_section_salesteams_search" model="ir.ui.view">
<field name="name">Case Sections - Search</field> <field name="name">Case Sections - Search</field>
<field name="model">crm.case.section</field> <field name="model">crm.case.section</field>
@ -99,7 +96,6 @@
</record> </record>
<!-- Case Sections Action --> <!-- Case Sections Action -->
<record id="crm_case_section_salesteams_act" model="ir.actions.act_window"> <record id="crm_case_section_salesteams_act" model="ir.actions.act_window">
<field name="name">Sales Teams</field> <field name="name">Sales Teams</field>
<field name="res_model">crm.case.section</field> <field name="res_model">crm.case.section</field>
@ -175,7 +171,6 @@
</record> </record>
<!-- Case Sections Tree View --> <!-- Case Sections Tree View -->
<record id="crm_case_section_view_tree" model="ir.ui.view"> <record id="crm_case_section_view_tree" model="ir.ui.view">
<field name="name">crm.case.section.tree</field> <field name="name">crm.case.section.tree</field>
<field name="model">crm.case.section</field> <field name="model">crm.case.section</field>
@ -189,15 +184,6 @@
</field> </field>
</record> </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"> <record id="crm_case_section_act" model="ir.actions.act_window">
<field name="name">Sales Teams</field> <field name="name">Sales Teams</field>
<field name="res_model">crm.case.section</field> <field name="res_model">crm.case.section</field>
@ -213,7 +199,6 @@
</p> </p>
</field> </field>
</record> </record>
<menuitem id="sale_team.menu_sale_team_act" action="crm_case_section_salesteams_act" sequence="1" parent="base.menu_sales"/> <menuitem id="sale_team.menu_sale_team_act" action="crm_case_section_salesteams_act" sequence="1" parent="base.menu_sales"/>
</data> </data>
</openerp> </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 import SUPERUSER_ID
from openerp.osv import fields, osv from openerp.osv import fields, osv
class sala_team_configuration(osv.TransientModel): class sala_team_configuration(osv.TransientModel):
_name = 'sale.team.config.settings' _name = 'sale.team.config.settings'
_inherit = ['sale.config.settings', 'fetchmail.config.settings'] _inherit = ['sale.config.settings', 'fetchmail.config.settings']
@ -35,11 +54,7 @@ class sala_team_configuration(osv.TransientModel):
return True return True
_columns = { _columns = {
'group_multi_salesteams': fields.boolean("Organize Sales activities into multiple Sales Teams", 'group_multi_salesteams': fields.boolean("Organize Sales activities into multiple Sales Teams",
implied_group='base.group_multi_salesteams', implied_group='base.group_multi_salesteams',
help="""Allows you to use Sales Teams to manage your leads and opportunities."""), 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="code">SPD</field>
<field name="member_ids" eval="[(4, ref('base.user_root')),(4, ref('base.user_demo'))]"/> <field name="member_ids" eval="[(4, ref('base.user_root')),(4, ref('base.user_demo'))]"/>
</record> </record>
</data> </data>
</openerp> </openerp>

View File

@ -2,4 +2,3 @@ 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,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_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"> <record model="ir.ui.menu" id="base.menu_base_config">
<field eval="[(4, ref('base.group_sale_manager'))]" name="groups_id"/> <field eval="[(4, ref('base.group_sale_manager'))]" name="groups_id"/>
</record> </record>
</data> </data>
</openerp> </openerp>