Skip to content

Commit

Permalink
Cherry pick of be32892 failed
Browse files Browse the repository at this point in the history
stdout:

stderr:
00:45:43.811332 git.c:444               trace: built-in: git cherry-pick be32892
error: Cherry-picking is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: cherry-pick failed
----------
status:
  • Loading branch information
fw-bot-adhoc committed May 7, 2024
1 parent 4162074 commit 8ac2a87
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 21 deletions.
5 changes: 0 additions & 5 deletions l10n_ar_account_withholding/models/account_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,6 @@ def _compute_amount(
self, base_amount, price_unit, quantity=1.0, product=None, partner=None, fixed_multiplicator=1):
if self.amount_type == 'partner_tax':
date = self._context.get('invoice_date', fields.Date.context_today(self))

# Parche para intentar que al intentar corregir el problema que surge al intentar consultar la alicuota
# para la fecha que estamos usando para forzar la actualizacion de la cotizacion
if not date or str(date) == '1970-01-01':
date = fields.Date.context_today(self)
partner = partner and partner.sudo()
return base_amount * self.sudo().get_partner_alicuota_percepcion(partner, date)
else:
Expand Down
50 changes: 45 additions & 5 deletions l10n_ar_ux/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def _l10n_ar_include_vat(self):
return self.l10n_latam_document_type_id.l10n_ar_letter in ['B', 'C', 'X', 'R']

def _post(self, soft=True):
<<<<<<< HEAD
""" Estamos sobreescribiendo este método para hacer cosas que en odoo oficial no se puede tanto previo como posterior a la validación de la factura. """
ar_invoices = self.filtered(lambda x: x.company_id.account_fiscal_country_id.code == "AR" and x.is_invoice(include_receipts=True))

Expand All @@ -94,11 +95,50 @@ def _post(self, soft=True):
inv.date = old_date
inv.date = accounting_date or today

res = super()._post(soft=soft)
||||||| parent of 368e8c17 (temp)
""" Estamos sobreescribiendo este método para hacer cosas que en odoo oficial no se puede tanto previo como posterior a la validación de la factura. """
ar_invoices = self.filtered(lambda x: x.company_id.account_fiscal_country_id.code == "AR" and x.is_invoice(include_receipts=True))

# Forzamos cambio de fecha en factura para actualizar cotización. Solucionamos problemas de cálculo en apunte contable y actualización de cotización. Solo usamos en l10n_ar. Considerar uso en otras locs. Resuelve:
# 1. Facturas creadas días atrás y dejadas en borrador usan cotización actual al validar.
# 2. Actualiza cotización si esta fue cambiada posterior a cuando fue usada en la factura.
# 3. Forzar cotización mantiene comportamiento correcto: usa la cotización forzada sin importar que fecha sea.
# También corresponde recomputar el campo 'date' de la factura de proveedor sino tenemos el problema de que en
# facturas de proveedor con moneda diferente a la de la compañía, al momento de validar, en los apuntes
# contables se les asigna fecha de un día posterior a la fecha de bloqueo en lugar de la fecha de la factura.

# para facturas argentinas y que no usen documentos tmb guardamos rate para mantener mismo comportamiento que en
# las que si y además porque nosotros siempre estamos mostrando la cotización (facturas con y sin). de esta
# manera queda mucho más consistente.
ar_invoices.filtered(lambda x: not x.l10n_latam_use_documents)._set_afip_rate()
other_currency_ar_invoices = ar_invoices.filtered(lambda x: x.currency_id != x.company_currency_id and not x.l10n_ar_currency_rate)
today = fields.Date.context_today(self)
old_date = '1970-01-01'
for inv in other_currency_ar_invoices:
invoice_date = inv.invoice_date
inv.invoice_date = old_date
inv.invoice_date = invoice_date or today

if inv.move_type in ['in_invoice', 'in_refund']:
accounting_date = inv.date
inv.date = old_date
inv.date = accounting_date or today

=======
# estamos haciendo varias cosas acá:
# 1. para facturas sin documentos guardamos el rate (en l10n_ar solo se hace para las que usan documentos)
# 2. en vez de que el rate se seete luego de postear (que es lo que l10n_ar) lo hacaemos antes para garantizar que
# se actualicen los apuntes contables con el rate que efectivamente se va a autilizar
# hacemos el hack del +1 porque sin eso no termina de actualizar
# el metodo _set_afip_rate super lo llama pero no va a hacer nada porque ya llega con un de l10n_ar_currency_rate seteado
not_use_doc_with_currency_ar_invoices = self.filtered(
lambda x: x.company_id.account_fiscal_country_id.code == "AR" and x.is_invoice(include_receipts=True)
and x.currency_id != x.company_currency_id and not x.l10n_ar_currency_rate)
for rec in not_use_doc_with_currency_ar_invoices:
rate = self.env['res.currency']._get_conversion_rate(
from_currency=rec.currency_id,
to_currency=rec.company_id.currency_id,
company=rec.company_id,
date=rec.invoice_date or fields.Date.context_today(rec),
)
rec.write({'l10n_ar_currency_rate': rate + 1, 'tax_totals': rec.tax_totals})
rec.write({'l10n_ar_currency_rate': rate, 'tax_totals': rec.tax_totals})
>>>>>>> 368e8c17 (temp)
res = super()._post(soft=soft)
return res
18 changes: 7 additions & 11 deletions l10n_ar_ux/wizards/account_move_change_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,14 @@ def _onchange_move(self):
self.currency_rate = self.move_id.l10n_ar_currency_rate or self.move_id.computed_currency_rate

def confirm(self):
# Agrego este contexto para obtenerlo desde el modulo account_invoice_tax y evitar que se recompute el monto (amount_currency ) de los impuestos fijos
# al cambiar la cotizacion de la moneda
# Si bien no seria necesario si no esta instalado este modulo, nos evita un modulo puente
context = {
'tax_list_origin': self.move_id.mapped('invoice_line_ids.tax_ids'),
'tax_total_origin': self.move_id.tax_totals
}
if self.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.with_context(context).l10n_ar_currency_rate = 0.0
message = _("The forced rate '%s' was removed, date rate will be use") % (self.move_id.l10n_ar_currency_rate)
rate = 0.0
else:
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.with_context(context).l10n_ar_currency_rate = self.currency_rate
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))
rate = self.currency_rate
# pasamos el tax_totals porque es lo que termina usando account_invoice_tax para poder mantener impuestos forzados
# lo podemos hacer aca de anera segura porque sabemos que solo cambia rate y no cambia ningun importe
self.move_id.write({'l10n_ar_currency_rate': rate, 'tax_totals': self.move_id.tax_totals})
self.move_id.message_post(body=message)
return {'type': 'ir.actions.act_window_close'}

0 comments on commit 8ac2a87

Please sign in to comment.