Skip to content

Commit

Permalink
FIX l10n_it_reverse_charge in multi currency: use the supplier invoic…
Browse files Browse the repository at this point in the history
…e date

Steps:

 - Configure reverse charge
 - Configure 2 different rate for USD: for 19/12/2023 and for 31/01/2024
 - Create a USD supplier invoice with invoice date 19/12/2023 and accounting date 31/01/2024
 - Validate

Observed:

the currency rate of self invoice is 31/01/2024

Desired:

the currency rate of self invoice is 19/12/2023
  • Loading branch information
eLBati committed Feb 27, 2024
1 parent e951df4 commit 3377cc3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions l10n_it_reverse_charge/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ def _compute_rc_flag(self):
line.rc = is_rc

rc = fields.Boolean("RC", compute="_compute_rc_flag", store=True, readonly=False)
rc_source_line_id = fields.Many2one("account.move.line", readonly=True)
currency_rate = fields.Float(
compute="_compute_currency_rate_rc",
)

def _compute_currency_rate_rc(self):
for line in self:
if line.currency_id and line.rc_source_line_id:
line.currency_rate = line.rc_source_line_id.currency_rate
else:
line._compute_currency_rate()


class AccountMove(models.Model):
Expand Down Expand Up @@ -81,6 +92,7 @@ def rc_inv_line_vals(self, line):
"price_unit": line.price_unit,
"quantity": line.quantity,
"discount": line.discount,
"rc_source_line_id": line.id,
}

def rc_inv_vals(self, partner, rc_type, lines, currency):
Expand Down Expand Up @@ -462,6 +474,7 @@ def generate_supplier_self_invoice(self):
invoice_line_vals = []
for inv_line in self.invoice_line_ids:
line_vals = inv_line.copy_data()[0]
line_vals["rc_source_line_id"] = inv_line.id
line_vals["move_id"] = supplier_invoice.id
line_tax_ids = inv_line.tax_ids
mapped_taxes = rc_type.map_tax(
Expand Down

0 comments on commit 3377cc3

Please sign in to comment.