1
1
# Copyright (C) 2023 - TODAY Raphaël Valyi - Akretion
2
2
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3
3
4
- import logging
4
+ from contextlib import contextmanager
5
5
6
6
from odoo .tests .common import tagged
7
7
from odoo .tests .suite import OdooSuite
8
8
9
- _logger = logging .getLogger (__name__ )
9
+ from odoo .addons .account .tests import common
10
+
11
+ from .common import instantiate_accountman
10
12
11
13
12
14
# ruff: noqa: E501 - line too long
@@ -52,12 +54,12 @@ def setup_company_data(cls, company_name, chart_template=None, **kwargs):
52
54
53
55
@classmethod
54
56
def setUpClass (cls , chart_template_ref = None ):
55
- res = super (). setUpClass ( chart_template_ref )
56
- # FIXME the following line should not be required but as for
57
- # now if we don't add this group, creating a refund will result
58
- # in an attempt to create a l10n_br_fiscal.subsequent.document record.
59
- cls . env . user . groups_id |= cls . env . ref ( "l10n_br_fiscal.group_manager" )
60
- return res
57
+ def instantiate ( cls ):
58
+ instantiate_accountman ( cls )
59
+ cls . user . lang = "en_US"
60
+
61
+ common . instantiate_accountman = instantiate
62
+ return super (). setUpClass ( chart_template_ref )
61
63
62
64
# The following tests list is taken with
63
65
# cat addons/account/tests/test_account_move_out_invoice.py | grep "def test_"
@@ -84,28 +86,25 @@ def test_force_out_invoice_line_onchange_product_2_with_fiscal_pos_2(self):
84
86
# FIXME
85
87
# return super().test_out_invoice_line_onchange_business_fields_1()
86
88
87
- # def test_force_out_invoice_line_onchange_accounting_fields_1(self):
88
- # FIXME this test works with most of the l10n-brazil modules
89
- # but fails because of _order = "date desc, date_maturity ASC, id desc"
90
- # inside l10n_br_account_payment_order/models/account_move_line.py
91
- # return super().test_out_invoice_line_onchange_accounting_fields_1()
92
-
93
89
def test_force_out_invoice_line_onchange_partner_1 (self ):
94
90
return super ().test_out_invoice_line_onchange_partner_1 ()
95
91
96
- # FIXME
97
- # def test_force_out_invoice_line_onchange_taxes_1( self):
98
- # return super().test_out_invoice_line_onchange_taxes_1()
92
+ def test_force_out_invoice_line_onchange_taxes_1 ( self ):
93
+ with self . _with_invoice_form_force_show_tax_ids ( ):
94
+ return super ().test_out_invoice_line_onchange_taxes_1 ()
99
95
100
96
def test_force_out_invoice_line_onchange_rounding_price_subtotal_1 (self ):
101
97
return super ().test_out_invoice_line_onchange_rounding_price_subtotal_1 ()
102
98
103
- # FIXME
104
- # def test_force_out_invoice_line_onchange_rounding_price_subtotal_2(self):
105
- # return super().test_out_invoice_line_onchange_rounding_price_subtotal_2()
106
- # FIXME
107
- # def test_force_out_invoice_line_onchange_taxes_2_price_unit_tax_included(self):
108
- # return super().test_out_invoice_line_onchange_taxes_2_price_unit_tax_included()
99
+ def test_force_out_invoice_line_onchange_rounding_price_subtotal_2 (self ):
100
+ with self ._with_invoice_form_force_show_tax_ids ():
101
+ return super ().test_out_invoice_line_onchange_rounding_price_subtotal_2 ()
102
+
103
+ def test_force_out_invoice_line_onchange_taxes_2_price_unit_tax_included (self ):
104
+ with self ._with_invoice_form_force_show_tax_ids ():
105
+ return (
106
+ super ().test_out_invoice_line_onchange_taxes_2_price_unit_tax_included ()
107
+ )
109
108
110
109
def test_force_out_invoice_line_onchange_analytic (self ):
111
110
return super ().test_out_invoice_line_onchange_analytic ()
@@ -116,17 +115,14 @@ def test_force_out_invoice_line_onchange_analytic_2(self):
116
115
def test_force_out_invoice_line_onchange_cash_rounding_1 (self ):
117
116
return super ().test_out_invoice_line_onchange_cash_rounding_1 ()
118
117
119
- # def test_force_out_invoice_line_onchange_currency_1(self):
120
- # FIXME broken after https://github.com/OCA/l10n-brazil/issues/3617
121
- # return super().test_out_invoice_line_onchange_currency_1()
118
+ def test_force_out_invoice_line_onchange_currency_1 (self ):
119
+ return super ().test_out_invoice_line_onchange_currency_1 ()
122
120
123
- # def test_force_out_invoice_line_tax_fixed_price_include_free_product(self):
124
- # FIXME
125
- # return super().test_out_invoice_line_tax_fixed_price_include_free_product()
121
+ def test_force_out_invoice_line_tax_fixed_price_include_free_product (self ):
122
+ return super ().test_out_invoice_line_tax_fixed_price_include_free_product ()
126
123
127
- # def test_force_out_invoice_line_taxes_fixed_price_include_free_product(self):
128
- # FIXME
129
- # return super().test_out_invoice_line_taxes_fixed_price_include_free_product()
124
+ def test_force_out_invoice_line_taxes_fixed_price_include_free_product (self ):
125
+ return super ().test_out_invoice_line_taxes_fixed_price_include_free_product ()
130
126
131
127
def test_force_out_invoice_create_refund (self ):
132
128
return super ().test_out_invoice_create_refund ()
@@ -176,11 +172,13 @@ def test_force_out_invoice_filter_zero_balance_lines(self):
176
172
def test_force_out_invoice_recomputation_receivable_lines (self ):
177
173
return super ().test_out_invoice_recomputation_receivable_lines ()
178
174
179
- # def test_force_out_invoice_rounding_recomputation_receivable_lines(self):
180
- # return super().test_out_invoice_rounding_recomputation_receivable_lines()
175
+ def test_force_out_invoice_rounding_recomputation_receivable_lines (self ):
176
+ with self ._with_invoice_form_force_show_tax_ids ():
177
+ return super ().test_out_invoice_rounding_recomputation_receivable_lines ()
181
178
182
- # def test_force_out_invoice_multi_company(self):
183
- # return super().test_out_invoice_multi_company()
179
+ def test_force_out_invoice_multi_company (self ):
180
+ with self ._with_invoice_form_force_show_tax_ids ():
181
+ return super ().test_out_invoice_multi_company ()
184
182
185
183
def test_force_out_invoice_multiple_switch_payment_terms (self ):
186
184
return super ().test_out_invoice_multiple_switch_payment_terms ()
@@ -191,11 +189,20 @@ def test_force_out_invoice_copy_custom_date(self):
191
189
def test_force_out_invoice_note_and_tax_partner_is_set (self ):
192
190
return super ().test_out_invoice_note_and_tax_partner_is_set ()
193
191
194
- # def test_force_out_invoice_reverse_caba(self):
195
- # return super().test_out_invoice_reverse_caba()
196
-
197
- # def test_force_out_invoice_duplicate_currency_rate(self):
198
- # return super().test_out_invoice_duplicate_currency_rate()
192
+ def test_force_out_invoice_reverse_caba (self ):
193
+ with self ._with_invoice_form_force_show_tax_ids ():
194
+ return super ().test_out_invoice_reverse_caba ()
199
195
200
196
def test_force_out_invoice_depreciated_account (self ):
201
197
return super ().test_out_invoice_depreciated_account ()
198
+
199
+ @contextmanager
200
+ def _with_invoice_form_force_show_tax_ids (self ):
201
+ env_orig = self .env
202
+ self .env = self .env (
203
+ context = dict (env_orig .context , force_show_invoice_tax_ids = True )
204
+ )
205
+ self .invoice = self .invoice .with_env (self .env )
206
+ yield
207
+ self .env = env_orig
208
+ self .invoice = self .invoice .with_env (self .env )
0 commit comments