| 1 |
from odoo import Command |
| 2 |
from odoo.addons.account.tests.test_taxes_downpayment import TestTaxesDownPayment |
| 3 |
from odoo.addons.point_of_sale.tests.test_frontend import TestTaxCommonPOS |
| 4 |
from odoo.addons.sale.tests.common import TestTaxCommonSale |
| 5 |
from odoo.tests import tagged |
| 6 |
|
| 7 |
|
| 8 |
@tagged('post_install', '-at_install') |
| 9 |
class TestTaxesDownPaymentPOS(TestTaxCommonPOS, TestTaxCommonSale, TestTaxesDownPayment): |
| 10 |
|
| 11 |
@classmethod |
| 12 |
def setUpClass(cls): |
| 13 |
super().setUpClass() |
| 14 |
cls.main_pos_config.down_payment_product_id = cls.env['product.product'].create({ |
| 15 |
'name': 'downpayment', |
| 16 |
'available_in_pos': True, |
| 17 |
'pos_categ_ids': [Command.set(cls.pos_desk_misc_test.ids)], |
| 18 |
}) |
| 19 |
cls.main_pos_config.pricelist_id = None |
| 20 |
cls.main_pos_config.available_pricelist_ids = [Command.clear()] |
| 21 |
|
| 22 |
def assert_pos_orders_and_invoices(self, tour, tests_with_orders): |
| 23 |
all_so = self.env['sale.order'] |
| 24 |
for _test_code, document, _soft_checking, _amount_type, _amount, _expected_values in tests_with_orders: |
| 25 |
so = self.convert_document_to_sale_order(document) |
| 26 |
so.currency_id = self.env.company.currency_id |
| 27 |
so.action_confirm() |
| 28 |
all_so += so |
| 29 |
super().assert_pos_orders_and_invoices(tour, tests_with_orders) |
| 30 |
all_so.action_cancel() |
| 31 |
|
| 32 |
def test_taxes_l10n_in_pos(self): |
| 33 |
tests = self._test_taxes_l10n_in() |
| 34 |
round_per_line_excluded_tests = [next(tests) for _i in range(22)] |
| 35 |
self.ensure_products_on_document(round_per_line_excluded_tests[0][1], 'product_1') |
| 36 |
self.assert_pos_orders_and_invoices('test_taxes_l10n_in_pos_downpayment_round_per_line_price_excluded', [ |
| 37 |
round_per_line_excluded_tests[19], |
| 38 |
round_per_line_excluded_tests[18], |
| 39 |
round_per_line_excluded_tests[7], |
| 40 |
round_per_line_excluded_tests[6], |
| 41 |
round_per_line_excluded_tests[1], |
| 42 |
round_per_line_excluded_tests[0], |
| 43 |
]) |
| 44 |
|
| 45 |
round_globally_excluded_tests = [next(tests) for _i in range(22)] |
| 46 |
self.ensure_products_on_document(round_globally_excluded_tests[0][1], 'product_2') |
| 47 |
self.assert_pos_orders_and_invoices('test_taxes_l10n_in_pos_downpayment_round_globally_price_excluded', [ |
| 48 |
round_globally_excluded_tests[19], |
| 49 |
round_globally_excluded_tests[18], |
| 50 |
round_globally_excluded_tests[7], |
| 51 |
round_globally_excluded_tests[6], |
| 52 |
round_globally_excluded_tests[1], |
| 53 |
round_globally_excluded_tests[0], |
| 54 |
]) |
| 55 |
|
| 56 |
round_per_line_included_tests = [next(tests) for _i in range(22)] |
| 57 |
self.ensure_products_on_document(round_per_line_included_tests[0][1], 'product_3') |
| 58 |
self.assert_pos_orders_and_invoices('test_taxes_l10n_in_pos_downpayment_round_per_line_price_included', [ |
| 59 |
round_per_line_included_tests[19], |
| 60 |
round_per_line_included_tests[18], |
| 61 |
round_per_line_included_tests[7], |
| 62 |
round_per_line_included_tests[6], |
| 63 |
round_per_line_included_tests[1], |
| 64 |
round_per_line_included_tests[0], |
| 65 |
]) |
| 66 |
|
| 67 |
round_globally_included_tests = [next(tests) for _i in range(22)] |
| 68 |
self.ensure_products_on_document(round_globally_included_tests[0][1], 'product_4') |
| 69 |
self.assert_pos_orders_and_invoices('test_taxes_l10n_in_pos_downpayment_round_globally_price_included', [ |
| 70 |
round_globally_included_tests[19], |
| 71 |
round_globally_included_tests[18], |
| 72 |
round_globally_included_tests[7], |
| 73 |
round_globally_included_tests[6], |
| 74 |
round_globally_included_tests[1], |
| 75 |
round_globally_included_tests[0], |
| 76 |
]) |
| 77 |
|
| 78 |
def test_taxes_l10n_br_pos(self): |
| 79 |
tests = self._test_taxes_l10n_br() |
| 80 |
round_per_line_excluded_tests = [next(tests) for _i in range(19)] |
| 81 |
self.ensure_products_on_document(round_per_line_excluded_tests[0][1], 'product_1') |
| 82 |
self.assert_pos_orders_and_invoices('test_taxes_l10n_br_pos_downpayment_round_per_line_price_excluded', [ |
| 83 |
round_per_line_excluded_tests[0], |
| 84 |
]) |
| 85 |
|
| 86 |
round_globally_excluded_tests = [next(tests) for _i in range(19)] |
| 87 |
self.ensure_products_on_document(round_globally_excluded_tests[0][1], 'product_2') |
| 88 |
self.assert_pos_orders_and_invoices('test_taxes_l10n_br_pos_downpayment_round_globally_price_excluded', [ |
| 89 |
round_globally_excluded_tests[0], |
| 90 |
]) |
| 91 |
|
| 92 |
round_per_line_included_tests = [next(tests) for _i in range(19)] |
| 93 |
self.ensure_products_on_document(round_per_line_included_tests[0][1], 'product_3') |
| 94 |
self.assert_pos_orders_and_invoices('test_taxes_l10n_br_pos_downpayment_round_per_line_price_included', [ |
| 95 |
round_per_line_included_tests[0], |
| 96 |
]) |
| 97 |
|
| 98 |
round_globally_included_tests = [next(tests) for _i in range(19)] |
| 99 |
self.ensure_products_on_document(round_globally_included_tests[0][1], 'product_4') |
| 100 |
self.assert_pos_orders_and_invoices('test_taxes_l10n_br_pos_downpayment_round_globally_price_included', [ |
| 101 |
round_globally_included_tests[0], |
| 102 |
]) |
| 103 |
|
| 104 |
def test_taxes_l10n_be_pos(self): |
| 105 |
tests = self._test_taxes_l10n_be() |
| 106 |
round_per_line_excluded_tests = [next(tests) for _i in range(19)] |
| 107 |
self.ensure_products_on_document(round_per_line_excluded_tests[0][1], 'product_1') |
| 108 |
self.assert_pos_orders_and_invoices('test_taxes_l10n_be_pos_downpayment_round_per_line_price_excluded', [ |
| 109 |
round_per_line_excluded_tests[0], |
| 110 |
]) |
| 111 |
|
| 112 |
round_globally_excluded_tests = [next(tests) for _i in range(19)] |
| 113 |
self.ensure_products_on_document(round_globally_excluded_tests[0][1], 'product_2') |
| 114 |
self.assert_pos_orders_and_invoices('test_taxes_l10n_be_pos_downpayment_round_globally_price_excluded', [ |
| 115 |
round_globally_excluded_tests[0], |
| 116 |
]) |
| 117 |
|
| 118 |
round_per_line_included_tests = [next(tests) for _i in range(19)] |
| 119 |
self.ensure_products_on_document(round_per_line_included_tests[0][1], 'product_3') |
| 120 |
self.assert_pos_orders_and_invoices('test_taxes_l10n_be_pos_downpayment_round_per_line_price_included', [ |
| 121 |
round_per_line_included_tests[0], |
| 122 |
]) |
| 123 |
|
| 124 |
round_globally_included_tests = [next(tests) for _i in range(19)] |
| 125 |
self.ensure_products_on_document(round_globally_included_tests[0][1], 'product_4') |
| 126 |
self.assert_pos_orders_and_invoices('test_taxes_l10n_be_pos_downpayment_round_globally_price_included', [ |
| 127 |
round_globally_included_tests[0], |
| 128 |
]) |