From 27ee024847dfde9e5a14eb26680621b60399b556 Mon Sep 17 00:00:00 2001 From: Randhir Mayatra rma-openerp Date: Tue, 22 Apr 2014 12:53:03 +0530 Subject: [PATCH] [IMP] optimize code --- addons/crm/crm.py | 3 +- addons/crm/crm_case_section_view.xml | 55 +++++++++---------- addons/crm/crm_lead.py | 3 +- addons/crm/security/crm_security.xml | 1 - addons/gamification/models/goal.py | 2 + addons/sale/report/__init__.py | 1 + .../sale/report/sale_analysis_report_view.xml | 4 +- addons/sale/sale.py | 4 +- addons/sale/sale_view.xml | 2 - addons/sale_crm/__init__.py | 1 - addons/sale_crm/report/__init__.py | 26 --------- addons/sale_crm/sale_crm_view.xml | 2 +- addons/sale_team/__init__.py | 3 +- addons/sale_team/__openerp__.py | 2 +- addons/sale_team/res_config_view.xml | 27 +++++---- addons/sale_team/sale_team.py | 9 +-- addons/sale_team/sale_team.xml | 19 +------ addons/sale_team/sale_team_config.py | 27 +++++++-- addons/sale_team/sale_team_demo.xml | 1 - .../{ => security}/ir.model.access.csv | 3 +- .../sale_team/security/sale_team_security.xml | 1 - 21 files changed, 77 insertions(+), 119 deletions(-) delete mode 100644 addons/sale_crm/report/__init__.py rename addons/sale_team/{ => security}/ir.model.access.csv (87%) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index c43a3feabb8..86350b472a7 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -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): diff --git a/addons/crm/crm_case_section_view.xml b/addons/crm/crm_case_section_view.xml index f45b3c4204e..57f5b70bfe8 100644 --- a/addons/crm/crm_case_section_view.xml +++ b/addons/crm/crm_case_section_view.xml @@ -86,39 +86,38 @@ crm.case.section - - - - - - - -
- %% -
-
-
- Leads - - Open Leads per Month
Click to see a detailed analysis of leads.
-
+ + + + + + + +
+ %%
- -
-
- + + + - kanban diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index e0149269243..cc2488f9589 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -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: diff --git a/addons/crm/security/crm_security.xml b/addons/crm/security/crm_security.xml index bd2c3cdb3a4..7539b699614 100644 --- a/addons/crm/security/crm_security.xml +++ b/addons/crm/security/crm_security.xml @@ -24,7 +24,6 @@ - Manage Fund Raising diff --git a/addons/gamification/models/goal.py b/addons/gamification/models/goal.py index 2a9b6788360..f6f7165c41b 100644 --- a/addons/gamification/models/goal.py +++ b/addons/gamification/models/goal.py @@ -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): diff --git a/addons/sale/report/__init__.py b/addons/sale/report/__init__.py index f1d48dd38e9..0ce593424d3 100644 --- a/addons/sale/report/__init__.py +++ b/addons/sale/report/__init__.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # ############################################################################## + import sales_crm_account_invoice_report import sale_report import sale_analysis_report diff --git a/addons/sale/report/sale_analysis_report_view.xml b/addons/sale/report/sale_analysis_report_view.xml index fb62468ec91..83613219046 100644 --- a/addons/sale/report/sale_analysis_report_view.xml +++ b/addons/sale/report/sale_analysis_report_view.xml @@ -1,6 +1,6 @@ - + sale.report.search.sale.crm sale.report @@ -12,5 +12,5 @@ - + \ No newline at end of file diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 09008e1dc81..d597d0d1743 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -18,6 +18,7 @@ # along with this program. If not, see . # ############################################################################## + 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'), } diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index fafca287f2e..790e71ee37b 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -565,9 +565,7 @@ - - Sales Orders ir.actions.act_window diff --git a/addons/sale_crm/__init__.py b/addons/sale_crm/__init__.py index cda0cd795a2..ac44586e7db 100644 --- a/addons/sale_crm/__init__.py +++ b/addons/sale_crm/__init__.py @@ -21,6 +21,5 @@ import wizard import sale_crm -import report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sale_crm/report/__init__.py b/addons/sale_crm/report/__init__.py deleted file mode 100644 index 3fd45ac3f8f..00000000000 --- a/addons/sale_crm/report/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). -# -# 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 . -# -############################################################################## - - - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/sale_crm/sale_crm_view.xml b/addons/sale_crm/sale_crm_view.xml index 102eb9462fa..070b8ef4fa7 100644 --- a/addons/sale_crm/sale_crm_view.xml +++ b/addons/sale_crm/sale_crm_view.xml @@ -31,5 +31,5 @@ - + diff --git a/addons/sale_team/__init__.py b/addons/sale_team/__init__.py index 6bac200f0db..f6973d5f845 100644 --- a/addons/sale_team/__init__.py +++ b/addons/sale_team/__init__.py @@ -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: \ No newline at end of file diff --git a/addons/sale_team/__openerp__.py b/addons/sale_team/__openerp__.py index 2ea88cc6a92..ea45d3c1e68 100644 --- a/addons/sale_team/__openerp__.py +++ b/addons/sale_team/__openerp__.py @@ -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'], diff --git a/addons/sale_team/res_config_view.xml b/addons/sale_team/res_config_view.xml index 7723fda48fc..ddcc72b5375 100644 --- a/addons/sale_team/res_config_view.xml +++ b/addons/sale_team/res_config_view.xml @@ -1,27 +1,26 @@ - crm settings sale.team.config.settings -
- - - +
+
+
-
+
diff --git a/addons/sale_team/sale_team.py b/addons/sale_team/sale_team.py index 3c13514bd11..db0e4638048 100644 --- a/addons/sale_team/sale_team.py +++ b/addons/sale_team/sale_team.py @@ -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 - - - \ No newline at end of file + return init_res \ No newline at end of file diff --git a/addons/sale_team/sale_team.xml b/addons/sale_team/sale_team.xml index e3bea558a68..b2b98be643a 100644 --- a/addons/sale_team/sale_team.xml +++ b/addons/sale_team/sale_team.xml @@ -24,7 +24,7 @@ res.users - + @@ -75,10 +75,7 @@ - - - Case Sections - Search crm.case.section @@ -99,7 +96,6 @@ - Sales Teams crm.case.section @@ -175,7 +171,6 @@ - crm.case.section.tree crm.case.section @@ -189,15 +184,6 @@ - - - - Sales Teams crm.case.section @@ -213,7 +199,6 @@

