diff --git a/account_cutoff_base/README.rst b/account_cutoff_base/README.rst index d546be7bca7..f6a13449cea 100644 --- a/account_cutoff_base/README.rst +++ b/account_cutoff_base/README.rst @@ -86,6 +86,9 @@ Contributors * Pedro M. Baeza * Jeroen Evens * Jim Hoefnagels +* `Aion Tech `_: + + * Simone Rubino Maintainers ~~~~~~~~~~~ diff --git a/account_cutoff_base/readme/CONTRIBUTORS.rst b/account_cutoff_base/readme/CONTRIBUTORS.rst index 5cea2d58849..69b46bd6309 100644 --- a/account_cutoff_base/readme/CONTRIBUTORS.rst +++ b/account_cutoff_base/readme/CONTRIBUTORS.rst @@ -5,3 +5,6 @@ * Pedro M. Baeza * Jeroen Evens * Jim Hoefnagels +* `Aion Tech `_: + + * Simone Rubino diff --git a/account_cutoff_base/static/description/index.html b/account_cutoff_base/static/description/index.html index 91f889ccea0..999d74cb6d5 100644 --- a/account_cutoff_base/static/description/index.html +++ b/account_cutoff_base/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -432,12 +432,18 @@

Contributors

  • Pedro M. Baeza <pedro.baeza@gmail.com>
  • Jeroen Evens <jeroen.evenss@dynapps.be>
  • Jim Hoefnagels <jim.hoefnagels@dynapps.be>
  • +
  • Aion Tech: +
  • Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +Odoo Community Association +

    OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

    diff --git a/account_cutoff_start_end_dates/models/account_cutoff.py b/account_cutoff_start_end_dates/models/account_cutoff.py index 3caefeffd3a..8fed0c2e41a 100644 --- a/account_cutoff_start_end_dates/models/account_cutoff.py +++ b/account_cutoff_start_end_dates/models/account_cutoff.py @@ -189,6 +189,15 @@ def get_lines(self): else: domain.append(("parent_state", "in", ("draft", "posted"))) + if self.cutoff_type in ["prepaid_expense", "accrued_expense"]: + domain += [ + ("account_internal_group", "=", "expense"), + ] + elif self.cutoff_type in ["prepaid_revenue", "accrued_revenue"]: + domain += [ + ("account_internal_group", "=", "income"), + ] + if self.cutoff_type in ["prepaid_expense", "prepaid_revenue"]: if self.forecast: domain += [ diff --git a/account_cutoff_start_end_dates/tests/test_account_cutoff_prepaid.py b/account_cutoff_start_end_dates/tests/test_account_cutoff_prepaid.py index a66f05bc5a4..9c21b3a5237 100644 --- a/account_cutoff_start_end_dates/tests/test_account_cutoff_prepaid.py +++ b/account_cutoff_start_end_dates/tests/test_account_cutoff_prepaid.py @@ -5,9 +5,10 @@ import time +from datetime import date from odoo import fields -from odoo.tests.common import SavepointCase +from odoo.tests.common import Form, SavepointCase class TestCutoffPrepaid(SavepointCase): @@ -104,12 +105,12 @@ def _create_invoice(self, date, amount, start_date, end_date): self.assertEqual(amount, invoice.amount_untaxed) return invoice - def _create_cutoff(self, date): + def _create_cutoff(self, date, cutoff_type="prepaid_expense"): cutoff = self.cutoff_model.create( { "company_id": self.env.ref("base.main_company").id, "cutoff_date": self._date(date), - "cutoff_type": "prepaid_revenue", + "cutoff_type": cutoff_type, "cutoff_journal_id": self.cutoff_journal.id, "cutoff_account_id": self.account_cutoff.id, "source_journal_ids": [(6, 0, [self.purchase_journal.id])], @@ -151,3 +152,65 @@ def tests_1(self): # two invoices, but two lines (because the two cutoff lines # have been grouped into one line plus one counterpart) self.assertEqual(len(cutoff.move_id.line_ids), 2) + + def test_general_entry_prepaid_expense_cutoff_account(self): + """ + Create an account move on a general journal for an expense account, + only the expense cutoff should retrieve its line.""" + # Arrange + bank_account = self.env["account.account"].search( + [("internal_type", "=", "liquidity")], limit=1 + ) + expense_account = self.account_expense + misc_journal = self.cutoff_journal + month_day_move_date = "10-31" + move_date = fields.Date.from_string(self._date(month_day_move_date)) + + move_form = Form(self.env["account.move"]) + move_form.date = move_date + move_form.journal_id = misc_journal + with move_form.line_ids.new() as line: + line.account_id = expense_account + line.debit = 1000 + line.start_date = date(move_date.year + 1, 1, 1) + line.end_date = date(move_date.year + 1, 12, 31) + with move_form.line_ids.new() as line: + line.account_id = bank_account + line.credit = 1000 + move = move_form.save() + move.action_post() + + prepaid_expense_cutoff = self._create_cutoff( + month_day_move_date, + cutoff_type="prepaid_expense", + ) + prepaid_expense_cutoff.source_journal_ids = misc_journal + + prepaid_revenue_cutoff = self._create_cutoff( + month_day_move_date, + cutoff_type="prepaid_revenue", + ) + prepaid_revenue_cutoff.source_journal_ids = misc_journal + + # pre-condition + expense_move_line = move.line_ids.filtered( + lambda line: line.account_id.internal_group == "expense" + ) + self.assertTrue(expense_move_line) + self.assertEqual(move.journal_id.type, "general") + + self.assertEqual(prepaid_expense_cutoff.cutoff_type, "prepaid_expense") + self.assertEqual(prepaid_expense_cutoff.source_journal_ids.type, "general") + + self.assertEqual(prepaid_revenue_cutoff.cutoff_type, "prepaid_revenue") + self.assertEqual(prepaid_revenue_cutoff.source_journal_ids.type, "general") + + # Act + prepaid_expense_cutoff.get_lines() + prepaid_revenue_cutoff.get_lines() + + # Assert + self.assertEqual( + prepaid_expense_cutoff.line_ids.origin_move_line_id, expense_move_line + ) + self.assertFalse(prepaid_revenue_cutoff.line_ids)