[IMP] l10n_latam_invoice_document: Remove l10n_ar constraint on base latam module
Documents with `l10n_latam_document_type_id.code == '99'` just exists on **l10n_ar** https://github.com/odoo/odoo/blob/13.0/addons/l10n_ar/data/l10n_latam.document.type.csv#L74 making this error arise on other localizations which don't use it. This was mistakenly introduced on 7748e0e This method is inherited inside l10n_ar and we add this additional validation. Original PR: https://github.com/odoo/odoo/pull/64831 closes odoo/odoo#68066 X-original-commit: 109b4b1aaac4d76ef273fb88d27e2b648331a266 Signed-off-by: Josse Colpaert <jco@openerp.com>
This commit is contained in:
@@ -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'),
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user