Skip to content

Conversation

@jjscarafia
Copy link
Member

Another approach for #854

Copilot AI review requested due to automatic review settings December 31, 2025 13:52
@roboadhoc
Copy link

Pull request status dashboard

Copy link

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 añade datos de demostración para el módulo account_exchange_difference_invoice, implementando un enfoque alternativo (approach 2) mediante una función de Python que crea datos de manera dinámica en lugar de registros XML estáticos.

  • Agrega archivos demo con tasas de cambio y facturas en USD para compañías argentinas
  • Implementa creación dinámica de datos demo mediante herencia de account.chart.template
  • Reemplaza referencia al antiguo archivo demo_data.xml por account_exchange_demo.xml

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
account_exchange_difference_invoice/__manifest__.py Actualiza dependencias (añade l10n_ar), reorganiza secciones data y demo para referenciar los nuevos archivos de demo
account_exchange_difference_invoice/__init__.py Importa el nuevo módulo demo para que las clases Python estén disponibles
account_exchange_difference_invoice/demo/__init__.py Archivo init que importa el módulo de demo
account_exchange_difference_invoice/demo/account_exchange_demo.xml Define función XML que invoca el método Python para instalar datos demo
account_exchange_difference_invoice/demo/account_exchange_demo.py Implementa la lógica de creación de datos demo: tasas de cambio y facturas en USD

Comment on lines 48 to 49
# one_month_ago = fields.Date.today() + relativedelta(months=-1)
# invoice_date = one_month_ago.strftime("%Y-%m-01")
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

Hay código comentado que no aporta a la claridad del código. Si estas líneas no son necesarias, deben eliminarse. Si representan una fecha alternativa a usar en el futuro, considera documentarlo de otra manera.

Suggested change
# one_month_ago = fields.Date.today() + relativedelta(months=-1)
# invoice_date = one_month_ago.strftime("%Y-%m-01")

Copilot uses AI. Check for mistakes.
demo_data = {
"res.currency.rate": self._exchange_diff_invoice_demo_rates(),
"account.move": self._exchange_diff_invoice_demo_invoices(),
# "account.fiscal.position": self._l10n_ar_get_demo_data_fiscal_position(),
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

Hay una línea comentada que referencia _l10n_ar_get_demo_data_fiscal_position. Si esta funcionalidad está planeada para el futuro, considera eliminar el comentario hasta que se implemente realmente, o añadir un TODO con contexto. Los comentarios de código no implementado pueden generar confusión.

Suggested change
# "account.fiscal.position": self._l10n_ar_get_demo_data_fiscal_position(),

Copilot uses AI. Check for mistakes.
Comment on lines 14 to 19
"demo/account_exchange_demo.xml",
],
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

Se están agregando nuevos archivos de datos demo y se modifica el manifest para referenciarlos, pero no se incrementa la versión del módulo (que aparece más arriba en la línea 3 como 18.0.1.0.0). Según las convenciones del proyecto, cuando se añaden archivos de datos o se modifican estructuras, se debe hacer un bump de versión. Sugerir cambiar de 18.0.1.0.0 a 18.0.1.0.1.

Copilot generated this review using guidance from repository custom instructions.
demo_data
)

self._exchange_diff_invoice_demo_create_payments()
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

Se llama al método _exchange_diff_invoice_demo_create_payments() pero este no está definido en ninguna parte del código. Esto causará un AttributeError cuando se ejecute el demo. Si la funcionalidad está comentada más abajo (líneas 74-138), deberías eliminar esta línea o descomentar e implementar el método correspondiente.

Suggested change
self._exchange_diff_invoice_demo_create_payments()

Copilot uses AI. Check for mistakes.
"views/account_move_line_views.xml",
"wizards/exchange_difference_wizard_views.xml",
"views/res_config_settings.xml",
"demo/account_exchange_demo.xml",
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

El archivo de demo account_exchange_demo.xml está listado tanto en la sección data (línea 14) como en la sección demo (línea 17). Los archivos demo deben estar únicamente en la sección demo, no en data, ya que la sección data se carga siempre mientras que demo solo se carga cuando se instala con datos de demostración. Elimina la referencia de la línea 14.

Suggested change
"demo/account_exchange_demo.xml",

Copilot uses AI. Check for mistakes.
Comment on lines 113 to 138

# # Create payment for invoice3: 121 USD at rate 1100
# if len(invoices) > 2:
# invoice3 = invoices[2]
# counterpart_amount_usd_inv3 = 121.0
# exchange_rate_inv3 = 1100.0
# amount_ars_inv3 = counterpart_amount_usd_inv3 * exchange_rate_inv3

# payment3 = self.env["account.payment"].create(
# {
# "payment_type": "inbound",
# "partner_type": "customer",
# "partner_id": invoice3.partner_id.id,
# "amount": amount_ars_inv3,
# "currency_id": self.env.company.currency_id.id,
# "date": date.today(),
# "journal_id": bank_journal.id,
# "counterpart_exchange_rate": exchange_rate_inv3,
# "counterpart_currency_id": usd_currency.id,
# "counterpart_currency_amount": counterpart_amount_usd_inv3,
# }
# )

# payment3.action_post()

# _logger.info("Created demo payment for invoice3: %s", payment3.name)
Copy link

Copilot AI Dec 31, 2025

Choose a reason for hiding this comment

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

Hay un gran bloque de código comentado (64 líneas) que incluye una implementación completa de creación de pagos. Si este código no es necesario, debe eliminarse para mantener limpio el repositorio. Si se planea usar en el futuro, considera mover esta lógica a un issue o documentación separada. El código comentado reduce la mantenibilidad y puede generar confusión.

Suggested change
# # Create payment for invoice3: 121 USD at rate 1100
# if len(invoices) > 2:
# invoice3 = invoices[2]
# counterpart_amount_usd_inv3 = 121.0
# exchange_rate_inv3 = 1100.0
# amount_ars_inv3 = counterpart_amount_usd_inv3 * exchange_rate_inv3
# payment3 = self.env["account.payment"].create(
# {
# "payment_type": "inbound",
# "partner_type": "customer",
# "partner_id": invoice3.partner_id.id,
# "amount": amount_ars_inv3,
# "currency_id": self.env.company.currency_id.id,
# "date": date.today(),
# "journal_id": bank_journal.id,
# "counterpart_exchange_rate": exchange_rate_inv3,
# "counterpart_currency_id": usd_currency.id,
# "counterpart_currency_amount": counterpart_amount_usd_inv3,
# }
# )
# payment3.action_post()
# _logger.info("Created demo payment for invoice3: %s", payment3.name)

Copilot uses AI. Check for mistakes.
@jjscarafia jjscarafia force-pushed the 18.0-t-61301-cav-jjs branch 4 times, most recently from 74d3549 to e9d05a8 Compare December 31, 2025 18:12
This commit adds comprehensive demo data for testing exchange rate differences
on invoices for Argentinian companies.

Changes:
- Add l10n_ar dependency to __manifest__.py
- Create demo module structure (demo/__init__.py)
- Add account_exchange_demo.py with demo data generation logic
- Add account_exchange_demo.xml to trigger demo data installation

Demo data features:
- Creates USD/ARS exchange rates for first 4 days of current month (rates: 1000, 1100, 1200, 1300)
- Creates a USD cash journal ("Caja USD") for payment operations
- Generates 4 customer invoices in USD using product_product_2:
  * Invoices 1-3: For ADHOC CABA partner on different dates (days 1, 2, 3 of month)
  * Invoice 4: For Gritti Agrimensura partner on day 1 of month
- Creates payments that automatically reconcile invoices at different exchange rates:
  * Payment 1: Pays invoices 1+2 on day 3 @ rate 1200
  * Payment 2: Pays invoice 3 on day 4 @ rate 1300
  * Payment 3: Pays invoice 4 on day 2 @ rate 1100
- Uses _load_data() approach with XML IDs for better test reusability
- Only installs for company base.company_ri
@cav-adhoc
Copy link
Contributor

@roboadhoc r+

roboadhoc pushed a commit that referenced this pull request Jan 5, 2026
This commit adds comprehensive demo data for testing exchange rate differences
on invoices for Argentinian companies.

Changes:
- Add l10n_ar dependency to __manifest__.py
- Create demo module structure (demo/__init__.py)
- Add account_exchange_demo.py with demo data generation logic
- Add account_exchange_demo.xml to trigger demo data installation

Demo data features:
- Creates USD/ARS exchange rates for first 4 days of current month (rates: 1000, 1100, 1200, 1300)
- Creates a USD cash journal ("Caja USD") for payment operations
- Generates 4 customer invoices in USD using product_product_2:
  * Invoices 1-3: For ADHOC CABA partner on different dates (days 1, 2, 3 of month)
  * Invoice 4: For Gritti Agrimensura partner on day 1 of month
- Creates payments that automatically reconcile invoices at different exchange rates:
  * Payment 1: Pays invoices 1+2 on day 3 @ rate 1200
  * Payment 2: Pays invoice 3 on day 4 @ rate 1300
  * Payment 3: Pays invoice 4 on day 2 @ rate 1100
- Uses _load_data() approach with XML IDs for better test reusability
- Only installs for company base.company_ri

closes #860

Signed-off-by: Camila Vives <cav@adhoc.inc>
@roboadhoc roboadhoc closed this Jan 5, 2026
@roboadhoc roboadhoc deleted the 18.0-t-61301-cav-jjs branch January 5, 2026 14:18
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.

3 participants