From 38ca39176f19214dfb6cfb60f89434e54515ce39 Mon Sep 17 00:00:00 2001 From: Jinjiu Liu <jili@odoo.com> Date: Tue, 11 Jul 2023 16:28:26 +0200 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#128146 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com> --- addons/website_sale/controllers/main.py | 6 +++--- addons/website_sale/i18n/website_sale.pot | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 0e6f8c1911b9..df8f490307e0 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -581,11 +581,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 73e88c89054a..6ec2a4f5ede2 100644 --- a/addons/website_sale/i18n/website_sale.pot +++ b/addons/website_sale/i18n/website_sale.pot @@ -782,6 +782,14 @@ msgid "" "account. Please contact us directly for this operation." msgstr "" +#. module: website_sale +#: 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:ir.model.fields,field_description:website_sale.field_product_public_category__child_id msgid "Children Categories" -- GitLab