From d361d4948150edc675c2c2cd1cd2565b625ea2db Mon Sep 17 00:00:00 2001 From: ijas ahammed Date: Wed, 3 Mar 2021 06:35:50 +0000 Subject: [PATCH] [IMP] website_crm_partner_assign: improve opportunity front-end page This commit improves the following: - Hides the icons under the 'Contact' section if the related information is not available. - Moves the 'Next Activity Date' next to 'Next Activity' on opportunity edition dialog, and opens the date-picker to schedule next activity below the input instead of above it. - Increased the height of 'Details Next Activity' textarea so that 'Next Activity Date' picker can be shown within the modal without introducing scroll-bar. - This commit renames the label 'Title' to 'Opportunity' to avoid confusion, and auto-fills it based on the 'Contact Name' for the modal that is used for creating opportunities from front-end. Apart from that, this commit also improves string of the button responsible to create new opportunity from front-end. TaskID-2443894 closes https://github.com/odoo/odoo/pull/67524 Part-of: odoo/odoo#67524 --- .../static/src/js/crm_partner_assign.js | 19 +++-- .../website_crm_partner_assign_templates.xml | 71 ++++++++++--------- 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/addons/website_crm_partner_assign/static/src/js/crm_partner_assign.js b/addons/website_crm_partner_assign/static/src/js/crm_partner_assign.js index e43d1430579..2f3974807ba 100644 --- a/addons/website_crm_partner_assign/static/src/js/crm_partner_assign.js +++ b/addons/website_crm_partner_assign/static/src/js/crm_partner_assign.js @@ -1,6 +1,7 @@ odoo.define('crm.partner_assign', function (require) { 'use strict'; +const {_t} = require('web.core'); var publicWidget = require('web.public.widget'); var time = require('web.time'); @@ -15,6 +16,7 @@ publicWidget.registry.crmPartnerAssign = publicWidget.Widget.extend({ 'click .new_opp_confirm': '_onNewOppConfirm', 'click .edit_opp_confirm': '_onEditOppConfirm', 'change .edit_opp_form .next_activity': '_onChangeNextActivity', + 'change #new-opp-dialog .contact_name': '_onChangeContactName', 'click div.input-group.date[data-target-input="nearest"]': '_onCalendarInputGroupClick', }, @@ -229,6 +231,17 @@ publicWidget.registry.crmPartnerAssign = publicWidget.Widget.extend({ ev.stopPropagation(); this._buttonExec($(ev.currentTarget), this._editOpportunity); }, + /** + * @private + * @param {Event} ev + */ + _onChangeContactName: function (ev) { + const contactName = ev.currentTarget.value.trim(); + let titleEl = this.el.querySelector('.title'); + if (!titleEl.value.trim()) { + titleEl.value = contactName ? _.str.sprintf(_t("%s's Opportunity"), contactName) : ''; + } + }, /** * @private * @param {Event} ev @@ -259,12 +272,6 @@ publicWidget.registry.crmPartnerAssign = publicWidget.Widget.extend({ down: 'fa fa-chevron-down', }, }; - // in some screen sizes, the automatic position opens the picker below input, - // but because #next_activity_div is the last element, we always open the - // picker on top the input to prevent extra scroll - if ($calendarInputGroup.is('#next_activity_div')) { - calendarOptions.widgetPositioning = {vertical: 'top'}; - } $calendarInputGroup.datetimepicker(calendarOptions); }, diff --git a/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml b/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml index 796dae42fff..72b4fdbf243 100644 --- a/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml +++ b/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml @@ -254,7 +254,7 @@
@@ -273,7 +273,7 @@
- +
@@ -569,31 +569,29 @@
Customer
-
+
-
+
- - - +
-
+
- - - +
-
+
- - - +
Address -
+
@@ -602,7 +600,7 @@
-
+
@@ -684,28 +682,35 @@
- - +
+
+ + +
+
+ +
+ + +
+ + + +
+
+
+
- -
-
- -
- - -
- - - -
-
+