-
-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] account_analytic_distribution_manual_date: New module account_a…
…nalytic_distribution_manual_date
- Loading branch information
1 parent
02604ec
commit c28eea5
Showing
18 changed files
with
1,217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
========================================= | ||
Account analytic distribution manual date | ||
========================================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:87883cfe72166f656358d438fe09302ad6946598cf4bd9fde07fe7540827c940 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/17.0/account_analytic_distribution_manual_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-17-0/account-analytic-17-0-account_analytic_distribution_manual_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=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module introduces **Start Date** and **End Date** fields for manual | ||
distribution. | ||
|
||
This functionality enforces stricter management of distributions by | ||
ensuring only relevant distributions within the specified time periods | ||
are shown, based on the invoice date, the Journal Entry date or the | ||
today's date | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
To utilize this module, follow these steps: | ||
|
||
1. **Navigate to Manual Analytic Distributions**: | ||
|
||
- Go to **Invoicing** → **Configuration** → **Manual Analytic | ||
Distributions**. | ||
|
||
2. **Create or Edit a Distribution**: | ||
|
||
- Create a new distribution or edit an existing one. | ||
- Set the **Start Date** and **End Date** for the distribution. | ||
|
||
3. **Create an Invoice or Vendor Bill**: | ||
|
||
- Proceed to create a new **Invoice** or **Vendor Bill**. | ||
|
||
4. **Add a Line to the Invoice**: | ||
|
||
- Create a line item on the invoice. | ||
- Select a manual distribution using the distribution widget. | ||
|
||
5. **Filtered Manual Distributions**: | ||
|
||
- Now, the available Manual Distributions will be filtered based on | ||
the **Invoice Date** or **Today's Date**. | ||
|
||
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_distribution_manual_date%0Aversion:%2017.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) Bernat Obrador | ||
|
||
Contributors | ||
------------ | ||
|
||
- APSL - Nagarro <https://apsl.tech> | ||
|
||
- 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-BernatObrador| image:: https://github.com/BernatObrador.png?size=40px | ||
:target: https://github.com/BernatObrador | ||
:alt: BernatObrador | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-BernatObrador| | ||
|
||
This module is part of the `OCA/account-analytic <https://github.com/OCA/account-analytic/tree/17.0/account_analytic_distribution_manual_date>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Copyright 2024 (APSL - Nagarro) Bernat Obrador | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2024 (APSL - Nagarro) Bernat Obrador | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Account analytic distribution manual date", | ||
"summary": "Account analytic distribution manual date", | ||
"version": "17.0.1.0.0", | ||
"license": "AGPL-3", | ||
"website": "https://github.com/OCA/account-analytic", | ||
"author": "(Nagarro - APSL) Bernat Obrador, Odoo Community Association (OCA)", | ||
"maintainers": ["BernatObrador"], | ||
"depends": ["account_analytic_distribution_manual"], | ||
"data": [ | ||
"views/account_analytic_distribution_manual_views.xml", | ||
], | ||
"assets": { | ||
"web.assets_backend": [ | ||
"account_analytic_distribution_manual_date/static/src/components/**/*", | ||
], | ||
}, | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_analytic_distribution_manual_date | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 17.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-11-07 07:42+0000\n" | ||
"PO-Revision-Date: 2024-11-07 07:42+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_distribution_manual_date | ||
#: model:ir.model,name:account_analytic_distribution_manual_date.model_account_analytic_distribution_manual | ||
msgid "Account analytic distribution manual" | ||
msgstr "Distribució Analítica Manual" | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#: model_terms:ir.ui.view,arch_db:account_analytic_distribution_manual_date.view_account_analytic_distribution_manual_form_inherit | ||
msgid "Distribution Dates" | ||
msgstr "Dates de Distribució" | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#: model:ir.model.fields,field_description:account_analytic_distribution_manual_date.field_account_analytic_distribution_manual__end_date | ||
#: model_terms:ir.ui.view,arch_db:account_analytic_distribution_manual_date.view_account_analytic_distribution_manual_form_inherit | ||
msgid "End Date" | ||
msgstr "Data de Fi" | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#: model:ir.model,name:account_analytic_distribution_manual_date.model_account_move | ||
msgid "Journal Entry" | ||
msgstr "Assentament comptable" | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#: model:ir.model.fields,field_description:account_analytic_distribution_manual_date.field_account_analytic_distribution_manual__start_date | ||
#: model_terms:ir.ui.view,arch_db:account_analytic_distribution_manual_date.view_account_analytic_distribution_manual_form_inherit | ||
msgid "Start Date" | ||
msgstr "Data d'Inici" | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#. odoo-python | ||
#: code:addons/account_analytic_distribution_manual_date/models/account_move.py:0 | ||
#, python-format | ||
msgid "" | ||
"The invoice date %(invoice_date)s is after the manual distribution end date " | ||
"%(end_date)s." | ||
msgstr "La data de la factura %(invoice_date)s és posterior a la data de fi de la distribució manual %(end_date)s." | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#. odoo-python | ||
#: code:addons/account_analytic_distribution_manual_date/models/account_move.py:0 | ||
#, python-format | ||
msgid "" | ||
"The invoice date %(invoice_date)s is before the manual distribution start " | ||
"date %(start_date)s." | ||
msgstr "La data de la factura %(invoice_date)s és anterior a la data d'inici de la distribució manual %(start_date)s." | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#. odoo-python | ||
#: code:addons/account_analytic_distribution_manual_date/models/account_move.py:0 | ||
#, python-format | ||
msgid "" | ||
"The invoice date %(invoice_date)s is outside the manual distribution period " | ||
"%(start_date)s - %(end_date)s." | ||
msgstr "La data de la factura %(invoice_date)s està fora del període de distribució manual %(start_date)s - %(end_date)s." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_analytic_distribution_manual_date | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 17.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-10-14 13:14+0000\n" | ||
"PO-Revision-Date: 2024-10-14 13:14+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_distribution_manual_date | ||
#: model:ir.model,name:account_analytic_distribution_manual_date.model_account_analytic_distribution_manual | ||
msgid "Account analytic distribution manual" | ||
msgstr "Distribución Analítica Manual" | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#: model_terms:ir.ui.view,arch_db:account_analytic_distribution_manual_date.view_account_analytic_distribution_manual_form_inherit | ||
msgid "Distribution Dates" | ||
msgstr "Fechas de Distribución" | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#: model:ir.model.fields,field_description:account_analytic_distribution_manual_date.field_account_analytic_distribution_manual__end_date | ||
#: model_terms:ir.ui.view,arch_db:account_analytic_distribution_manual_date.view_account_analytic_distribution_manual_form_inherit | ||
msgid "End Date" | ||
msgstr "Fecha de Fin" | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#: model:ir.model,name:account_analytic_distribution_manual_date.model_account_move | ||
msgid "Journal Entry" | ||
msgstr "Asiento contable" | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#: model:ir.model.fields,field_description:account_analytic_distribution_manual_date.field_account_analytic_distribution_manual__start_date | ||
#: model_terms:ir.ui.view,arch_db:account_analytic_distribution_manual_date.view_account_analytic_distribution_manual_form_inherit | ||
msgid "Start Date" | ||
msgstr "Fecha de Inicio" | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#. odoo-python | ||
#: code:addons/account_analytic_distribution_manual_date/models/account_move.py:0 | ||
#, python-format | ||
msgid "" | ||
"The invoice date %(invoice_date)s is after the manual distribution end date " | ||
"%(end_date)s." | ||
msgstr "La fecha de la factura %(invoice_date)s es posterior a la fecha de fin de la distribución manual %(end_date)s." | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#. odoo-python | ||
#: code:addons/account_analytic_distribution_manual_date/models/account_move.py:0 | ||
#, python-format | ||
msgid "" | ||
"The invoice date %(invoice_date)s is before the manual distribution start " | ||
"date %(start_date)s." | ||
msgstr "La fecha de la factura %(invoice_date)s es anterior a la fecha de inicio de la distribución manual %(start_date)s." | ||
|
||
#. module: account_analytic_distribution_manual_date | ||
#. odoo-python | ||
#: code:addons/account_analytic_distribution_manual_date/models/account_move.py:0 | ||
#, python-format | ||
msgid "" | ||
"The invoice date %(invoice_date)s is outside the manual distribution period " | ||
"%(start_date)s - %(end_date)s." | ||
msgstr "La fecha de la factura %(invoice_date)s está fuera del período de distribución manual %(start_date)s - %(end_date)s." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import account_analytic_distribution_manual | ||
from . import account_move |
10 changes: 10 additions & 0 deletions
10
account_analytic_distribution_manual_date/models/account_analytic_distribution_manual.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright 2024 (APSL - Nagarro) Bernat Obrador | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import fields, models | ||
|
||
|
||
class AccountAnalyticDistributionManual(models.Model): | ||
_inherit = "account.analytic.distribution.manual" | ||
|
||
start_date = fields.Date() | ||
end_date = fields.Date() |
91 changes: 91 additions & 0 deletions
91
account_analytic_distribution_manual_date/models/account_move.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Copyright 2024 (APSL - Nagarro) Bernat Obrador | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import _, fields, models | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class AccountMove(models.Model): | ||
_inherit = "account.move" | ||
|
||
def write(self, vals): | ||
for record in self: | ||
date = self._get_invoice_date(vals, record) | ||
|
||
invoice_line_ids = vals.get("invoice_line_ids", []) | ||
|
||
if invoice_line_ids: | ||
self._validate_manual_distributions(invoice_line_ids, date) | ||
elif "invoice_date" in vals: | ||
self._validate_existing_manual_distributions(date, record) | ||
|
||
return super().write(vals) | ||
|
||
def _get_invoice_date(self, vals, record): | ||
date_string = ( | ||
vals.get("invoice_date") | ||
or record.invoice_date | ||
or vals.get("date") | ||
or record.date | ||
) | ||
return ( | ||
fields.Date.from_string(date_string) | ||
if date_string | ||
else fields.Date.context_today(self) | ||
) | ||
|
||
def _validate_manual_distributions(self, invoice_line_ids, date): | ||
for line in invoice_line_ids: | ||
if len(line) > 2 and "manual_distribution_id" in line[2]: | ||
manual_distribution = self.env[ | ||
"account.analytic.distribution.manual" | ||
].browse(line[2]["manual_distribution_id"]) | ||
self._check_manual_distribution_date(manual_distribution, date) | ||
|
||
def _validate_existing_manual_distributions(self, date, record): | ||
for line in record.invoice_line_ids: | ||
manual_distribution = line.manual_distribution_id | ||
if manual_distribution: | ||
self._check_manual_distribution_date(manual_distribution, date) | ||
|
||
def _check_manual_distribution_date(self, manual_distribution, date): | ||
if manual_distribution: | ||
start_date = manual_distribution.start_date | ||
end_date = manual_distribution.end_date | ||
|
||
if start_date and end_date and not (start_date <= date <= end_date): | ||
raise UserError( | ||
_( | ||
"The invoice date %(invoice_date)s is outside the " | ||
"manual distribution period %(start_date)s - " | ||
"%(end_date)s." | ||
) | ||
% { | ||
"invoice_date": date, | ||
"start_date": start_date, | ||
"end_date": end_date, | ||
} | ||
) | ||
|
||
elif start_date and not end_date and date < start_date: | ||
raise UserError( | ||
_( | ||
"The invoice date %(invoice_date)s is before the " | ||
"manual distribution start date %(start_date)s." | ||
) | ||
% { | ||
"invoice_date": date, | ||
"start_date": start_date, | ||
} | ||
) | ||
|
||
elif not start_date and end_date and date > end_date: | ||
raise UserError( | ||
_( | ||
"The invoice date %(invoice_date)s is after the " | ||
"manual distribution end date %(end_date)s." | ||
) | ||
% { | ||
"invoice_date": date, | ||
"end_date": end_date, | ||
} | ||
) |
Oops, something went wrong.