Skip to content

Commit

Permalink
[ADD] account_analytic_distribution_manual_date: New module account_a…
Browse files Browse the repository at this point in the history
…nalytic_distribution_manual_date
  • Loading branch information
BernatObrador committed Oct 15, 2024
1 parent 02604ec commit 1ad6c65
Show file tree
Hide file tree
Showing 18 changed files with 1,070 additions and 0 deletions.
113 changes: 113 additions & 0 deletions account_analytic_distribution_manual_date/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
=========================================
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.

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.
3 changes: 3 additions & 0 deletions account_analytic_distribution_manual_date/__init__.py
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
21 changes: 21 additions & 0 deletions account_analytic_distribution_manual_date/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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)",
"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,
}
46 changes: 46 additions & 0 deletions account_analytic_distribution_manual_date/i18n/ca_ES.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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ó 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.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
#: code:addons/account_analytic_distribution_manual_date/models/account_move.py:0
#, python-format
msgid "The invoice date %s is outside the manual distribution period %s - %s."
msgstr "La data de la factura %s està fora del període de la distribució manual %s - %s."
46 changes: 46 additions & 0 deletions account_analytic_distribution_manual_date/i18n/es .po
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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.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
#: code:addons/account_analytic_distribution_manual_date/models/account_move.py:0
#, python-format
msgid "The invoice date %s is outside the manual distribution period %s - %s."
msgstr "La fecha de la factura %s está fuera del período de la distribución manual %s - %s."
2 changes: 2 additions & 0 deletions account_analytic_distribution_manual_date/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_analytic_distribution_manual
from . import account_move
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()
71 changes: 71 additions & 0 deletions account_analytic_distribution_manual_date/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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):
date_string = (
vals.get("invoice_date")
or self.invoice_date
or vals.get("date")
or self.date
)
date = (
fields.Date.from_string(date_string)
if date_string
else fields.Date.context_today(self)
)

invoice_line_ids = vals.get("invoice_line_ids", [])

if invoice_line_ids:
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"])
if manual_distribution and not (
manual_distribution.start_date
<= date
<= manual_distribution.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": manual_distribution.start_date,
"end_date": manual_distribution.end_date,
}
)
# If invoice date has changed but no lines has changed
elif "needed_terms_dirty" not in vals:
for line in self.invoice_line_ids:
manual_distribution = line.manual_distribution_id
if manual_distribution:
if not (
manual_distribution.start_date
<= date
<= manual_distribution.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": manual_distribution.start_date,
"end_date": manual_distribution.end_date,
}
)

return super().write(vals)
3 changes: 3 additions & 0 deletions account_analytic_distribution_manual_date/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- APSL - Nagarro \<<https://apsl.tech>\>
- Bernat Obrador
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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
18 changes: 18 additions & 0 deletions account_analytic_distribution_manual_date/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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**.
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 1ad6c65

Please sign in to comment.