summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/l10n_latam_invoice_document/models/account_move.py7
-rw-r--r--addons/l10n_latam_invoice_document/wizards/account_debit_note.py2
2 files changed, 4 insertions, 5 deletions
diff --git a/addons/l10n_latam_invoice_document/models/account_move.py b/addons/l10n_latam_invoice_document/models/account_move.py
index e47ef5608bc..f3479d90c7f 100644
--- a/addons/l10n_latam_invoice_document/models/account_move.py
+++ b/addons/l10n_latam_invoice_document/models/account_move.py
@@ -177,13 +177,12 @@ class AccountMove(models.Model):
for rec in self.filtered(lambda x: x.journal_id and x.l10n_latam_use_documents and x.partner_id):
rec.l10n_latam_available_document_type_ids = self.env['l10n_latam.document.type'].search(rec._get_l10n_latam_documents_domain())
- @api.depends('l10n_latam_available_document_type_ids')
- @api.depends_context('internal_type')
+ @api.depends('l10n_latam_available_document_type_ids', 'debit_origin_id')
def _compute_l10n_latam_document_type(self):
- internal_type = self._context.get('internal_type', False)
+ debit_note = self.debit_origin_id
for rec in self.filtered(lambda x: x.state == 'draft'):
document_types = rec.l10n_latam_available_document_type_ids._origin
- document_types = internal_type and document_types.filtered(lambda x: x.internal_type == internal_type) or document_types
+ document_types = debit_note and document_types.filtered(lambda x: x.internal_type == 'debit_note') or document_types
rec.l10n_latam_document_type_id = document_types and document_types[0].id
def _compute_invoice_taxes_by_group(self):
diff --git a/addons/l10n_latam_invoice_document/wizards/account_debit_note.py b/addons/l10n_latam_invoice_document/wizards/account_debit_note.py
index 763f3211d90..e84f6ba6ff0 100644
--- a/addons/l10n_latam_invoice_document/wizards/account_debit_note.py
+++ b/addons/l10n_latam_invoice_document/wizards/account_debit_note.py
@@ -11,5 +11,5 @@ class AccountDebitNote(models.TransientModel):
new_move_id = res.get('res_id')
if new_move_id:
new_move = self.env['account.move'].browse(new_move_id)
- new_move.with_context(internal_type='debit_note')._compute_l10n_latam_document_type()
+ new_move._compute_l10n_latam_document_type()
return res