From c50745f1a1f04ce06696a5095b5ff7407e7dac60 Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Fri, 9 Jun 2017 12:26:38 +0200 Subject: [PATCH 1/3] [FIX] base_geolocalize: geocode errors out on empty address It's unclear whether that's a recent change or a long-standing issue, however currently if geocode is called with an empty address string it will reply with a 400 Bad Request, which gets raised as an exception and forwarded to the user. That is not a great experience. Shortcut the entire thing and just return None (= geolocation failed / no geolocation) on trying to geolocate an empty address. OPW-746686 backport of 74a89bcf5c656a0a64f2a699444d39739ff7f1d2 --- addons/base_geolocalize/models/res_partner.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/base_geolocalize/models/res_partner.py b/addons/base_geolocalize/models/res_partner.py index 0b4a3ecf153..c42f8f55627 100644 --- a/addons/base_geolocalize/models/res_partner.py +++ b/addons/base_geolocalize/models/res_partner.py @@ -31,6 +31,8 @@ from openerp.tools.translate import _ def geo_find(addr): + if not addr: + return None url = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=' url += urllib2.quote(addr.encode('utf8')) From ed61da6793298ce8d2ecb17e195d64585e4baa76 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Fri, 9 Jun 2017 16:43:13 +0200 Subject: [PATCH 2/3] [FIX] base: duplicate company => duplicate partner The name of a company is uniq. The name of a company comes from a partner and is required. Thus duplicating a company didn't work. With this change, if no partner is overriding the copy, the current partner is duplicated and associated to the new duplicated company. opw-746106 closes #17532 --- openerp/addons/base/res/res_company.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py index 71995487cf1..596d4143849 100644 --- a/openerp/addons/base/res/res_company.py +++ b/openerp/addons/base/res/res_company.py @@ -22,7 +22,7 @@ import os import re import openerp -from openerp import SUPERUSER_ID, tools +from openerp import SUPERUSER_ID, tools, api from openerp.osv import fields, osv from openerp.tools.translate import _ from openerp.tools.safe_eval import safe_eval as eval @@ -154,6 +154,19 @@ class res_company(osv.osv): ('name_uniq', 'unique (name)', 'The company name must be unique !') ] + @api.multi + def copy(self, default=None): + """ + Duplicating a company without specifying a partner duplicate the partner + """ + self.ensure_one() + default = dict(default or {}) + if not default.get('name') and not default.get('partner_id'): + copy_partner = self.partner_id.copy() + default['partner_id'] = copy_partner.id + default['name'] = copy_partner.name + return super(res_company, self).copy(default) + def onchange_footer(self, cr, uid, ids, custom_footer, phone, fax, email, website, vat, company_registry, bank_ids, context=None): if custom_footer: return {} From 06141c34a5960be9315b8c6393a1ec3b71e92588 Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Mon, 12 Jun 2017 13:53:19 +0200 Subject: [PATCH 3/3] [FIX] auth_oauth: don't assume that google and facebook providers always exist Before this commit, it was not possible to reach the general settings when one of the "default" provider was delete. After this commit, we don't assume anymore that there are google and facebook providers. opw-746907 --- addons/auth_oauth/res_config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/auth_oauth/res_config.py b/addons/auth_oauth/res_config.py index de5f1a74b2d..09c48922415 100644 --- a/addons/auth_oauth/res_config.py +++ b/addons/auth_oauth/res_config.py @@ -45,10 +45,10 @@ class base_config_settings(osv.TransientModel): rg = self.pool.get('auth.oauth.provider').read(cr, uid, [google_id], ['enabled','client_id'], context=context) rf = self.pool.get('auth.oauth.provider').read(cr, uid, [facebook_id], ['enabled','client_id'], context=context) return { - 'auth_oauth_google_enabled': rg[0]['enabled'], - 'auth_oauth_google_client_id': rg[0]['client_id'], - 'auth_oauth_facebook_enabled': rf[0]['enabled'], - 'auth_oauth_facebook_client_id': rf[0]['client_id'], + 'auth_oauth_google_enabled': rg[0]['enabled'] if rg else False, + 'auth_oauth_google_client_id': rg[0]['client_id'] if rg else False, + 'auth_oauth_facebook_enabled': rf[0]['enabled'] if rf else False, + 'auth_oauth_facebook_client_id': rf[0]['client_id'] if rf else False, } def set_oauth_providers(self, cr, uid, ids, context=None):