-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[18.0][FIX] auditlog: drop tocompute register entirely from ThrowAwayCache #3469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| from . import test_account_bank_statement_line | ||
| from . import test_account_move_reverse | ||
| from . import test_product_tax_multicompany |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| from odoo.tests import tagged | ||
|
|
||
| from odoo.addons.account.tests.common import AccountTestInvoicingCommon | ||
| from odoo.addons.auditlog.tests.common import AuditLogRuleCommon | ||
|
|
||
|
|
||
| @tagged("post_install", "-at_install") | ||
| class TestAccountBankStatementLine(AccountTestInvoicingCommon, AuditLogRuleCommon): | ||
| def setUp(self): | ||
| super().setUp() | ||
| self.rule = self.env["auditlog.rule"].create( | ||
| { | ||
| "name": __name__, | ||
| "model_id": self.env.ref("account.model_account_move").id, | ||
| "log_read": True, | ||
| "log_create": True, | ||
| "log_write": True, | ||
| "log_unlink": True, | ||
| "log_type": "full", | ||
| } | ||
| ) | ||
| self.rule.subscribe() | ||
|
|
||
| def test_create_statement_line(self): | ||
| """Statement line can be created with logging on journal entries enabled. | ||
|
|
||
| Because we swap out the cache when fetching previous values during full | ||
| logging using the ThrowAwayCache, some values that are assumed by | ||
| compute methods (c.q. 'date' in account.bank.statement.line's | ||
| _compute_internal_index) might be missing. If a recompute of those fields | ||
| is inadvertently triggered when using the ThrowAwayCache, the missing | ||
| values will raise an exception (in this case: `AttributeError: 'bool' | ||
| object has no attribute 'strftime'`). This test verifies that the queued | ||
| recomputes are consistent with the values in the cache such that this | ||
| exception does not occur. | ||
| """ | ||
| partner = self.env["res.partner"].create({"name": "test"}) | ||
| stmt = self.env["account.bank.statement"].create( | ||
| {"journal_id": self.company_data["default_journal_bank"].id} | ||
| ) | ||
| line = self.env["account.bank.statement.line"].create( | ||
| { | ||
| "date": "2023-04-01", | ||
| "account_number": "NL45 TRIO 0198100000", | ||
| "amount": 5.75, | ||
| "journal_id": self.company_data["default_journal_bank"].id, | ||
| "payment_ref": "1234", | ||
| "partner_id": partner.id, | ||
| "statement_id": stmt.id, | ||
| }, | ||
| ) | ||
| line.flush_recordset() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we add an assert?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so. Without the fix, this test (with the flush) reproduces the issue. There is no specific value to assert.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know that it tests the code that no error is raised, however, it would be nice to add an assert to know what we are expecting (a created auditlog for example)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be misleading, because that is not the goal of the test. Checking that auditlogs are created is covered by lots of other tests already.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case, the test must include the reason of it's existance. Without checking the PR it is not clear why we need this test.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good point, thanks! I now added documentation of the issue and the exception it causes to the test method docstring. |
||
Uh oh!
There was an error while loading. Please reload this page.