diff options
| author | Katherine Zaoral <kz@adhoc.com.ar> | 2020-04-29 19:45:14 +0000 |
|---|---|---|
| committer | Josse Colpaert <jco@odoo.com> | 2020-06-09 11:12:54 +0000 |
| commit | d1c38bbf0fd48509180ea36b2ebde4deb0738326 (patch) | |
| tree | 6546166ca30fb3292d31245270bc7e0e13f4c030 /addons/l10n_ar | |
| parent | 0215a52252792abab0f274e227195c8f187b3127 (diff) | |
[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>
Diffstat (limited to 'addons/l10n_ar')
| -rw-r--r-- | addons/l10n_ar/i18n/es.po | 12 | ||||
| -rw-r--r-- | addons/l10n_ar/i18n/l10n_ar.pot | 8 | ||||
| -rw-r--r-- | addons/l10n_ar/models/account_move.py | 9 |
3 files changed, 27 insertions, 2 deletions
diff --git a/addons/l10n_ar/i18n/es.po b/addons/l10n_ar/i18n/es.po index cd975eb1dde..3b57cffc086 100644 --- a/addons/l10n_ar/i18n/es.po +++ b/addons/l10n_ar/i18n/es.po @@ -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 @@ -1000,6 +1000,16 @@ 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 msgid "The validation digit is not valid for \"%s\"" diff --git a/addons/l10n_ar/i18n/l10n_ar.pot b/addons/l10n_ar/i18n/l10n_ar.pot index b6a9c8d507f..3f938007ca6 100644 --- a/addons/l10n_ar/i18n/l10n_ar.pot +++ b/addons/l10n_ar/i18n/l10n_ar.pot @@ -959,6 +959,14 @@ 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 msgid "The validation digit is not valid for \"%s\"" diff --git a/addons/l10n_ar/models/account_move.py b/addons/l10n_ar/models/account_move.py index 97bf2a45520..178f5644f34 100644 --- a/addons/l10n_ar/models/account_move.py +++ b/addons/l10n_ar/models/account_move.py @@ -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'), |
