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

TA#66906 [16.0][MIG]:account_invoice_constraint_chronology_forced #183

Merged
merged 5 commits into from
Jul 2, 2024
Merged
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
1 change: 1 addition & 0 deletions .docker_files/main/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"account",
"account_bank_menu",
"account_closing_journal",
"account_invoice_constraint_chronology_forced",
"account_show_full_features",
"old_accounts",
],
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ USER odoo

COPY account_bank_menu /mnt/extra-addons/account_bank_menu
COPY account_closing_journal /mnt/extra-addons/account_closing_journal
COPY account_invoice_constraint_chronology_forced /mnt/extra-addons/account_invoice_constraint_chronology_forced
COPY account_show_full_features /mnt/extra-addons/account_show_full_features
COPY old_accounts /mnt/extra-addons/old_accounts

Expand Down
22 changes: 22 additions & 0 deletions account_invoice_constraint_chronology_forced/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Account Invoice Constraint Chronology Forced
============================================

.. contents:: Table of Contents

Context
-------
The module `Account Invoice Constraint Chronology <https://github.com/OCA/account-financial-tools/blob/14.0/account_invoice_constraint_chronology>`_ helps ensuring the chronology of invoice numbers.

This module adds the following fixes :

* Add French translation of some messages
* Lock the field check_chronolgy and set it to True for sale type journal
* Forbids changing the type of a sale journal if it contains accounting moves

Contributors
------------
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)

More information
----------------
* Meet us at https://bit.ly/numigi-com
5 changes: 5 additions & 0 deletions account_invoice_constraint_chronology_forced/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import models

Check notice on line 4 in account_invoice_constraint_chronology_forced/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

account_invoice_constraint_chronology_forced/__init__.py#L4

'.models' imported but unused (F401)
from .hooks import sale_journals_check_chronology

Check notice on line 5 in account_invoice_constraint_chronology_forced/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

account_invoice_constraint_chronology_forced/__init__.py#L5

'.hooks.sale_journals_check_chronology' imported but unused (F401)
19 changes: 19 additions & 0 deletions account_invoice_constraint_chronology_forced/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{

Check warning on line 4 in account_invoice_constraint_chronology_forced/__manifest__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

account_invoice_constraint_chronology_forced/__manifest__.py#L4

Statement seems to have no effect
'name': 'Account Invoice Constraint Chronology Forced',
'version': '1.1.0',
'author': 'Numigi',
'maintainer': 'Numigi',
'website': 'https://www.numigi.com',
'license': 'LGPL-3',
'category': 'Accounting',
'summary': 'Add menu entries to configure bank accounts and banks of partners',
'depends': [
'account_invoice_constraint_chronology',
],
"data": ["views/account_journal.xml"],
"installable": True,
"post_init_hook": "sale_journals_check_chronology",
}
10 changes: 10 additions & 0 deletions account_invoice_constraint_chronology_forced/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo import SUPERUSER_ID, api


def sale_journals_check_chronology(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
sale_journal_ids = env["account.journal"].search([('type', '=', 'sale')])
for journal in sale_journal_ids:
journal.check_chronology = True
57 changes: 57 additions & 0 deletions account_invoice_constraint_chronology_forced/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_invoice_constraint_chronology
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-16 10:18+0000\n"
"PO-Revision-Date: 2023-08-16 10:18+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_invoice_constraint_chronology
#: code:addons/account_invoice_constraint_chronology/model/account_move.py:0
#, python-format
msgid ""
"Chronology conflict: A conflicting draft invoice dated before {date_invoice}"
" exists, please validate it first."
msgstr ""
"Conflit de chronologie : Une facture brouillon existe avant le "
"{date_invoice} , merci de la valider avant"

#. module: account_invoice_constraint_chronology
#: code:addons/account_invoice_constraint_chronology/model/account_move.py:0
#, python-format
msgid ""
"Chronology conflict: A conflicting validated invoice dated after "
"{date_invoice} exists."
msgstr ""
"Conflit de chronologie : Une facture a été validé avec une date après le "
" {date_invoice}"

#. module: account_invoice_constraint_chronology
#: code:addons/account_invoice_constraint_chronology/model/account_move.py:0
#, python-format
msgid ""
"Chronology conflict: An invoice with a higher number {highest_name} dated "
"before {date_invoice} exists."
msgstr ""
"Conflit de chronologie : Une facture avec une sequence plus grande {highest_name} existe "
"avant le {date_invoice}"

#. module: account_invoice_constraint_chronology_forced
#: code:addons/account_invoice_constraint_chronology_forced/models/account_journal.py:0
#, python-format
msgid ""
"You cannot change the Type of the Journal because there is At Least One "
"Account Move linked to the Journal."
msgstr ""
"Vous ne pouvez pas modifier le type du journal car au moins "
"une pièce comptable est associée au journal."
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import account_journal

Check notice on line 4 in account_invoice_constraint_chronology_forced/models/__init__.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

account_invoice_constraint_chronology_forced/models/__init__.py#L4

'.account_journal' imported but unused (F401)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2024-today Numigi and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from odoo import api, models, _
from odoo.exceptions import UserError


class AccountJournal(models.Model):
_inherit = "account.journal"

@api.onchange("type")
def _onchange_type(self):
super()._onchange_type()
if self.type == "sale":
self.check_chronology = True
if self._origin.type == "sale":
domain = [("journal_id", '=', self._origin.id), ('move_type', '=',
'out_invoice')]
moves_count = self.env['account.move'].search_count(domain)
if moves_count > 0:
raise UserError(_("You cannot change the Type of the Journal because "
"there is At Least One Account Move linked to the Journal."))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
# © 2023 Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
-->
<odoo>
<record id="view_account_journal_form" model="ir.ui.view">
<field name="name">account.journal.form.readonly.check_chronology</field>
<field name="model">account.journal</field>
<field name="inherit_id" ref="account_invoice_constraint_chronology.view_account_journal_form" />
<field name="arch" type="xml">
<field name="check_chronology" position="attributes">
<attribute name="attrs">{'readonly': [('type', '=', 'sale')],
'invisible': [('type', 'not in', ['sale', 'purchase'])] }
</attribute>
<attribute name="force_save">1</attribute>
</field>

</field>
</record>
</odoo>
Loading