Skip to content

Commit

Permalink
[ADD] l10n_ar_ux: Debit note withou debit origin
Browse files Browse the repository at this point in the history
Necessary when creating a debit note different from view, for example,
from python or API, an automated action, or an ir.cron.
  • Loading branch information
zaoral committed Jan 26, 2023
1 parent 98cdc52 commit 8581a08
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions l10n_ar_ux/models/account_move.py
Expand Up @@ -147,3 +147,15 @@ def _is_manual_document_number(self):
if self.journal_id._l10n_ar_journal_issuer_is_supplier():
return not res
return res

@api.depends('l10n_latam_available_document_type_ids', 'debit_origin_id')
def _compute_l10n_latam_document_type(self):
""" Sobre escribimos este metodo porque es necesario para poder auto calcular el tipo de documento por defecto
de una nota de debito cuando no hay un debit_origin_id definido, puede ser porque simplemente no haya un
documento relacionado original o porque hay muchos documentos relacionados pero no puede ser asociados """
super()._compute_l10n_latam_document_type()
if self.env.context.get('internal_type') == 'debit_note':
for rec in self.filtered(lambda x: x.state == 'draft'):
document_types = rec.l10n_latam_available_document_type_ids._origin
document_types = document_types.filtered(lambda x: x.internal_type == 'debit_note')
rec.l10n_latam_document_type_id = document_types and document_types[0].id

0 comments on commit 8581a08

Please sign in to comment.