[FIX] website_sale: add conditions to make sure partner's name exists
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) <anv@odoo.com> Signed-off-by: Jinjiu Liu (jili) <jili@odoo.com>
This commit is contained in:
@@ -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."
|
||||
))
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user