1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.tests.common import tagged
from odoo.tools import mute_logger
from .common import TestPosQrCommon
@tagged('post_install_l10n', 'post_install', '-at_install')
class TestUiSEPA(TestPosQrCommon):
@classmethod
@TestPosQrCommon.setup_country('be')
def setUpClass(cls):
super().setUpClass()
# Set Bank Account on journal
cls.bank_account = cls.env['res.partner.bank'].create({
'acc_number': 'BE15001559627230',
'partner_id': cls.company_data['company'].partner_id.id,
})
cls.company_data['default_journal_bank'].write({'bank_account_id': cls.bank_account.id})
# Setup QR Payment method for SEPA
qr_payment = cls.env['pos.payment.method'].create({
'name': 'QR Code',
'journal_id': cls.company_data['default_journal_bank'].id,
'payment_method_type': "qr_code",
'qr_code_method': "sct_qr"
})
cls.main_pos_config.write({
'payment_method_ids': [(4, qr_payment.id)]
})
@mute_logger('odoo.http')
def test_01_pos_order_with_sepa_qr_payment_fail(self):
""" Test Point of Sale QR Payment flow with SEPA.
In this test the QR payment method is missing the required fields and will display an error message.
"""
# Set non sepa bank account to make the test failed
self.bank_account.write({
'acc_number': 'SA4420000001234567891234',
})
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenWithQRPaymentFailure', login="pos_user")
def test_02_pos_order_with_sepa_qr_payment(self):
""" Test Point of Sale QR Payment flow with SEPA
"""
# Set info that were wrong in test_01
self.bank_account.write({
'acc_number': 'BE15001559627230',
})
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenWithQRPayment', login="pos_user")
@tagged('post_install_l10n', 'post_install', '-at_install')
class TestUiCH(TestPosQrCommon):
@classmethod
@TestPosQrCommon.setup_country('ch')
def setUpClass(cls):
super().setUpClass()
# Set required fields for Swiss QR bank account partner
cls.company_data['company'].partner_id.write({
'street': "Crab street, 11",
'city': "Crab City",
'zip': "4242",
})
# Set Bank Account on journal
cls.bank_account = cls.env['res.partner.bank'].create({
'acc_number': 'CH15 3881 5158 3845 3843 7',
'partner_id': cls.company_data['company'].partner_id.id,
})
cls.company_data['default_journal_bank'].write({'bank_account_id': cls.bank_account.id})
# Setup QR Payment method for Swiss QR
qr_payment = cls.env['pos.payment.method'].create({
'name': 'QR Code',
'journal_id': cls.company_data['default_journal_bank'].id,
'payment_method_type': "qr_code",
'qr_code_method': "ch_qr"
})
cls.main_pos_config.write({
'payment_method_ids': [(4, qr_payment.id)]
})
cls.env['res.partner'].create({
'name': 'AAA Partner Swiss',
'country_id': cls.env.ref('base.ch').id,
'street': "Crab street, 11",
'city': "Crab City",
'zip': "4242",
})
@mute_logger('odoo.http')
def test_01_pos_order_with_swiss_qr_payment_fail(self):
""" Test Point of Sale QR Payment flow with Swiss QR.
In this test the QR payment will fail as we are not selecting a swiss customer
"""
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenWithQRPaymentFailure', login="pos_user")
def test_02_pos_order_with_swiss_qr_payment(self):
""" Test Point of Sale QR Payment flow with Swiss QR
We have to select a customer based in Switzerland or Lichtestein to use this payment method
"""
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenWithQRPaymentSwiss', login="pos_user")
@tagged('post_install_l10n', 'post_install', '-at_install')
class TestUiHK(TestPosQrCommon):
@classmethod
def setup_armageddon_tax(cls, tax_name, company_data):
# Hong Kong doesn't have any tax, so this methods will throw errors if we don't return None
return None
@classmethod
@TestPosQrCommon.setup_country('hk')
def setUpClass(cls):
super().setUpClass()
cls.company_data['company'].partner_id.update({
'city': 'HK',
})
# Set Bank Account on journal
cls.bank_account = cls.env['res.partner.bank'].create({
'acc_number': '123-123456-123',
'partner_id': cls.company_data['company'].partner_id.id,
})
cls.company_data['default_journal_bank'].write({'bank_account_id': cls.bank_account.id})
# Setup QR Payment method for EMV(FPS)
qr_payment = cls.env['pos.payment.method'].create({
'name': 'QR Code',
'journal_id': cls.company_data['default_journal_bank'].id,
'payment_method_type': "qr_code",
'qr_code_method': "emv_qr"
})
cls.main_pos_config.write({
'payment_method_ids': [(4, qr_payment.id)]
})
@mute_logger('odoo.http')
def test_01_pos_order_with_fps_qr_payment_fail(self):
""" Test Point of Sale QR Payment flow with FPS.
In this test the QR payment method is missing the required fields and will display an error message.
"""
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenWithQRPaymentFailure', login="pos_user")
def test_02_pos_order_with_emv_qr_payment(self):
""" Test Point of Sale QR Payment flow with FPS.
"""
# Set missing info that were missing in test_01
self.bank_account.write({
'proxy_type': 'mobile',
'proxy_value': '+852-67891234',
'include_reference': True,
})
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenWithQRPayment', login="pos_user")
@tagged('post_install_l10n', 'post_install', '-at_install')
class TestUIBR(TestPosQrCommon):
@classmethod
@TestPosQrCommon.setup_country('br')
def setUpClass(cls):
super().setUpClass()
cls.company_data['company'].partner_id.update({
'country_id': cls.env.ref('base.br').id,
'city': 'BR',
})
# Set Bank Account on journal
cls.bank_account = cls.env["res.partner.bank"].create({
"acc_number": "123456789012345678",
"partner_id": cls.company_data["company"].partner_id.id,
})
cls.company_data['default_journal_bank'].write({'bank_account_id': cls.bank_account.id})
# Setup QR Payment method for PIX
qr_payment = cls.env['pos.payment.method'].create({
'name': 'QR Code',
'journal_id': cls.company_data['default_journal_bank'].id,
'payment_method_type': "qr_code",
'qr_code_method': "emv_qr"
})
cls.main_pos_config.write({
'payment_method_ids': [(4, qr_payment.id)]
})
@mute_logger('odoo.http')
def test_01_pos_order_with_pix_qr_payment_fail(self):
""" Test Point of Sale QR Payment flow with PIX.
In this test the QR payment method is missing the required fields and will display an error message.
"""
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenWithQRPaymentFailure', login="pos_user")
def test_02_pos_order_with_pix_qr_payment(self):
""" Test Point of Sale QR Payment flow with PIX
"""
# Set missing info that were missing in test_01
self.bank_account.write({
"proxy_type": "br_random",
"proxy_value": "71d6c6e1-64ea-4a11-9560-a10870c40ca2",
"include_reference": True,
})
self.main_pos_config.with_user(self.pos_user).open_ui()
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenWithQRPayment', login="pos_user")
|