From 8066ab43482a3875d4f432a468aaa017aeea4bba Mon Sep 17 00:00:00 2001 From: Patrick Hoste Date: Tue, 4 Aug 2020 12:52:26 +0000 Subject: [PATCH] [REF] crm: update revenue fields names PURPOSE Link field name with their content. SPECIFICATIONS This commit changes the field name "expected_revenue" into "prorated_revenue" and the field name "planned_revenue" into "expected_revenue". Indeed content of those fields evolved since their first naming. Their content is not what the field name indicates. Better rename those fields to understand code flow inside CRM. LINKS Task ID-2283052 odoo/odoo#54194 odoo/enterprise#12423 odoo/upgrade#1463 --- addons/crm/data/crm_lead_demo.xml | 60 +++++++++---------- addons/crm/models/crm_lead.py | 30 +++++----- addons/crm/models/crm_team.py | 8 +-- .../report/crm_opportunity_report_views.xml | 4 +- addons/crm/static/src/js/tours/crm.js | 2 +- addons/crm/views/crm_lead_views.xml | 24 ++++---- .../controllers/main.py | 2 +- .../models/crm_lead.py | 2 +- .../static/src/js/crm_partner_assign.js | 2 +- .../website_crm_partner_assign_templates.xml | 6 +- 10 files changed, 70 insertions(+), 70 deletions(-) diff --git a/addons/crm/data/crm_lead_demo.xml b/addons/crm/data/crm_lead_demo.xml index e1b3c7edf1d..144ed8e5789 100644 --- a/addons/crm/data/crm_lead_demo.xml +++ b/addons/crm/data/crm_lead_demo.xml @@ -343,7 +343,7 @@ Andrew

]]> opportunity Quote for 12 Tables - 40000 + 40000 10.0 Will McEncroe Rediff Mail @@ -367,7 +367,7 @@ Andrew

]]>
opportunity Office Design Project 7 - 24000 + 24000 10.0 Deco Addict info@agrolait.com @@ -392,7 +392,7 @@ Andrew

]]> opportunity Info about services - 25000 + 25000 30.0 virginie@agrolait.com @@ -484,7 +484,7 @@ Andrew

]]>
opportunity Global Solutions: Furnitures - 3800 + 3800 90.0 Robin Smith Global Solutions @@ -508,7 +508,7 @@ Andrew

]]>
opportunity Balmer Inc: Potential Distributor - 1000 + 1000 35.0 BalmerInc S.A. Oliver Passot @@ -542,7 +542,7 @@ Andrew

]]>
opportunity DeltaPC: 10 Computer Desks - + Leland Martinez info@deltapc.com @@ -589,7 +589,7 @@ Andrew

]]>
opportunity Customizable Desk 3 - 15000 + 15000 65.5 Nhomar Vauxoo @@ -617,7 +617,7 @@ Andrew

]]>
opportunity Distributor Contract - 19800 + 19800 John M. Brown Epic Technologies john.b@tech.info @@ -640,7 +640,7 @@ Andrew

]]>
opportunity Office Design and Architecture - 9000 + 9000 Birmingham @@ -660,7 +660,7 @@ Andrew

]]>
opportunity 5 VP Chairs - 5600 + 5600 30.0 Benjamin Flores Nebula Business @@ -679,7 +679,7 @@ Andrew

]]>
opportunity Access to Online Catalog - 2000 + 2000 80.0 0 @@ -696,7 +696,7 @@ Andrew

]]>
opportunity Need 20 Desks - 60000 + 60000 90.0 info@mycompany.net @@ -715,7 +715,7 @@ Andrew

]]>
opportunity Modern Open Space - 4500 + 4500 60 Henry Jordan E-light Industry @@ -739,7 +739,7 @@ Andrew

]]>
opportunity Open Space Design - 11000 + 11000 45 Deco Addict info@agrolait.com @@ -763,7 +763,7 @@ Andrew

]]>
opportunity Interest in your products - 2000 + 2000 80 Deco Addict info@agrolait.com @@ -787,7 +787,7 @@ Andrew

]]>
opportunity Furnish a 60m² office - 7500 + 7500 20 Deco Addict info@agrolait.com @@ -852,7 +852,7 @@ Andrew

]]>
opportunity Quote for 150 carpets - 40000 + 40000 10.0 Erik N. French ErikNFrench@armyspy.com @@ -874,7 +874,7 @@ Andrew

]]>
opportunity Quote for 600 Chairs - 22500 + 22500 20.0 Erik N. French ErikNFrench@armyspy.com @@ -896,7 +896,7 @@ Andrew

]]>
lead Recurring delivery contract -36221 +36221 20 Max Johnson max123@itconsult.com @@ -915,7 +915,7 @@ Andrew

]]>
lead Need info about pricing -28443 +28443 80 Aloysius Akred aakreda@theglobeandmail.com @@ -935,7 +935,7 @@ Andrew

]]>
lead Trelian New Offices -88715 +88715 12 Rosalynd Oxshott Photobug @@ -955,7 +955,7 @@ Andrew

]]>
lead Branded Furniture -7784 +7784 20 Myrna Limprecht mlimprecht8@fastcompany.com @@ -974,7 +974,7 @@ Andrew

]]>
lead Design New Shelves -54587 +54587 81 Alys Kalinovich Jaloo @@ -994,7 +994,7 @@ Andrew

]]>
lead Office chairs -5474 +5474 20 Jennine Jobbins Shufflebeat @@ -1014,7 +1014,7 @@ Andrew

]]>
lead Cleaning subscription -11475 +11475 25 Elmo Espinazo Realblab @@ -1034,7 +1034,7 @@ Andrew

]]>
lead Custom Desks (100 pieces) -9987 +9987 20 Chalmers Redford Muxo @@ -1056,7 +1056,7 @@ Andrew

]]>
lead Need a price: urgent -4482 +4482 90 Itch Kirvell Skibox @@ -1076,7 +1076,7 @@ Andrew

]]>
lead Furnitures for new location -22500 +22500 20 Napoleon Grabert Twinte @@ -1096,7 +1096,7 @@ Andrew

]]>
lead Modernize old offices -99755 +99755 20 Franny Seiller Yozio @@ -1117,7 +1117,7 @@ Andrew

]]>
lead Quote for 35 windows -41421 +41421 20 Tommi Brockhouse Gabcube diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index 57e08c62d29..12b39893342 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -38,7 +38,7 @@ CRM_LEAD_FIELDS_TO_MERGE = [ 'partner_name', 'phone', 'probability', - 'planned_revenue', + 'expected_revenue', 'street', 'street2', 'zip', @@ -125,8 +125,8 @@ class Lead(models.Model): help="Classify and analyze your lead/opportunity categories like: Training, Service") color = fields.Integer('Color Index', default=0) # Opportunity specific - planned_revenue = fields.Monetary('Expected Revenue', currency_field='company_currency', tracking=True) - expected_revenue = fields.Monetary('Prorated Revenue', currency_field='company_currency', store=True, compute="_compute_expected_revenue") + expected_revenue = fields.Monetary('Expected Revenue', currency_field='company_currency', tracking=True) + prorated_revenue = fields.Monetary('Prorated Revenue', currency_field='company_currency', store=True, compute="_compute_prorated_revenue") company_currency = fields.Many2one("res.currency", string='Currency', related='company_id.currency_id', readonly=True) # Dates date_closed = fields.Datetime('Closed Date', readonly=True, copy=False) @@ -366,10 +366,10 @@ class Lead(models.Model): if was_automated: lead.probability = lead.automated_probability - @api.depends('planned_revenue', 'probability') - def _compute_expected_revenue(self): + @api.depends('expected_revenue', 'probability') + def _compute_prorated_revenue(self): for lead in self: - lead.expected_revenue = round((lead.planned_revenue or 0.0) * (lead.probability or 0) / 100.0, 2) + lead.prorated_revenue = round((lead.expected_revenue or 0.0) * (lead.probability or 0) / 100.0, 2) def _compute_meeting_count(self): if self.ids: @@ -721,14 +721,14 @@ class Lead(models.Model): self.ensure_one() self.action_set_won() - if self.user_id and self.team_id and self.planned_revenue: + if self.user_id and self.team_id and self.expected_revenue: query = """ SELECT SUM(CASE WHEN user_id = %(user_id)s THEN 1 ELSE 0 END) as total_won, - MAX(CASE WHEN date_closed >= CURRENT_DATE - INTERVAL '30 days' AND user_id = %(user_id)s THEN planned_revenue ELSE 0 END) as max_user_30, - MAX(CASE WHEN date_closed >= CURRENT_DATE - INTERVAL '7 days' AND user_id = %(user_id)s THEN planned_revenue ELSE 0 END) as max_user_7, - MAX(CASE WHEN date_closed >= CURRENT_DATE - INTERVAL '30 days' AND team_id = %(team_id)s THEN planned_revenue ELSE 0 END) as max_team_30, - MAX(CASE WHEN date_closed >= CURRENT_DATE - INTERVAL '7 days' AND team_id = %(team_id)s THEN planned_revenue ELSE 0 END) as max_team_7 + MAX(CASE WHEN date_closed >= CURRENT_DATE - INTERVAL '30 days' AND user_id = %(user_id)s THEN expected_revenue ELSE 0 END) as max_user_30, + MAX(CASE WHEN date_closed >= CURRENT_DATE - INTERVAL '7 days' AND user_id = %(user_id)s THEN expected_revenue ELSE 0 END) as max_user_7, + MAX(CASE WHEN date_closed >= CURRENT_DATE - INTERVAL '30 days' AND team_id = %(team_id)s THEN expected_revenue ELSE 0 END) as max_team_30, + MAX(CASE WHEN date_closed >= CURRENT_DATE - INTERVAL '7 days' AND team_id = %(team_id)s THEN expected_revenue ELSE 0 END) as max_team_7 FROM crm_lead WHERE type = 'opportunity' @@ -748,13 +748,13 @@ class Lead(models.Model): message = False if query_result['total_won'] == 1: message = _('Go, go, go! Congrats for your first deal.') - elif query_result['max_team_30'] == self.planned_revenue: + elif query_result['max_team_30'] == self.expected_revenue: message = _('Boom! Team record for the past 30 days.') - elif query_result['max_team_7'] == self.planned_revenue: + elif query_result['max_team_7'] == self.expected_revenue: message = _('Yeah! Deal of the last 7 days for the team.') - elif query_result['max_user_30'] == self.planned_revenue: + elif query_result['max_user_30'] == self.expected_revenue: message = _('You just beat your personal record for the past 30 days.') - elif query_result['max_user_7'] == self.planned_revenue: + elif query_result['max_user_7'] == self.expected_revenue: message = _('You just beat your personal record for the past 7 days.') if message: diff --git a/addons/crm/models/crm_team.py b/addons/crm/models/crm_team.py index 695823a0d80..5d0b8267d43 100644 --- a/addons/crm/models/crm_team.py +++ b/addons/crm/models/crm_team.py @@ -63,14 +63,14 @@ class Team(models.Model): ('team_id', 'in', self.ids), ('probability', '<', 100), ('type', '=', 'opportunity'), - ]).read(['planned_revenue', 'team_id']) + ]).read(['expected_revenue', 'team_id']) counts = {} amounts = {} for datum in opportunity_data: counts.setdefault(datum['team_id'][0], 0) amounts.setdefault(datum['team_id'][0], 0) counts[datum['team_id'][0]] += 1 - amounts[datum['team_id'][0]] += (datum.get('planned_revenue', 0)) + amounts[datum['team_id'][0]] += (datum.get('expected_revenue', 0)) for team in self: team.opportunities_count = counts.get(team.id, 0) team.opportunities_amount = amounts.get(team.id, 0) @@ -81,9 +81,9 @@ class Team(models.Model): ('probability', '<', 100), ('type', '=', 'opportunity'), ('date_deadline', '<', fields.Date.to_string(fields.Datetime.now())) - ], ['planned_revenue', 'team_id'], ['team_id']) + ], ['expected_revenue', 'team_id'], ['team_id']) counts = {datum['team_id'][0]: datum['team_id_count'] for datum in opportunity_data} - amounts = {datum['team_id'][0]: (datum['planned_revenue']) for datum in opportunity_data} + amounts = {datum['team_id'][0]: (datum['expected_revenue']) for datum in opportunity_data} for team in self: team.opportunities_overdue_count = counts.get(team.id, 0) team.opportunities_overdue_amount = amounts.get(team.id, 0) diff --git a/addons/crm/report/crm_opportunity_report_views.xml b/addons/crm/report/crm_opportunity_report_views.xml index f8b101e02c7..b97a0f6fc14 100644 --- a/addons/crm/report/crm_opportunity_report_views.xml +++ b/addons/crm/report/crm_opportunity_report_views.xml @@ -10,7 +10,7 @@ - + @@ -35,7 +35,7 @@ - +
diff --git a/addons/crm/static/src/js/tours/crm.js b/addons/crm/static/src/js/tours/crm.js index db1ff6d1e8e..6af1e0207af 100644 --- a/addons/crm/static/src/js/tours/crm.js +++ b/addons/crm/static/src/js/tours/crm.js @@ -35,7 +35,7 @@ tour.register('crm_tour', { trigger: ".o_kanban_quick_create .o_field_widget[name='name']", auto: true, }, { - trigger: '.o_kanban_quick_create .o_field_monetary[name="planned_revenue"]', + trigger: '.o_kanban_quick_create .o_field_monetary[name="expected_revenue"]', content: _t("Define here the Expected Revenue of this Opportunity."), position: 'right', }, { diff --git a/addons/crm/views/crm_lead_views.xml b/addons/crm/views/crm_lead_views.xml index 749187354a2..67bc4f41e67 100644 --- a/addons/crm/views/crm_lead_views.xml +++ b/addons/crm/views/crm_lead_views.xml @@ -47,10 +47,10 @@

-
@@ -387,7 +387,7 @@ - + @@ -405,9 +405,9 @@ -