From 6b2d2bb18de410b14ef51b55ecc04fe6fb8db80b Mon Sep 17 00:00:00 2001 From: Katherine Zaoral Date: Tue, 18 Aug 2020 15:48:00 +0000 Subject: [PATCH] [IMP] l10n_latam_invoice_document: remove context key internal_type context key is not used anymore, now use the debit_origin_id directly to know if the current account.move is a debit note closes odoo/odoo#56673 X-original-commit: c45edd11a048d4822b1ffd5dcebdb63d0e0e8f45 Signed-off-by: Josse Colpaert --- addons/l10n_latam_invoice_document/models/account_move.py | 7 +++---- .../wizards/account_debit_note.py | 2 +- 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