Debian Codegraph @

addons/l10n_latam_invoice_document/wizards/account_debit_note.py

raw
1 from odoo import models
2
3
4 class AccountDebitNote(models.TransientModel):
5 _inherit = 'account.debit.note'
6
7 def create_debit(self):
8 """ Properly compute the latam document type of type debit note. """
9 res = super().create_debit()
10 new_move_id = res.get('res_id')
11 if new_move_id:
12 new_move = self.env['account.move'].browse(new_move_id)
13 new_move._compute_l10n_latam_document_type()
14 new_move._onchange_l10n_latam_document_type_id()
15 return res
16
17 def _prepare_default_values(self, move):
18 """ Needed to avoid constraint when creating Debit Note from Credit Note """
19 vals = super()._prepare_default_values(move)
20 vals['l10n_latam_document_type_id'] = False
21 return vals