- - + \ No newline at end of file diff --git a/addons/sale_team/sale_team_config.py b/addons/sale_team/sale_team_config.py index 33a5e84b8de..2ae861e34b5 100644 --- a/addons/sale_team/sale_team_config.py +++ b/addons/sale_team/sale_team_config.py @@ -1,8 +1,27 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-today OpenERP SA () +# +# 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 . +# +############################################################################## 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."""), - } - - - + } \ No newline at end of file diff --git a/addons/sale_team/sale_team_demo.xml b/addons/sale_team/sale_team_demo.xml index b24c047fba1..58f5ac66b69 100644 --- a/addons/sale_team/sale_team_demo.xml +++ b/addons/sale_team/sale_team_demo.xml @@ -15,6 +15,5 @@ SPD - \ No newline at end of file diff --git a/addons/sale_team/ir.model.access.csv b/addons/sale_team/security/ir.model.access.csv similarity index 87% rename from addons/sale_team/ir.model.access.csv rename to addons/sale_team/security/ir.model.access.csv index 9817ad834f6..e3c55739176 100644 --- a/addons/sale_team/ir.model.access.csv +++ b/addons/sale_team/security/ir.model.access.csv @@ -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 \ No newline at end of file diff --git a/addons/sale_team/security/sale_team_security.xml b/addons/sale_team/security/sale_team_security.xml index 53fb560e332..11e4f583dda 100644 --- a/addons/sale_team/security/sale_team_security.xml +++ b/addons/sale_team/security/sale_team_security.xml @@ -35,6 +35,5 @@ -