Skip to content

Commit

Permalink
dfsdf
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohmontenegro committed Mar 20, 2023
1 parent 9eafc32 commit 4e9120f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
18 changes: 12 additions & 6 deletions l10n_ar_ux/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import models, api, fields
from odoo import models, api


class AccountMoveLine(models.Model):
Expand All @@ -8,9 +8,15 @@ class AccountMoveLine(models.Model):
def _compute_currency_rate(self):
forced = self.filtered(lambda x: x.move_id.l10n_ar_currency_rate)
for rec in forced:
from_currency=rec.company_currency_id
company=rec.company_id
date=rec.move_id.invoice_date or rec.move_id.date or fields.Date.context_today(rec)
company_currency_rate = (from_currency)._get_rates(company, date)
rec.currency_rate = company_currency_rate.get(from_currency.id) / rec.move_id.l10n_ar_currency_rate
if rec.currency_id == self.move_id.company_currency_id:
# Esto es para que quede bien el asiento cuando pasamos de una moneda distinta de la compañía
# a la moneda de la compañía
rec.currency_rate = 1
if rec.move_id.l10n_ar_currency_rate != 0.0:
# Si la tasa fue forzada, volvemos y la moneda de la compañía y luego a una moneda
# distinta a la de la compañía queremos que la tasa forzada sea 0.0 , de lo contrario
# quedaría mal el asiento
rec.move_id.l10n_ar_currency_rate = 0.0
else:
rec.currency_rate = 1 / rec.move_id.l10n_ar_currency_rate
return super(AccountMoveLine, self - forced)._compute_currency_rate()
5 changes: 2 additions & 3 deletions l10n_ar_ux/wizards/account_move_change_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ def _onchange_move(self):

def confirm(self):
if self.day_rate:
day_rate = float_round(self.move_id.currency_id._convert(1.0, self.move_id.company_currency_id, self.move_id.company_id, date=self.move_id.date or fields.Date.context_today(self)), 2)
message = _("Currency rate changed from %s to %s") % (float_round(self.move_id.l10n_ar_currency_rate, 2) or float_round(self.move_id.computed_currency_rate, 2), day_rate)
message = _("Currency rate changed from %s to %s") % (self.move_id.l10n_ar_currency_rate or self.move_id.computed_currency_rate, float_round(self.move_id.computed_currency_rate,2))
self.move_id.l10n_ar_currency_rate = 0.0
else:
message = _("Currency rate changed from %s to %s . Currency rate forced") % (float_round(self.move_id.computed_currency_rate, 2), float_round(self.currency_rate, 2))
message = _("Currency rate changed from %s to %s . Currency rate forced") % (float_round(self.move_id.l10n_ar_currency_rate or self.move_id.computed_currency_rate, 2), float_round(self.currency_rate, 2))
self.move_id.l10n_ar_currency_rate = self.currency_rate
self.move_id.message_post(body=message)
return {'type': 'ir.actions.act_window_close'}

0 comments on commit 4e9120f

Please sign in to comment.