From 125fcaa6202e2b2b70761ce5bb12e4e1fd3cb2b1 Mon Sep 17 00:00:00 2001 From: Jinjiu Liu Date: Tue, 11 Jul 2023 14:28:26 +0000 Subject: [PATCH] [FIX] website_sale: add conditions to make sure partner's name exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reproduction: 1. Install Event, Sales, Website, Contacts 2. Login as Admin, create a new portal user 123, set the password as 123 3. Go to Contacts, find the created user, add a shipping address, leave the name blank 4. Open another tab login as the portal user, place an order 5. At the Address step, Edit the billing address, change the name from empty to “Test Name”, click next 5. An error is thrown cause the new name is not equal to empty value Fix: this fix aimed the conditions we have in the previous PR: https://github.com/odoo/odoo/pull/111708 This change will allow the user to add a name for shipping address at checkout.Without the fix, if you change the name of a shipping address, it won’t be able to get through. This is because of how we manage the shipping address, e.g. shipping address is managed as child partners. For shipping address, the check can_edit_vat is always false. See here: https://github.com/odoo/odoo/blob/14.0/addons/portal/models/res_partner.py Another check, e.g. if shipping is being edited, is added to make sure name/email can be changed for delivery address. For internal user, the editing of shipping address is not blocked because of the `share` check. But the same condition is used to ensure the consistency in case we change how the shipping address is managed in the future. Note: if the data is '' for name for example, the pre-process will convert it to `False`. Thus the edge case that `'' != False` doen't exist anymore Related PR: https://github.com/odoo/odoo/pull/111708 opw-3126325 closes odoo/odoo#134606 X-original-commit: 55423cbdeeb1ce35fb257624ea0d04d4be99a943 Signed-off-by: Antoine Vandevenne (anv) Signed-off-by: Jinjiu Liu (jili) --- addons/website_sale/controllers/main.py | 6 +++--- addons/website_sale/i18n/website_sale.pot | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 782384d75a2..cb2adc4c829 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -1000,11 +1000,11 @@ class WebsiteSale(http.Controller): name_change = partner_su and 'name' in data and data['name'] != partner_su.name email_change = partner_su and 'email' in data and data['email'] != partner_su.email - # Prevent changing the partner name if invoices have been issued. - if name_change and not partner_su.can_edit_vat(): + # Prevent changing the billing partner name if invoices have been issued. + if mode[1] == 'billing' and name_change and not partner_su.can_edit_vat(): error['name'] = 'error' error_message.append(_( - "Changing your name is not allowed once invoices have been issued for your" + "Changing your name is not allowed once documents have been issued for your" " account. Please contact us directly for this operation." )) diff --git a/addons/website_sale/i18n/website_sale.pot b/addons/website_sale/i18n/website_sale.pot index 2330e53bc78..d8e8b3202bd 100644 --- a/addons/website_sale/i18n/website_sale.pot +++ b/addons/website_sale/i18n/website_sale.pot @@ -1132,6 +1132,15 @@ msgid "" "account. Please contact us directly for this operation." msgstr "" +#. module: website_sale +#. odoo-python +#: code:addons/website_sale/controllers/main.py:0 +#, python-format +msgid "" +"Changing your name is not allowed once documents have been issued for your " +"account. Please contact us directly for this operation." +msgstr "" + #. module: website_sale #: model_terms:ir.ui.view,arch_db:website_sale.snippet_options msgid "Checkout Pages"