Skip to content
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

[16.0][ADD] account_analytic_document_date: New module account_analyt… #694

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions account_analytic_document_date/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
==============================
Account Analytic Document Date
==============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a744d1489a8640283abcaacbc6366a24199f447d5d46ba66ad30beefcebf542b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github
:target: https://github.com/OCA/account-analytic/tree/16.0/account_analytic_document_date
:alt: OCA/account-analytic
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-analytic-16-0/account-analytic-16-0-account_analytic_document_date
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-analytic&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

The module introduces a new field in the accounting records to specify
the "Accrual Date" for income and expenses. This field is crucial for
accurately tracking when the revenue or expense is earned or incurred,
regardless of the invoice creation date.

For instance, if an invoice is created in December but refers to sales
made in November, the Accrual Date allows us to reflect this correctly
in our accounting records. This ensures compliance with accrual-based
accounting principles and provides better insights into the financial
period to which transactions belong.

This feature is particularly valuable for businesses that need to
differentiate between the accounting period of transaction occurrence
and the timing of document issuance.

**Table of contents**

.. contents::
:local:

Usage
=====

1. **Set Document Date on Invoice:**

- Navigate to the invoice and set the document date.
- If the document date is not set, it will automatically be assigned
the invoice date upon confirmation.

2. **Analytic Line Generation:**

- If any line has analytic information, the generated analytic entry
will inherit the document date.

3. **Setting Document Date in Reconcile View:**

- You can also set the document date from the reconciliation view,
but this option is available only during manual reconciliation.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-analytic/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-analytic/issues/new?body=module:%20account_analytic_document_date%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* (Nagarro - APSL)

Contributors
------------

- ``APSL - Nagarro <https://apsl.tech>``\ \_\_:

- Miquel Pascual
- Bernat Obrador

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-mpascual, BernatObrador| image:: https://github.com/mpascual, BernatObrador.png?size=40px
:target: https://github.com/mpascual, BernatObrador
:alt: mpascual, BernatObrador

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-mpascual, BernatObrador|

