diff --git a/addons/l10n_ar/models/account_move.py b/addons/l10n_ar/models/account_move.py index 07cf0782acd..e17a65a19db 100644 --- a/addons/l10n_ar/models/account_move.py +++ b/addons/l10n_ar/models/account_move.py @@ -42,6 +42,19 @@ class AccountMove(models.Model): 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.")) + @api.constrains('move_type', 'l10n_latam_document_type_id') + def _check_invoice_type_document_type(self): + """ LATAM module define that we are not able to use debit_note or invoice document types in an invoice refunds, + However for Argentinian Document Type's 99 (internal type = invoice) we are able to used in a refund invoices. + + In this method we exclude the argentinian document type 99 from the generic constraint """ + ar_doctype_99 = self.filtered( + lambda x: x.l10n_latam_country_code == 'AR' and + x.l10n_latam_document_type_id.code == '99' and + x.move_type in ['out_refund', 'in_refund']) + + super(AccountMove, self - ar_doctype_99)._check_invoice_type_document_type() + 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'), diff --git a/addons/l10n_latam_invoice_document/models/account_move.py b/addons/l10n_latam_invoice_document/models/account_move.py index f5c464c4fd1..85b0f16c987 100644 --- a/addons/l10n_latam_invoice_document/models/account_move.py +++ b/addons/l10n_latam_invoice_document/models/account_move.py @@ -192,8 +192,7 @@ class AccountMove(models.Model): for rec in self.filtered('l10n_latam_document_type_id.internal_type'): internal_type = rec.l10n_latam_document_type_id.internal_type invoice_type = rec.move_type - if internal_type in ['debit_note', 'invoice'] and invoice_type in ['out_refund', 'in_refund'] and \ - rec.l10n_latam_document_type_id.code != '99': + if internal_type in ['debit_note', 'invoice'] and invoice_type in ['out_refund', 'in_refund']: raise ValidationError(_('You can not use a %s document type with a refund invoice', internal_type)) elif internal_type == 'credit_note' and invoice_type in ['out_invoice', 'in_invoice']: raise ValidationError(_('You can not use a %s document type with a invoice', internal_type))