diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 1d4cda555e5..cf28b23c960 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -3371,6 +3371,19 @@ msgstr "" msgid "Day(s) after the invoice date" msgstr "" +#. module: account +#: code:addons/account/models/company.py:44 +#, python-format +msgid "Dear Sir/Madam,\n" +"\n" +"Our records indicate that some payments on your account are still due. Please find details below.\n" +"If the amount has already been paid, please disregard this notice. Otherwise, please forward us the total amount stated below.\n" +"If you have any queries regarding your account, Please contact us.\n" +"\n" +"Thank you in advance for your cooperation.\n" +"Best Regards," +msgstr "" + #. module: account #: model:ir.model.fields,field_description:account.field_account_move_line_debit #: model:ir.ui.view,arch_db:account.report_financial diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 5dd2568d708..80cb1b4e31d 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -41,14 +41,14 @@ class ResCompany(models.Model): property_stock_valuation_account_id = fields.Many2one('account.account', string="Account Template for Stock Valuation") bank_journal_ids = fields.One2many('account.journal', 'company_id', domain=[('type', '=', 'bank')], string='Bank Journals') overdue_msg = fields.Text(string='Overdue Payments Message', translate=True, - default='''Dear Sir/Madam, + default=lambda t: _('''Dear Sir/Madam, Our records indicate that some payments on your account are still due. Please find details below. If the amount has already been paid, please disregard this notice. Otherwise, please forward us the total amount stated below. If you have any queries regarding your account, Please contact us. Thank you in advance for your cooperation. -Best Regards,''') +Best Regards,''')) @api.multi def _check_lock_dates(self, vals): diff --git a/addons/base_geolocalize/models/res_partner.py b/addons/base_geolocalize/models/res_partner.py index 44fa8d9692f..4c36ffe9207 100644 --- a/addons/base_geolocalize/models/res_partner.py +++ b/addons/base_geolocalize/models/res_partner.py @@ -1,16 +1,26 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. import json +import logging import urllib2 from odoo import api, fields, models, tools, _ from odoo.exceptions import UserError +_logger = logging.getLogger(__name__) -def geo_find(addr): + +def geo_find(addr, apikey=False): if not addr: return None - url = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=' + + if not apikey: + raise UserError(_('''API key for GeoCoding (Places) required.\n + Save this key in System Parameters with key: google.api_key_geocode, value: + Visit https://developers.google.com/maps/documentation/geocoding/get-api-key for more information. + ''')) + + url = "https://maps.googleapis.com/maps/api/geocode/json?key=%s&sensor=false&address=" % apikey url += urllib2.quote(addr.encode('utf8')) try: @@ -19,6 +29,8 @@ def geo_find(addr): raise UserError(_('Cannot contact geolocation servers. Please make sure that your Internet connection is up and running (%s).') % e) if result['status'] != 'OK': + if result.get('error_message'): + _logger.error(result['error_message']) return None try: @@ -46,22 +58,26 @@ class ResPartner(models.Model): partner_longitude = fields.Float(string='Geo Longitude', digits=(16, 5)) date_localization = fields.Date(string='Geolocation Date') + @classmethod + def _geo_localize(cls, apikey, street='', zip='', city='', state='', country=''): + search = geo_query_address(street=street, zip=zip, city=city, state=state, country=country) + result = geo_find(search, apikey) + if result is None: + search = geo_query_address(city=city, state=state, country=country) + result = geo_find(search, apikey) + return result + @api.multi def geo_localize(self): # We need country names in English below + apikey = self.env['ir.config_parameter'].sudo().get_param('google.api_key_geocode') for partner in self.with_context(lang='en_US'): - result = geo_find(geo_query_address(street=partner.street, - zip=partner.zip, - city=partner.city, - state=partner.state_id.name, - country=partner.country_id.name)) - if result is None: - result = geo_find(geo_query_address( - city=partner.city, - state=partner.state_id.name, - country=partner.country_id.name - )) - + result = partner._geo_localize(apikey, + partner.street, + partner.zip, + partner.city, + partner.state_id.name, + partner.country_id.name) if result: partner.write({ 'partner_latitude': result[0], diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index 5dcf0ac332b..e2231b15f63 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -864,7 +864,7 @@ class Lead(models.Model): @api.model def get_empty_list_help(self, help): - if help: + if help and help.find("oe_view_nocontent_create") == -1: alias_record = self.env.ref("crm.mail_alias_lead_info", raise_if_not_found=False) if alias_record and alias_record.alias_domain and alias_record.alias_name: email = '%s@%s' % (alias_record.alias_name, alias_record.alias_domain) @@ -872,7 +872,9 @@ class Lead(models.Model): dynamic_help = _("""All email incoming to %s will automatically create new opportunity. Update your business card, phone book, social media,... Send an email right now and see it here.""") % (email_link,) - return '

%s

%s

%s

' % (_('Click to add a new opportunity'), help, dynamic_help) + return '

%s

%s

%s
%s

%s' % ( + return '

%s
%s

%s' % ( _('Click to add a new expense,'), _('or send receipts by email to %s.') % (link,), help_message) diff --git a/addons/im_livechat/models/mail_channel.py b/addons/im_livechat/models/mail_channel.py index 3f6c47ba5ce..2f72f3f5d49 100644 --- a/addons/im_livechat/models/mail_channel.py +++ b/addons/im_livechat/models/mail_channel.py @@ -105,7 +105,7 @@ class MailChannel(models.Model): @api.model def get_empty_list_help(self, help): if help: - return '%s

' % (help) + return '

%s

' % (help) return super(MailChannel, self).get_empty_list_help(help) def _define_command_history(self): diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 0cd8a937167..bc05ff70212 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -341,7 +341,9 @@ class MailThread(models.AbstractModel): 'email_link': email_link } } - return "%(static_help)s

%(dyn_help)s" % { + # do not add alias two times if it was added previously + if not help or help.find("oe_view_nocontent_alias") == -1: + return '%(static_help)s

%(dyn_help)s

' % { 'static_help': help or '', 'dyn_help': _("You could also add a new %(document)s by sending an email to: %(email_link)s.") % { 'document': document_name, diff --git a/addons/website_crm_partner_assign/models/crm_lead.py b/addons/website_crm_partner_assign/models/crm_lead.py index f5d59edbd8c..e47e35722f6 100644 --- a/addons/website_crm_partner_assign/models/crm_lead.py +++ b/addons/website_crm_partner_assign/models/crm_lead.py @@ -86,19 +86,10 @@ class CrmLead(models.Model): if lead.partner_latitude and lead.partner_longitude: continue if lead.country_id: - result = geo_find(geo_query_address(street=lead.street, - zip=lead.zip, - city=lead.city, - state=lead.state_id.name, - country=lead.country_id.name)) - - if result is None: - result = geo_find(geo_query_address( - city=lead.city, - state=lead.state_id.name, - country=lead.country_id.name - )) - + apikey = self.env['ir.config_parameter'].sudo().get_param('google.api_key_geocode') + result = self.env['res.partner']._geo_localize(apikey, + lead.street, lead.zip, lead.city, + lead.state_id.name, lead.country_id.name) if result: lead.write({ 'partner_latitude': result[0], diff --git a/addons/website_crm_partner_assign/tests/test_partner_assign.py b/addons/website_crm_partner_assign/tests/test_partner_assign.py index 6bf5e00af76..b3249fd3d7c 100644 --- a/addons/website_crm_partner_assign/tests/test_partner_assign.py +++ b/addons/website_crm_partner_assign/tests/test_partner_assign.py @@ -11,7 +11,7 @@ class TestPartnerAssign(TransactionCase): def setUp(self): super(TestPartnerAssign, self).setUp() - def geo_find(addr): + def geo_find(addr, apikey): return { 'Wavre, Belgium': (50.7158956, 4.6128075), 'Cannon Hill Park, B46 3AG Birmingham, United Kingdom': (52.45216, -1.898578),