summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorKatherine Zaoral <kz@adhoc.com.ar>2020-06-09 19:06:01 +0000
committerKatherine Zaoral <kz@adhoc.com.ar>2020-06-12 10:43:58 +0000
commitb7421e5860822652a3dbe0d3307b11534c076ad1 (patch)
treeb765fb72a93fb544facb3175e7425ff3794c3bfb /addons
parentd2bd958765734108065e7f5a46021ba34cadfdc6 (diff)
[FIX] l10n_ar: support multiple records inside constraint method
Before this change the constraint that check afip configurations has an ensure_one() that was throwing an error when we try to change journals in batch. Now the constraint support mutilple records at once and return the ValidationError message show information of the journal's which constraint aplies. Also, we remove the print of the list of the invoices in the ValidationError message because this ones could be a really long list and it is not necessary, only knowing the journal is enough. closes odoo/odoo#52914 X-original-commit: 710bb9f161da4718024c4454ce14a7dbc2d24c93 Signed-off-by: Josse Colpaert <jco@openerp.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/l10n_ar/i18n/es.po12
-rw-r--r--addons/l10n_ar/i18n/l10n_ar.pot4
-rw-r--r--addons/l10n_ar/models/account_journal.py15
3 files changed, 14 insertions, 17 deletions
diff --git a/addons/l10n_ar/i18n/es.po b/addons/l10n_ar/i18n/es.po
index 3b57cffc086..57928f97f1e 100644
--- a/addons/l10n_ar/i18n/es.po
+++ b/addons/l10n_ar/i18n/es.po
@@ -1006,8 +1006,8 @@ 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."
+"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
@@ -1207,11 +1207,11 @@ msgstr ""
#: code:addons/l10n_ar/models/account_journal.py:0
#, python-format
msgid ""
-"You can not change the journal configuration for a journal that already have"
-" validate invoices"
+"You can not change the journal's configuration if journal already have "
+"validated invoices"
msgstr ""
-"No puedes cambiar la configuración del diario ya que este tiene facturas "
-"validadas"
+"No puedes cambiar la confguración de un diario si el diario ya tiene "
+"facturas validadas"
#. module: l10n_ar
#: model:ir.model.fields.selection,name:l10n_ar.selection__l10n_latam_document_type__purchase_aliquots__zero
diff --git a/addons/l10n_ar/i18n/l10n_ar.pot b/addons/l10n_ar/i18n/l10n_ar.pot
index 3f938007ca6..514f916dcc9 100644
--- a/addons/l10n_ar/i18n/l10n_ar.pot
+++ b/addons/l10n_ar/i18n/l10n_ar.pot
@@ -1156,8 +1156,8 @@ msgstr ""
#: code:addons/l10n_ar/models/account_journal.py:0
#, python-format
msgid ""
-"You can not change the journal configuration for a journal that already have"
-" validate invoices"
+"You can not change the journal's configuration if journal already have "
+"validated invoices"
msgstr ""
#. module: l10n_ar
diff --git a/addons/l10n_ar/models/account_journal.py b/addons/l10n_ar/models/account_journal.py
index ba901e591fc..8a537f57b4d 100644
--- a/addons/l10n_ar/models/account_journal.py
+++ b/addons/l10n_ar/models/account_journal.py
@@ -107,16 +107,13 @@ class AccountJournal(models.Model):
'l10n_latam_use_documents')
def _check_afip_configurations(self):
""" Do not let to update journal if already have confirmed invoices """
- self.ensure_one()
- if self.company_id.country_id != self.env.ref('base.ar'):
- return True
- if self.type != 'sale' and self._origin.type != 'sale':
- return True
- invoices = self.env['account.move'].search([('journal_id', '=', self.id), ('state', '!=', 'draft')])
+ arg_sale_journals = self.filtered(lambda x: x.company_id.country_id == self.env.ref('base.ar') and
+ x.type == 'sale' and x._origin.type == 'sale')
+ invoices = self.env['account.move'].search([('journal_id', 'in', arg_sale_journals.ids), ('state', '!=', 'draft')])
if invoices:
- raise ValidationError(_(
- 'You can not change the journal configuration for a journal that already have validate invoices') +
- ':<br/><br/> - %s' % ('<br/>- '.join(invoices.mapped('display_name'))))
+ raise ValidationError(
+ _("You can not change the journal's configuration if journal already have validated invoices") + ' ('
+ + ', '.join(invoices.mapped('journal_id').mapped('name')) + ')')
@api.constrains('l10n_ar_afip_pos_number')
def _check_afip_pos_number(self):