Skip to content

Commit

Permalink
[FIX] account_interests: not able to create debit note
Browse files Browse the repository at this point in the history
Crear la nota de debito en el diario de ventas compatible y sugerido
por defecto en Odoo.

Antes de este cambio si teniamos por ejemplo si necesitamos generar
una nota de debito de exportación daba error porque en si siempre
elegiamos un tipo de diario regular de ventas que no era compatible
  • Loading branch information
zaoral committed Jan 23, 2023
1 parent 8738ac0 commit b1d0928
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions account_interests/models/res_company_interest.py
Expand Up @@ -132,10 +132,6 @@ def _get_move_line_domains(self, to_date):
def create_invoices(self, to_date, groupby='partner_id'):
self.ensure_one()

journal = self.env['account.journal'].search([
('type', '=', 'sale'),
('company_id', '=', self.company_id.id)], limit=1)

move_line_domain = self._get_move_line_domains(to_date)

# Check if a filter is set
Expand Down Expand Up @@ -172,8 +168,14 @@ def create_invoices(self, to_date, groupby='partner_id'):
'Creating Interest Invoice (%s of %s) with values:\n%s',
idx + 1, total_items, line)
partner_id = line[groupby][0]

partner = self.env['res.partner'].browse(partner_id)

# Necesitamos que la factura a generar se cree en un diaro compatible, simulamos crear una nota de debito
# para que el odoo auto calcule el diario mas recomendable y usamos ese para crear las factura de interes
# relacionada a cada partner
journal = self.env['account.move'].with_context(internal_type='debit_note').new(
{'partner_id': partner_id, 'move_type': 'out_invoice'}).journal_id

move_vals = self._prepare_interest_invoice(
partner, debt, to_date, journal)

Expand Down

0 comments on commit b1d0928

Please sign in to comment.