From a5b3246dcd3949ad9b38a8dd3d113da2cda1119d Mon Sep 17 00:00:00 2001 From: "Antoine Prieels (ANP)" Date: Thu, 11 Oct 2018 14:15:53 +0000 Subject: [PATCH] [FIX] Convert the estimated price for snailmail server-side Currency rates were not updated client-side so we moved to make the convertion happen server-side, where rates are updated daily closes odoo/odoo#27688 --- addons/snailmail/models/snailmail_letter.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/snailmail/models/snailmail_letter.py b/addons/snailmail/models/snailmail_letter.py index 24fb3bd91d0..7024edfec34 100644 --- a/addons/snailmail/models/snailmail_letter.py +++ b/addons/snailmail/models/snailmail_letter.py @@ -123,6 +123,7 @@ class SnailmailLetter(models.Model): options: { color: boolean (true if color, false if black-white), duplex: boolean (true if duplex, false otherwise), + currency_name: char } } """ @@ -191,6 +192,7 @@ class SnailmailLetter(models.Model): 'options': { 'color': self and self[0].color, 'duplex': self and self[0].duplex, + 'currency_name': self and self[0].company_id.currency_id.name, }, # this will not raise the InsufficientCreditError which is the behaviour we want for now 'batch': True, @@ -310,11 +312,8 @@ class SnailmailLetter(models.Model): endpoint = self.env['ir.config_parameter'].sudo().get_param('snailmail.endpoint', DEFAULT_ENDPOINT) params = self._snailmail_create('estimate') req = jsonrpc(endpoint + '/iap/snailmail/1/estimate', params=params) - # The cost is sent in hunderth of eurocents, we change it to euros and then convert it to the company currency - cost = int(req['total_cost'])/10000.0 - currency_eur = self.env.ref('base.EUR') - return currency_eur._convert(cost, self[0].company_id.currency_id, self[0].company_id, fields.Datetime.now()) + return req['total_cost'] @api.model def _snailmail_cron(self):