Skip to content

Commit

Permalink
[16.0][ADD] account_analytic_document_date: New module account_analyt…
Browse files Browse the repository at this point in the history
…ic_document_date
  • Loading branch information
BernatObrador committed Oct 3, 2024
1 parent dd9ab02 commit 331cb37
Show file tree
Hide file tree
Showing 25 changed files with 1,045 additions and 0 deletions.
Binary file added account_analytic_document_date.zip
Binary file not shown.
109 changes: 109 additions & 0 deletions account_analytic_document_date/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
==============================
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|

This module adds an other date to the account.move for analytics
proposits

**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)
* Miquel Pascual
* Bernat Obrador

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.

.. |[email protected], [email protected]| image:: https://github.com/[email protected], [email protected]?size=40px
:target: https://github.com/[email protected], [email protected]
:alt: [email protected], [email protected]

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

|[email protected], [email protected]|

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
23 changes: 23 additions & 0 deletions account_analytic_document_date/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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), Miquel Pascual, Bernat Obrador,"
"Odoo Community Association (OCA)"
),
"maintainers": ["[email protected], [email protected]"],
"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",
}
13 changes: 13 additions & 0 deletions account_analytic_document_date/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2024 (APSL - Nagarro) Miquel Pascual, Bernat Obrador
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import SUPERUSER_ID, api


def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})

moves = env["account.move"].search([])

for move in moves:
if not move.document_date:
move.write({"document_date": move.invoice_date})
44 changes: 44 additions & 0 deletions account_analytic_document_date/i18n/ca_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: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
21 changes: 21 additions & 0 deletions account_analytic_document_date/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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()

@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()
if not self.document_date:
self.document_date = self.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
1 change: 1 addition & 0 deletions account_analytic_document_date/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module adds an other date to the account.move for analytics proposits
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

0 comments on commit 331cb37

Please sign in to comment.