From 3579bd53bed09a6bd06ac32d8bce780937993501 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 30 Apr 2018 11:30:37 +0200 Subject: [PATCH 1/3] [FIX] hr_expense: account on expense - Set a specific expense account on an expense product - Send an email to the expense alias The specific expense account is not used; a default account is used instead. opw-1838174 --- addons/hr_expense/models/hr_expense.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 53c64c4a5ac..703429b286f 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -350,6 +350,7 @@ class HrExpense(models.Model): expense_description = expense_description.replace(product_code.group(), '') products = self.env['product.product'].search([('default_code', 'ilike', product_code.group(1))]) or default_product product = products.filtered(lambda p: p.default_code == product_code.group(1)) or products[0] + account = product.product_tmpl_id._get_product_accounts()['expense'] pattern = '[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?' # Match the last occurence of a float in the string @@ -376,6 +377,8 @@ class HrExpense(models.Model): 'unit_amount': price, 'company_id': employee.company_id.id, }) + if account: + custom_values['account_id'] = account.id return super(HrExpense, self).message_new(msg_dict, custom_values) class HrExpenseSheet(models.Model): From e48767fe6509c9dc5bb3c0907ad36d16c4b5b773 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 14 May 2018 16:33:55 +0200 Subject: [PATCH 2/3] [FIX] mass_mailing: force to not use a template for the rendering If the user configures a default `template_id` for the `mail.compose.message`, this template was used by the mass mailing to render the email, and, among others, it therefore used the `email_to` of this email template, to render the recipients, and it was configured empty or something else than `object.id`, it did not used the `active_ids` passed in the context to the `mail.compose.message` `create` call to compute the correct recipients To reproduce: - In developer mode (?debug) - Open the full mail compose message e.g. in app sales, open a so, hit new message, and hit the button to open the full message composer - Set the template to the quotation template is not there already - In the debug menu of the dialog, View > Set defaults, - Click the radio button to all users, and the default to Use template = ... - Then, try to send a mass mailing. It will fail because it cannot compute the `email_to` values correctly because the `email_to` of the quotation template is empty. opw-1840287 --- addons/mass_mailing/models/mass_mailing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py index 154acd47bd8..340d4c8ccb8 100644 --- a/addons/mass_mailing/models/mass_mailing.py +++ b/addons/mass_mailing/models/mass_mailing.py @@ -785,6 +785,7 @@ class MassMailing(osv.Model): 'mass_mailing_id': mailing.id, 'mailing_list_ids': [(4, l.id) for l in mailing.contact_list_ids], 'no_auto_thread': mailing.reply_to_mode != 'thread', + 'template_id': None, } if mailing.reply_to_mode == 'email': composer_values['reply_to'] = mailing.reply_to From 045086839184d89e6aa11b4938d5f685ce607513 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 14 May 2018 19:54:50 +0200 Subject: [PATCH 3/3] [FIX] website: correct GeoIP Legacy compatibility Attribute is different for country and continent objects. --- addons/website/geoipresolver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website/geoipresolver.py b/addons/website/geoipresolver.py index e95b9318eb2..24bbe723d6d 100644 --- a/addons/website/geoipresolver.py +++ b/addons/website/geoipresolver.py @@ -50,10 +50,10 @@ class GeoIPResolver(object): # Compatibility with Legacy database. # Some ips cannot be located to a specific country. Legacy DB used to locate them in # continent instead of country. Do the same to not change behavior of existing code. - country = r.country if r.country.geoname_id else r.continent + country, attr = (r.country, 'iso_code') if r.country.geoname_id else (r.continent, 'code') return { 'city': r.city.name, - 'country_code': country.iso_code, + 'country_code': getattr(country, attr), 'country_name': country.name, 'region': r.subdivisions[0].iso_code if r.subdivisions else None, 'time_zone': r.location.time_zone,