diff --git a/l10n_it_reverse_charge/models/account_move.py b/l10n_it_reverse_charge/models/account_move.py index b5208036d78d..cc8d313323d1 100644 --- a/l10n_it_reverse_charge/models/account_move.py +++ b/l10n_it_reverse_charge/models/account_move.py @@ -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): @@ -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): @@ -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(