[FIX] website_crm_partner_assign: require fields

**Current behavior:**
Trying to create an opportunity as a portal user and leaving
any of the fields empty will cause an unnecessary exception
dialog to flash on screen.

**Expected behavior:**
Submitting the form with empty required fields will just prompt
the user to add values to all fields.

**Steps to reproduce:**
1. In the Contacts application, go to a portal user and in the
     Partner Assignment notebook tab, give them a partner level

2. In the CRM app, create a new lead and assign the portal user
     who was granted the partner level as the customer

3. Login as the portal user, and convert the lead in My Leads
     to an opportunity

4. Go to the my/opportunities website menu

3. Select 'Create Opportunity' in the top right and leave
     any/all of the fields empty then select 'Confirm'

**Cause of the issue:**
The catch block in the _buttonExec() function is rejecting its
Promise when it catches anything aside from an RPCError.

**Fix:**
Only reject the Promise when the catch block encounters an
actual Error, preventing dialog window popups when non-critical
exceptions (non-Errors) are thrown.

opw-3703238

closes odoo/odoo#151982

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Ethan Vincent
2024-02-13 08:30:14 +00:00
parent 197bb9c394
commit dca2dd0550
@@ -3,7 +3,6 @@
import { _t } from "@web/core/l10n/translation";
import publicWidget from "@web/legacy/js/public/public_widget";
import { parseDate, formatDate, serializeDate } from "@web/core/l10n/dates";
import { RPCError } from "@web/core/network/rpc_service";
const { DateTime } = luxon;
publicWidget.registry.crmPartnerAssign = publicWidget.Widget.extend({
@@ -40,7 +39,7 @@ publicWidget.registry.crmPartnerAssign = publicWidget.Widget.extend({
$btn.prop('disabled', true);
return callback.call(this).catch(function (e) {
$btn.prop('disabled', false);
if (!(e instanceof RPCError)) {
if (e instanceof Error) {
return Promise.reject(e);
}
});