Skip to content
Snippets Groups Projects
Commit d930a78f authored by Julien Castiaux's avatar Julien Castiaux
Browse files

[FIX] snailmail_account: external pingen test


Commit 4d64e553 introduced an 'mt-3' in the address layout of the
external background layout to fix a problem related to the display of
phone numbers.

That fix introduced an error with the pingen external post service. It
requires the area where the destination address is printed to be blank,
due to the mt-3, the background image was visible instead of that blank
area.

As removing solely the mt-3 doesn't break the first problem and solve
the second, it is safe to remove it.

Before this commit, no message was logged to help finding out why the
test was failing.

The `requests.raise_for_status` method raises an error on both 400 and
500 status code. We don't want the test to break in case pingen screw
up their side so 500 errors are just logged. 400 errors still raise an
exception.

closes odoo/odoo#36504

Signed-off-by: default avatarChristophe Monniez (moc) <moc@odoo.com>
parent 1d15892e
No related branches found
No related tags found
No related merge requests found
......@@ -2,10 +2,13 @@
import requests
import json
import base64
import logging
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
from odoo.tests import tagged
_logger = logging.getLogger(__name__)
@tagged('post_install', '-at_install', '-standard', 'external')
class TestPingenSend(AccountingTestCase):
......@@ -59,16 +62,20 @@ class TestPingenSend(AccountingTestCase):
}
response = requests.post(self.pingen_url, data=self.data, files=files)
try:
response.raise_for_status()
except:
return False
return True
if 400 <= response.status_code <= 599:
msg = "%(code)s %(side)s Error: %(reason)s for url: %(url)s\n%(body)s" % {
'code': response.status_code,
'side': r"%s",
'reason': response.reason,
'url': self.pingen_url,
'body': response.text}
if response.status_code <= 499:
raise requests.HTTPError(msg % "Client")
else:
_logger.warning(msg % "Server")
def test_pingen_send_invoice(self):
self.assertTrue(self.render_and_send('external_layout_standard'))
self.assertTrue(self.render_and_send('external_layout_background'))
self.assertTrue(self.render_and_send('external_layout_boxed'))
self.assertTrue(self.render_and_send('external_layout_clean'))
self.render_and_send('external_layout_standard')
self.render_and_send('external_layout_background')
self.render_and_send('external_layout_boxed')
self.render_and_send('external_layout_clean')
......@@ -125,7 +125,7 @@
<!-- External layouts styles -->
<template id="address_layout">
<t t-set="colclass" t-value="('col-md-5' if report_type == 'html' else 'col-5') + ' ml-auto mt-3'"/>
<t t-set="colclass" t-value="('col-md-5' if report_type == 'html' else 'col-5') + ' ml-auto'"/>
<t t-if="address">
<div class="address row">
<t t-if="information_block">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment