Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: OCA/account-closing
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 489cb36633cdbba3a5fc1832ab3096b37e5e068a
Choose a base ref
..
head repository: OCA/account-closing
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0f30e6b9d7488d090dbb838a4845683a4c834d53
Choose a head ref
Showing with 117 additions and 2 deletions.
  1. +8 −2 account_cutoff_base/models/account_cutoff.py
  2. +108 −0 account_cutoff_base/tests/test_account_cutoff.py
  3. +1 −0 account_cutoff_base/views/account_cutoff.xml
10 changes: 8 additions & 2 deletions account_cutoff_base/models/account_cutoff.py
Original file line number Diff line number Diff line change
@@ -345,8 +345,14 @@ def create_move(self):

if self.auto_reverse:
next_day = fields.Date.from_string(self.cutoff_date) + relativedelta(days=1)
rev_move = move._reverse_move(next_day, move.journal_id)
rev_move.ref = _("reversal of: ") + move.ref
rev_move = move._reverse_moves(
[
{
"date": next_day,
"ref": _("reversal of: ") + move.ref,
}
]
)
data["move_reversal_id"] = rev_move.id
if self.company_id.post_cutoff_move:
rev_move._post(soft=False)
108 changes: 108 additions & 0 deletions account_cutoff_base/tests/test_account_cutoff.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
# Copyright 2018 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import Command, fields
from odoo.tests.common import TransactionCase


class TestAccountCutoff(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
cls.company = cls.env.ref("base.main_company")
cls.cutoff_journal = cls.env["account.journal"].create(
{
"code": "cop0",
"company_id": cls.company.id,
"name": "Cutoff Journal Base",
"type": "general",
}
)
cls.cutoff_account = cls.env["account.account"].create(
{
"name": "Cutoff Base Account",
"code": "ACB480000",
"company_id": cls.company.id,
"account_type": "liability_current",
}
)

def test_default_cutoff_account_id(self):
account_id = self.env["account.cutoff"]._default_cutoff_account_id()
self.assertEqual(account_id, False)
@@ -36,3 +60,87 @@ def test_default_cutoff_account_id(self):
random_account.id,
"The account must be equals to %s" % random_account.id,
)

def test_create_move(self):
type_cutoff = "accrued_revenue"
cutoff = (
self.env["account.cutoff"]
.with_context(default_cutoff_type=type_cutoff)
.create(
{
"cutoff_type": type_cutoff,
"company_id": 1,
"cutoff_date": fields.Date.today(),
"cutoff_account_id": self.cutoff_account.id,
"cutoff_journal_id": self.cutoff_journal.id,
}
)
)
account = self.env["account.account"].create(
{
"name": "Base account",
"code": "ACB220000",
"company_id": self.company.id,
"account_type": "liability_current",
}
)
cutoff.line_ids = [
Command.create(
{
"parent_id": cutoff.id,
"account_id": account.id,
"cutoff_account_id": self.cutoff_account.id,
"cutoff_amount": 50,
},
)
]
self.company.post_cutoff_move = False
cutoff.auto_reverse = False
cutoff.create_move()
self.assertEqual(
cutoff.move_id.state,
"draft",
"A draft move is expected",
)
self.assertFalse(
cutoff.move_reversal_id,
"No reversal move is expected",
)
cutoff.back2draft()
self.assertFalse(
cutoff.move_id,
"No move is expected",
)
cutoff.auto_reverse = True
cutoff.create_move()
self.assertEqual(
cutoff.move_id.state,
"draft",
"A draft move is expected",
)
self.assertEqual(
cutoff.move_reversal_id.state,
"draft",
"A draft reversal move is expected",
)
cutoff.back2draft()
self.assertFalse(
cutoff.move_id,
"No move is expected",
)
self.assertFalse(
cutoff.move_reversal_id,
"No reversal move is expected",
)
self.company.post_cutoff_move = True
cutoff.create_move()
self.assertEqual(
cutoff.move_id.state,
"posted",
"A posted move is expected",
)
self.assertEqual(
cutoff.move_id.state,
"posted",
"A posted reversal move is expected",
)
1 change: 1 addition & 0 deletions account_cutoff_base/views/account_cutoff.xml
Original file line number Diff line number Diff line change
@@ -67,6 +67,7 @@
options="{'datepicker': {'warn_future': true}}"
/>
<field name="total_cutoff_amount" />
<field name="auto_reverse" />
<field name="source_move_state" widget="radio" />
<field name="company_id" options="{'no_create': True}" />
<field name="company_currency_id" invisible="1" />