Skip to content

Commit

Permalink
FIX tests
Browse files Browse the repository at this point in the history
  File "/opt/l10n-italy/l10n_it_reverse_charge/models/account_move.py", line 421, in generate_self_invoice
    force_conversion_date=self.rc_original_purchase_invoice_ids[0].invoice_date,
  File "/opt/odoo/odoo/models.py", line 5731, in __getitem__
    return self.browse((self._ids[key],))
IndexError: tuple index out of range

+ pre-commit
  • Loading branch information
eLBati committed Nov 26, 2024
1 parent ad04b73 commit 1a115c3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
12 changes: 10 additions & 2 deletions l10n_it_reverse_charge/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,19 @@ def generate_self_invoice(self):
line.remove_move_reconcile()
rc_invoice.invoice_line_ids.unlink()
rc_invoice.with_context(
force_conversion_date=self.rc_original_purchase_invoice_ids[0].invoice_date,
force_conversion_date=self.rc_original_purchase_invoice_ids[
0
].invoice_date
if self.rc_original_purchase_invoice_ids
else self.rc_purchase_invoice_id.invoice_date,
).write(inv_vals)
else:
rc_invoice = self.with_context(
force_conversion_date=self.rc_original_purchase_invoice_ids[0].invoice_date,
force_conversion_date=self.rc_original_purchase_invoice_ids[
0
].invoice_date
if self.rc_original_purchase_invoice_ids
else self.rc_purchase_invoice_id.invoice_date,
).create(inv_vals)
self.rc_self_invoice_id = rc_invoice.id
rc_invoice.with_context(
Expand Down
17 changes: 13 additions & 4 deletions l10n_it_reverse_charge/models/res_currency.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
from odoo import models


class ResCurrency(models.BaseModel):
_inherit = 'res.currency'
_inherit = "res.currency"

def _convert(self, from_amount, to_currency, company, date, round=True):
if self.env.context.get('force_conversion_date'):
return super(ResCurrency, self)._convert(from_amount, to_currency, company, date=self.env.context['force_conversion_date'], round=round)
if self.env.context.get("force_conversion_date"):
return super(ResCurrency, self)._convert(
from_amount,
to_currency,
company,
date=self.env.context["force_conversion_date"],
round=round,
)

return super(ResCurrency, self)._convert(from_amount, to_currency, company, date, round)
return super(ResCurrency, self)._convert(
from_amount, to_currency, company, date, round
)

0 comments on commit 1a115c3

Please sign in to comment.