[FIX] l10n_ar: Show proper message when trying to use a use_document journal when is not expected

We found an error by trying to post journals entries from an expense with a use_document journals.
Add new constraint that only let the user to create invoices in use documents journals, it can not create account.move of type entry

closes odoo/odoo#52690

X-original-commit: 82bbf3784e3bdf684eef25c53bf3235ebc2b7237
Signed-off-by: Josse Colpaert <jco@openerp.com>
This commit is contained in:
Katherine Zaoral
2020-06-09 11:12:54 +00:00
committed by Josse Colpaert
parent 0215a52252
commit d1c38bbf0f
3 changed files with 27 additions and 2 deletions
+11 -1
View File
@@ -868,7 +868,7 @@ msgstr ""
#: code:addons/l10n_ar/models/account_journal.py:0
#, python-format
msgid "Please define a valid AFIP POS number (5 digits max)"
msgstr "Por favor defina un número de PdV AFIP válido (5 números máximo)"
msgstr "Por favor defina un número de PdV AFIP válido (5 dígitos máximo)"
#. module: l10n_ar
#: code:addons/l10n_ar/models/account_journal.py:0
@@ -999,6 +999,16 @@ msgstr ""
msgid "The number of import Dispatch must be 16 characters"
msgstr "El número de Despacho de importación debe ser de 16 caracteres"
#. module: l10n_ar
#: code:addons/l10n_ar/models/account_move.py:0
#, python-format
msgid ""
"The selected Journal can't be used in this transaction, please select one "
"that doesn't use documents as these are just for Invoices."
msgstr ""
"El Diario seleccionado no se puede usar en esta transacción, por favor seleccione "
"uno que no use documentos, ya que estos son solo para Facturas."
#. module: l10n_ar
#: code:addons/l10n_ar/models/res_partner.py:0
#, python-format
+8
View File
@@ -958,6 +958,14 @@ msgstr ""
msgid "The number of import Dispatch must be 16 characters"
msgstr ""
#. module: l10n_ar
#: code:addons/l10n_ar/models/account_move.py:0
#, python-format
msgid ""
"The selected Journal can't be used in this transaction, please select one "
"that doesn't use documents as these are just for Invoices."
msgstr ""
#. module: l10n_ar
#: code:addons/l10n_ar/models/res_partner.py:0
#, python-format
+8 -1
View File
@@ -1,6 +1,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, fields, api, _
from odoo.exceptions import UserError, RedirectWarning
from odoo.exceptions import UserError, RedirectWarning, ValidationError
from dateutil.relativedelta import relativedelta
from lxml import etree
import logging
@@ -35,6 +35,13 @@ class AccountMove(models.Model):
l10n_ar_afip_service_start = fields.Date(string='AFIP Service Start Date', readonly=True, states={'draft': [('readonly', False)]})
l10n_ar_afip_service_end = fields.Date(string='AFIP Service End Date', readonly=True, states={'draft': [('readonly', False)]})
@api.constrains('type', 'journal_id', 'l10n_latam_use_documents')
def _check_moves_use_documents(self):
""" Do not let to create not invoices entries in journals that use documents """
not_invoices = self.filtered(lambda x: x.company_id.country_id == self.env.ref('base.ar') and x.journal_id.type in ['sale', 'purchase'] and x.l10n_latam_use_documents and not x.is_invoice())
if not_invoices:
raise ValidationError(_("The selected Journal can't be used in this transaction, please select one that doesn't use documents as these are just for Invoices."))
def _get_afip_invoice_concepts(self):
""" Return the list of values of the selection field. """
return [('1', 'Products / Definitive export of goods'), ('2', 'Services'), ('3', 'Products and Services'),