Skip to content
Snippets Groups Projects
Commit 28cca3ef7c26 authored by Houzefa Abbasbhay's avatar Houzefa Abbasbhay :slight_smile:
Browse files

Users may set accounting dates in advance

parent 115dd1756551
No related branches found
No related tags found
1 merge request!1Topic/13.0/dates tg 347
Pipeline #11710 canceled
13.0.1.1.0
----------
* Users may set accounting dates in advance.
13.0.1.0.0
----------
......
......@@ -12,6 +12,8 @@
:alt: coverage report
Per-period accounting concept. Periods can be individually closed.
Periods are filled based on an accounting date this module adds which users
may however set in advance.
This module also adds a transaction date in accounting documents.
......
......@@ -22,7 +22,7 @@
"name": "Accounting Periods",
"license": "AGPL-3",
"summary": "Add period accounting concept",
"version": "13.0.1.0.0",
"version": "13.0.1.1.0",
"category": "Accounting/Accounting",
"author": "XCG Consulting",
"website": "http://odoo.consulting/",
......
......@@ -18,8 +18,6 @@
#
##############################################################################
import datetime
from odoo import _, api, exceptions, fields, models
......@@ -33,7 +31,7 @@
string="Accounting date",
copy=False,
help="Validation date of the accounting document.",
readonly=True,
states={"posted": [("readonly", True)]},
)
period_id = fields.Many2one(
......@@ -82,8 +80,8 @@
- Only select open periods.
"""
acc_date = datetime.date.today()
today = fields.Date.today()
for accdoc in self:
# Cache some data.
......@@ -86,7 +84,8 @@
for accdoc in self:
# Cache some data.
acc_date = accdoc.accounting_date or today
company = accdoc.company_id
# Set the acc_date only if the force_period_on_date
......
......@@ -51,6 +51,18 @@
today = odoo.fields.Date.today()
period_today = self._getTodayPeriod()
# Prepare periods for the 2017-01-15 date we use below.
fiscalyear_2017 = self.env["account.fiscalyear"].create(
{
"code": "2017",
"company_id": self.env.company.id,
"date_stop": odoo.fields.Date.to_date("2017-12-31"),
"name": "2017",
}
)
fiscalyear_2017.create_period()
period_2017_01 = fiscalyear_2017.period_ids[0]
# Control: Default dates & period around today.
accdoc = self._makeInvoice()
self._validateInvoice(accdoc)
......@@ -62,7 +74,7 @@
self.assertEqual(set(accentries.mapped("transaction_date")), {today})
self.assertEqual(accentries.mapped("period_id").id, period_today.id)
# Force a date on the invoice; check its propagation.
# Force a transaction date on the invoice; check its propagation.
forced_date = odoo.fields.Date.to_date("2017-01-15")
accdoc = self._makeInvoice(invoice_date=forced_date)
self._validateInvoice(accdoc)
......@@ -76,6 +88,20 @@
)
self.assertEqual(accentries.mapped("period_id").id, period_today.id)
# Force an accounting date on the invoice; check its propagation.
forced_date = odoo.fields.Date.to_date("2017-01-15")
accdoc = self._makeInvoice(accounting_date=forced_date)
self._validateInvoice(accdoc)
self.assertEqual(accdoc.accounting_date, forced_date)
self.assertEqual(accdoc.date, today) # unchanged odoo field
self.assertEqual(accdoc.transaction_date, forced_date)
self.assertEqual(accdoc.period_id.id, period_2017_01.id)
accentries = accdoc.line_ids
self.assertEqual(
set(accentries.mapped("transaction_date")), {forced_date}
)
self.assertEqual(accentries.mapped("period_id").id, period_2017_01.id)
def test_close_period(self):
"""Check the "Close period" dialog box.
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment