Skip to content

[FIX] product_catalog_tree: clear context when updating order line info#837

Closed
cav-adhoc wants to merge 1 commit intoingadhoc:18.0from
adhoc-dev:18.0-h-106545-cav
Closed

[FIX] product_catalog_tree: clear context when updating order line info#837
cav-adhoc wants to merge 1 commit intoingadhoc:18.0from
adhoc-dev:18.0-h-106545-cav

Conversation

@cav-adhoc
Copy link
Copy Markdown
Contributor

When using catalog tree from invoices a context with UI keys is passed and that produces errors when creating account move lines. This commit clears the context when calling the order method to avoid such issues.

Copilot AI review requested due to automatic review settings December 16, 2025 15:37
@roboadhoc
Copy link
Copy Markdown
Contributor

Pull request status dashboard

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Este PR corrige un error que ocurría al utilizar el árbol de catálogo de productos desde facturas. El problema se originaba cuando claves de contexto de la UI se pasaban al crear líneas de movimiento contable, causando errores. La solución limpia el contexto antes de llamar al método de actualización de líneas de orden.

# Actualizar la información de la línea de orden
order.with_company(order.company_id)._update_order_line_info(rec.id, product_catalog_qty)
# Call the order method with a cleared context to avoid errors on creating move line
order.with_company(order.company_id).with_context(**{})._update_order_line_info(rec.id, product_catalog_qty)
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El uso de with_context(**{}) elimina TODO el contexto, incluyendo información crítica como lang, tz y uid. Esto puede causar problemas en traducciones, zona horaria o permisos. Es mejor usar with_context(clear_context=True) o crear un diccionario explícito con solo las claves necesarias a eliminar (por ejemplo, las claves de UI que causan el problema).

Suggested change
order.with_company(order.company_id).with_context(**{})._update_order_line_info(rec.id, product_catalog_qty)
order.with_company(order.company_id).with_context(clear_context=True)._update_order_line_info(rec.id, product_catalog_qty)

Copilot uses AI. Check for mistakes.
for rec in self:
# Actualizar la información de la línea de orden
order.with_company(order.company_id)._update_order_line_info(rec.id, product_catalog_qty)
# Call the order method with a cleared context to avoid errors on creating move line
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El comentario está en inglés mientras que el comentario anterior (línea 61) está en español. Para mantener consistencia en el código, ambos comentarios deberían estar en el mismo idioma. Se recomienda usar español para mantener coherencia con el resto del archivo.

Copilot generated this review using guidance from repository custom instructions.
@cav-adhoc cav-adhoc force-pushed the 18.0-h-106545-cav branch 2 times, most recently from 58e93c5 to d8c01e6 Compare December 16, 2025 17:02
When using catalog tree from invoices a context with UI keys is passed and that produces errors
when creating account move lines. This commit clears the context when calling the order method
to avoid such issues.
@rov-adhoc
Copy link
Copy Markdown
Contributor

@roboadhoc r+

roboadhoc pushed a commit that referenced this pull request Dec 19, 2025
When using catalog tree from invoices a context with UI keys is passed and that produces errors
when creating account move lines. This commit clears the context when calling the order method
to avoid such issues.

closes #837

Signed-off-by: rov-adhoc <rov@adhoc.com.ar>
@roboadhoc roboadhoc closed this Dec 19, 2025
@roboadhoc roboadhoc deleted the 18.0-h-106545-cav branch December 19, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants