mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-24 01:22:01 +02:00
19.0 vanilla
This commit is contained in:
parent
ba20ce7443
commit
768b70e05e
2357 changed files with 1057103 additions and 712486 deletions
|
|
@ -0,0 +1,60 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import Command
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tests import tagged
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestAccountReport(AccountTestInvoicingCommon):
|
||||
|
||||
def test_copy_report(self):
|
||||
""" Ensure that copying a report correctly adjust codes, formulas and subformulas. """
|
||||
report = self.env['account.report'].create({
|
||||
'name': "Report To Copy",
|
||||
'column_ids': [Command.create({'name': 'balance', 'sequence': 1, 'expression_label': 'balance'})],
|
||||
'line_ids': [
|
||||
Command.create({
|
||||
'name': "test_line_1",
|
||||
'code': "test_line_1",
|
||||
'sequence': 1,
|
||||
'expression_ids': [
|
||||
Command.create({
|
||||
'date_scope': 'strict_range',
|
||||
'engine': 'external',
|
||||
'formula': 'sum',
|
||||
'label': 'balance',
|
||||
}),
|
||||
]
|
||||
}),
|
||||
Command.create({
|
||||
'name': "test_line_2",
|
||||
'code': "test_line_2",
|
||||
'sequence': 2,
|
||||
'expression_ids': [
|
||||
Command.create({
|
||||
'date_scope': 'strict_range',
|
||||
'engine': 'aggregation',
|
||||
'formula': 'test_line_1.balance',
|
||||
'subformula': 'if_other_expr_above(test_line_1.balance, USD(0))',
|
||||
'label': 'balance',
|
||||
})
|
||||
],
|
||||
})
|
||||
]
|
||||
})
|
||||
copy = report.copy()
|
||||
# Ensure that the two line codes are updated.
|
||||
self.assertEqual(copy.line_ids[0].code, 'test_line_1_COPY')
|
||||
self.assertEqual(copy.line_ids[1].code, 'test_line_2_COPY')
|
||||
# Ensure that the line 2 expression formula and subformula point to the correct code.
|
||||
expression = copy.line_ids[1].expression_ids
|
||||
self.assertEqual(expression.formula, 'test_line_1_COPY.balance')
|
||||
self.assertEqual(expression.subformula, 'if_other_expr_above(test_line_1_COPY.balance, USD(0))')
|
||||
|
||||
with self.assertRaisesRegex(ValidationError, "Invalid formula for expression 'balance' of line 'test_line_2'"):
|
||||
expression.write({
|
||||
'engine': 'account_codes',
|
||||
'formula': 'test(12)',
|
||||
},
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue