From 5425316eff19e7ae716aafdb730c92d1b3ea2abb Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Wed, 16 Dec 2015 14:16:20 +0100 Subject: [PATCH 01/25] [FIX] auth_signup: no SQL error for duplicated user In case of registration with an already existant user, an SQL error 'duplicate key value violates unique constaint res_users_login_key...' Replace by a more user friendly error. Fixes #10068, opw 659913 --- addons/auth_signup/controllers/main.py | 6 +++++- addons/auth_signup/i18n/auth_signup.pot | 26 +++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py index 91326d5d530..7678db52198 100644 --- a/addons/auth_signup/controllers/main.py +++ b/addons/auth_signup/controllers/main.py @@ -54,7 +54,11 @@ class AuthSignupHome(openerp.addons.web.controllers.main.Home): self.do_signup(qcontext) return super(AuthSignupHome, self).web_login(*args, **kw) except (SignupError, AssertionError), e: - qcontext['error'] = _(e.message) + if request.env["res.users"].sudo().search([("login", "=", qcontext.get("login"))]): + qcontext["error"] = _("Another user is already registered using this email address.") + else: + _logger.error(e.message) + qcontext['error'] = _("Could not create a new account.") return request.render('auth_signup.signup', qcontext) diff --git a/addons/auth_signup/i18n/auth_signup.pot b/addons/auth_signup/i18n/auth_signup.pot index a635a4ac086..ba66c98cbdb 100644 --- a/addons/auth_signup/i18n/auth_signup.pot +++ b/addons/auth_signup/i18n/auth_signup.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-01-21 14:07+0000\n" -"PO-Revision-Date: 2015-01-21 14:07+0000\n" +"POT-Creation-Date: 2015-12-16 13:15+0000\n" +"PO-Revision-Date: 2015-12-16 13:15+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -86,7 +86,13 @@ msgid "An invitation email containing the following subscription link has been s msgstr "" #. module: auth_signup -#: code:addons/auth_signup/controllers/main.py:125 +#: code:addons/auth_signup/controllers/main.py:58 +#, python-format +msgid "Another user is already registered using this email address." +msgstr "" + +#. module: auth_signup +#: code:addons/auth_signup/controllers/main.py:130 #, python-format msgid "Authentification Failed." msgstr "" @@ -109,7 +115,13 @@ msgid "Confirm Password" msgstr "" #. module: auth_signup -#: code:addons/auth_signup/controllers/main.py:80 +#: code:addons/auth_signup/controllers/main.py:61 +#, python-format +msgid "Could not create a new account." +msgstr "" + +#. module: auth_signup +#: code:addons/auth_signup/controllers/main.py:84 #, python-format msgid "Could not reset your password" msgstr "" @@ -160,6 +172,12 @@ msgstr "" msgid "Reset password" msgstr "" +#. module: auth_signup +#: code:addons/auth_signup/res_users.py:267 +#, python-format +msgid "Reset password: invalid username or email" +msgstr "" + #. module: auth_signup #: view:res.users:auth_signup.res_users_form_view msgid "Send Reset Password Instructions" From fc3c0b22f9d3a16a0b7aefde68a278dd9fff9789 Mon Sep 17 00:00:00 2001 From: Antonio Espinosa Date: Mon, 14 Dec 2015 12:37:02 +0100 Subject: [PATCH 02/25] [FIX] mass_mailing: absolute URLs to email images Partial backport of 9.0 commit a14f89c8 to 8.0 are not well supported in some webmails Replace absolute URLs by full path appending the domain. Closes #10062 --- addons/mass_mailing/models/mail_mail.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/mass_mailing/models/mail_mail.py b/addons/mass_mailing/models/mail_mail.py index 651d8f07729..c2775ad019b 100644 --- a/addons/mass_mailing/models/mail_mail.py +++ b/addons/mass_mailing/models/mail_mail.py @@ -21,6 +21,7 @@ import urlparse import werkzeug.urls +import re from openerp.tools.translate import _ from openerp import tools @@ -80,6 +81,14 @@ class MailMail(osv.Model): base = "" % domain body = tools.append_content_to_html(base, body, plaintext=False, container_tag='div') + # resolve relative image url to absolute for outlook.com + def _sub_relative2absolute(match): + return match.group(1) + urlparse.urljoin(domain, match.group(2)) + # Regex: https://regex101.com/r/aE8uG5/3 + body = re.sub('(]*\ssrc=["\'])(/[^/][^"\']+)', _sub_relative2absolute, body) + # Regex: https://regex101.com/r/kT3lD5/2 + body = re.sub(r'(<[^>]+\bstyle=["\'][^"\']+\burl\([\'"]?)(/[^/\'"][^\'")]+)', _sub_relative2absolute, body) + # generate tracking URL if mail.statistics_ids: tracking_url = self._get_tracking_url(cr, uid, mail, partner, context=context) From 7f29a231186deb1856098d81703848ab6b24328c Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 16 Dec 2015 17:06:46 +0100 Subject: [PATCH 03/25] [FIX] tools: email TLDs can be longer than 6 chars According to the RFC1034 https://tools.ietf.org/html/rfc1034 A TLD can use up to 63 octets. The regex checking that an email address is valid should there allow emails using a TLD with such a length. Besides, the use of TLD domains exceeding 6 characters is more and more common, nowadays. e.g. using a domain `.amsterdam` opw-660014 --- openerp/tools/mail.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/tools/mail.py b/openerp/tools/mail.py index 20d6117e778..40a52a42b5f 100644 --- a/openerp/tools/mail.py +++ b/openerp/tools/mail.py @@ -603,10 +603,10 @@ def append_content_to_html(html, content, plaintext=True, preserve=False, contai #---------------------------------------------------------- # matches any email in a body of text -email_re = re.compile(r"""([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})""", re.VERBOSE) +email_re = re.compile(r"""([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63})""", re.VERBOSE) # matches a string containing only one email -single_email_re = re.compile(r"""^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$""", re.VERBOSE) +single_email_re = re.compile(r"""^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$""", re.VERBOSE) res_re = re.compile(r"\[([0-9]+)\]", re.UNICODE) command_re = re.compile("^Set-([a-z]+) *: *(.+)$", re.I + re.UNICODE) From d251041c05706d7749bae38942a18dbab9edde79 Mon Sep 17 00:00:00 2001 From: "Suganthi, Sodexis" Date: Thu, 3 Dec 2015 16:33:00 +0530 Subject: [PATCH 04/25] [FIX] account_anglo_saxon: analytic account on the expense move line When using Anglo-Saxon accounting, the customer invoice has two extra lines: - One on the output account - One on the expense account the move line with the expense account should have the analytic account set on the invoice line This is related to the revision efee12a1bb7139ddf8fb67dc3f97be447aa77aa3, solving the below issue: https://bugs.launchpad.net/openobject-addons/+bug/921877 opw-659931 closes #10026 --- addons/account_anglo_saxon/invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py index 69256a6b016..a330210b456 100644 --- a/addons/account_anglo_saxon/invoice.py +++ b/addons/account_anglo_saxon/invoice.py @@ -121,7 +121,7 @@ class account_invoice_line(osv.osv): 'account_id':fiscal_pool.map_account(cr, uid, fpos, cacc), 'product_id':i_line.product_id.id, 'uos_id':i_line.uos_id.id, - 'account_analytic_id': False, + 'account_analytic_id': i_line.account_analytic_id.id, 'taxes':i_line.invoice_line_tax_id, }, ] From ca40236ddc75424be0e361f33adc55e8663ca399 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 17 Dec 2015 14:26:06 +0100 Subject: [PATCH 05/25] [FIX] sale: onchange_product_uom The function "product_uom_change" was built to reset the price unit of a SO line when the uom was changed. Before this fix 503820a, the price unit of the SO line only depended on the price list then it was not needed to pass the fiscal position to this function. After this fix 503820a, the price unit of a SO line also depends on the taxes set on the SO line(e.g.:if an included tax is deleted, the price unit must be recomputed without this tax). Then to recompute the unit price, the function "product_id_change" must take into account the fiscal position set on the SO to consider the right taxes to recompute the unit price. The fiscal position set on a SO must be passed to onchange_product_uom each time it will be called because the price unit will be recomputed. --- addons/sale/sale.py | 12 ++++++++++++ addons/sale/sale_view.xml | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index d172c7bdb2c..119bee779aa 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -1232,6 +1232,18 @@ class sale_order_line(osv.osv): partner_id=partner_id, lang=lang, update_tax=update_tax, date_order=date_order, context=context) + def onchange_product_uom(self, cursor, user, ids, pricelist, product, qty=0, + uom=False, qty_uos=0, uos=False, name='', partner_id=False, + lang=False, update_tax=True, date_order=False, fiscal_position=False, context=None): + context = context or {} + lang = lang or ('lang' in context and context['lang']) + if not uom: + return {'value': {'price_unit': 0.0, 'product_uom' : uom or False}} + return self.product_id_change(cursor, user, ids, pricelist, product, + qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name, + partner_id=partner_id, lang=lang, update_tax=update_tax, + date_order=date_order, fiscal_position=fiscal_position, context=context) + def unlink(self, cr, uid, ids, context=None): if context is None: context = {} diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index be3ad08b6ee..675a621071f 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -134,7 +134,7 @@ on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, False, parent.fiscal_position, True, context)"/> + on_change="onchange_product_uom(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, parent.fiscal_position, context)"/>