summaryrefslogtreecommitdiff
path: root/addons/mail/models/mail_alias.py
diff options
context:
space:
mode:
authorJulien Castiaux <juc@odoo.com>2020-08-06 11:04:16 +0000
committerGoffin Simon <sig@odoo.com>2020-09-22 18:57:25 +0000
commitad2cc2fe43cb80a7ab3b0bcd08ea29aa5b403761 (patch)
treeaa89c311bc3c691da757a1cb93dc151d7a3b48cc /addons/mail/models/mail_alias.py
parentbfbc1db205de43c8c89ca882e809d578bb733ac0 (diff)
[FIX] account,mail: default purchase mail alias non-ascii
* Change the `addons/account/i18n/vi.po` PO file to replace the translation of `Vendor Bill` like msgids from `Công nợ nhà cung cấp` to ` by `Hóa đơn Nhà cung cấp`, there should be 3. What's matter is the `đ` character. * Create a brand new Vietnamese database (using `-l vi_VN` and `--load-language=vi_VN`) * Install Invoicing (`account`), an email alias constraint is raised. > You cannot use anything else than unaccented latin characters in the > alias address. During the installation of the invoicing module, an email alias is created for every journal account of purchase type. The alias is created using the current journal name. Here the journal name is `Hóa đơn Nhà cung cấp`, as mail aliases should only contain ascii characters, we attempt to remove the accents. The `tools.misc.remove_accents` successfully remove most of them but the `đ` character is left as-is, the final alias is `hoa-đon-nha-cung-cap` which is invalid as it contains some non-ascii characters. The `remove_accents` function uses the [NFKD] Unicode Compatibility Decomposition Normalization Form. This normalization process unify all abstract equivalent characters, i.e. characters only different by font or rotation. While this normalization process helps to transcript a lot of characters to their ascii compatibility equivalent, some 118,230 other non-ascii characters (mainly from the Chinese and Japanese scripts) are left as-is as they lack an ascii compatibility equivalent. The solution has been to not use the journal name but rather the journal code or journal type as email alias when the name is unsafe. The journal code is a short version of the name, the journal type is not translatable so is always ascii. One additional watchdog has been added to the sanitization function of email aliases so non-ascii characters are replaced with a '?' which is an authorized character in emails local-part. [NFKD] https://unicode.org/reports/tr15/ Closes #55492 Closes #55493 closes odoo/odoo#58276 X-original-commit: 8dc85be3821cf26226cd0bf4ce2b6739e68fc66f Signed-off-by: Simon Goffin (sig) <sig@openerp.com> Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com> Co-authored-by: Thong Le <thongthele@users.no-reply.github.com>
Diffstat (limited to 'addons/mail/models/mail_alias.py')
-rw-r--r--addons/mail/models/mail_alias.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/addons/mail/models/mail_alias.py b/addons/mail/models/mail_alias.py
index 3c08bb168d6..b41b267947f 100644
--- a/addons/mail/models/mail_alias.py
+++ b/addons/mail/models/mail_alias.py
@@ -142,6 +142,7 @@ class Alias(models.Model):
name already exists an UserError is raised. """
sanitized_name = remove_accents(name).lower().split('@')[0]
sanitized_name = re.sub(r'[^\w+.]+', '-', sanitized_name)
+ sanitized_name = sanitized_name.encode('ascii', errors='replace').decode()
catchall_alias = self.env['ir.config_parameter'].sudo().get_param('mail.catchall.alias')
bounce_alias = self.env['ir.config_parameter'].sudo().get_param('mail.bounce.alias')