This module is part of the `OCA/account-analytic <https://github.com/OCA/account-analytic/tree/16.0/account_analytic_document_date>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions account_analytic_document_date/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .hooks import post_init_hook
20 changes: 20 additions & 0 deletions account_analytic_document_date/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 (APSL - Nagarro) Miquel Pascual, Bernat Obrador
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Account Analytic Document Date",
"summary": "Account Analytic Document Date",
"version": "16.0.1.0.0",
"website": "https://github.com/OCA/account-analytic",
"author": ("(Nagarro - APSL), Odoo Community Association (OCA)"),
"maintainers": ["mpascual, BernatObrador"],
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["account", "account_reconcile_oca"],
"data": [
"views/account_analytic_line_views.xml",
"views/account_bank_statement_line_views.xml",
"views/account_move.xml",
],
"post_init_hook": "post_init_hook",
}
12 changes: 12 additions & 0 deletions account_analytic_document_date/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2024 (APSL - Nagarro) Miquel Pascual, Bernat Obrador
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).


def post_init_hook(cr, registry):
cr.execute(
"""
UPDATE account_move
SET document_date = invoice_date
WHERE document_date IS NULL
"""
)
44 changes: 44 additions & 0 deletions account_analytic_document_date/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_analytic_document_date
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-27 10:33+0000\n"
"PO-Revision-Date: 2024-09-27 10:33+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_analytic_document_date
#: model:ir.model,name:account_analytic_document_date.model_account_analytic_line
msgid "Analytic Line"
msgstr "Línia analítica"

#. module: account_analytic_document_date
#: model:ir.model,name:account_analytic_document_date.model_account_bank_statement_line
msgid "Bank Statement Line"
msgstr "Línea d'extracte bancari"

#. module: account_analytic_document_date
#: model:ir.model.fields,field_description:account_analytic_document_date.field_account_analytic_line__document_date
#: model:ir.model.fields,field_description:account_analytic_document_date.field_account_bank_statement_line__document_date
#: model:ir.model.fields,field_description:account_analytic_document_date.field_account_move__document_date
#: model:ir.model.fields,field_description:account_analytic_document_date.field_account_payment__document_date
msgid "Document Date"
msgstr "Data del Document"

#. module: account_analytic_document_date
#: model:ir.model,name:account_analytic_document_date.model_account_move
msgid "Journal Entry"
msgstr "Assentament comptable"

#. module: account_analytic_document_date
#: model:ir.model,name:account_analytic_document_date.model_account_move_line
msgid "Journal Item"
msgstr "Element del diari"
44 changes: 44 additions & 0 deletions account_analytic_document_date/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_analytic_document_date
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-27 10:29+0000\n"
"PO-Revision-Date: 2024-09-27 10:29+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: account_analytic_document_date
#: model:ir.model,name:account_analytic_document_date.model_account_analytic_line
msgid "Analytic Line"
msgstr "Línea analítica"

#. module: account_analytic_document_date
#: model:ir.model,name:account_analytic_document_date.model_account_bank_statement_line
msgid "Bank Statement Line"
msgstr "Línea de extracto bancario"

#. module: account_analytic_document_date
#: model:ir.model.fields,field_description:account_analytic_document_date.field_account_analytic_line__document_date
#: model:ir.model.fields,field_description:account_analytic_document_date.field_account_bank_statement_line__document_date
#: model:ir.model.fields,field_description:account_analytic_document_date.field_account_move__document_date
#: model:ir.model.fields,field_description:account_analytic_document_date.field_account_payment__document_date
msgid "Document Date"
msgstr "Fecha del Documento"

#. module: account_analytic_document_date
#: model:ir.model,name:account_analytic_document_date.model_account_move
msgid "Journal Entry"
msgstr "Asiento contable"

#. module: account_analytic_document_date
#: model:ir.model,name:account_analytic_document_date.model_account_move_line
msgid "Journal Item"
msgstr "Apunte contable"
4 changes: 4 additions & 0 deletions account_analytic_document_date/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import account_move_line
from . import account_analytic_line
from . import account_move
from . import account_bank_statement_line
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2024 (APSL - Nagarro) Miquel Pascual, Bernat Obrador
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class AccountAnalyticLine(models.Model):
_inherit = "account.analytic.line"

document_date = fields.Date()
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 (APSL - Nagarro) Miquel Pascual, Bernat Obrador
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"

document_date = fields.Date(
"Document Date", related="move_id.document_date", readonly=False
)

def reconcile_bank_line(self):
self.ensure_one()
res = super().reconcile_bank_line()
self.move_id.document_date = self.document_date
return res

Check warning on line 17 in account_analytic_document_date/models/account_bank_statement_line.py

View check run for this annotation

Codecov / codecov/patch

account_analytic_document_date/models/account_bank_statement_line.py#L14-L17

Added lines #L14 - L17 were not covered by tests
22 changes: 22 additions & 0 deletions account_analytic_document_date/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024 (APSL - Nagarro) Miquel Pascual, Bernat Obrador
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models


class AccountMove(models.Model):
_inherit = "account.move"

document_date = fields.Date()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a date only for analytic, it shouldn't be called document_date, but analytic_document_date or analytic_date.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it is used for analytic purposes, but it is also visible in the account module, so it serves both purposes. For this reason, I believe the name 'document_date' remains appropriate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it creates confusion on users thinking that date is going to be used for example for financial reports. It should be renamed to analytic_document_date IMO.


@api.onchange("invoice_date")
def _onchange_invoice_date(self):
for record in self:
if not record.document_date:
record.document_date = record.invoice_date

def action_post(self):
res = super().action_post()
for record in self:
if not record.document_date:
record.document_date = record.invoice_date
return res
16 changes: 16 additions & 0 deletions account_analytic_document_date/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2024 (APSL - Nagarro) Miquel Pascual, Bernat Obrador
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models


class AccountMoveLine(models.Model):
_inherit = "account.move.line"

def _prepare_analytic_lines(self):
vals = super()._prepare_analytic_lines()
for val in vals:
if self.move_id.document_date:
val.update({"document_date": self.move_id.document_date})
else:
val.update({"document_date": self.move_id.invoice_date})
return vals
4 changes: 4 additions & 0 deletions account_analytic_document_date/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- `APSL - Nagarro <https://apsl.tech>`__:

- Miquel Pascual
- Bernat Obrador
5 changes: 5 additions & 0 deletions account_analytic_document_date/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The module introduces a new field in the accounting records to specify the "Accrual Date" for income and expenses. This field is crucial for accurately tracking when the revenue or expense is earned or incurred, regardless of the invoice creation date.

For instance, if an invoice is created in December but refers to sales made in November, the Accrual Date allows us to reflect this correctly in our accounting records. This ensures compliance with accrual-based accounting principles and provides better insights into the financial period to which transactions belong.

This feature is particularly valuable for businesses that need to differentiate between the accounting period of transaction occurrence and the timing of document issuance.
9 changes: 9 additions & 0 deletions account_analytic_document_date/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1. **Set Document Date on Invoice:**
- Navigate to the invoice and set the document date.
- If the document date is not set, it will automatically be assigned the invoice date upon confirmation.

2. **Analytic Line Generation:**
- If any line has analytic information, the generated analytic entry will inherit the document date.

3. **Setting Document Date in Reconcile View:**
- You can also set the document date from the reconciliation view, but this option is available only during manual reconciliation.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading