-
Notifications
You must be signed in to change notification settings - Fork 132
Open [IMP] account_exchange_difference_invoice: Add demo data (approach 2) #860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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.xmlporaccount_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 |
| # one_month_ago = fields.Date.today() + relativedelta(months=-1) | ||
| # invoice_date = one_month_ago.strftime("%Y-%m-01") |
Copilot
AI
Dec 31, 2025
There was a problem hiding this comment.
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.
| # one_month_ago = fields.Date.today() + relativedelta(months=-1) | |
| # invoice_date = one_month_ago.strftime("%Y-%m-01") |
| 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(), |
Copilot
AI
Dec 31, 2025
There was a problem hiding this comment.
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.
| # "account.fiscal.position": self._l10n_ar_get_demo_data_fiscal_position(), |
| "demo/account_exchange_demo.xml", | ||
| ], |
Copilot
AI
Dec 31, 2025
There was a problem hiding this comment.
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.
| demo_data | ||
| ) | ||
|
|
||
| self._exchange_diff_invoice_demo_create_payments() |
Copilot
AI
Dec 31, 2025
There was a problem hiding this comment.
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.
| self._exchange_diff_invoice_demo_create_payments() |
| "views/account_move_line_views.xml", | ||
| "wizards/exchange_difference_wizard_views.xml", | ||
| "views/res_config_settings.xml", | ||
| "demo/account_exchange_demo.xml", |
Copilot
AI
Dec 31, 2025
There was a problem hiding this comment.
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.
| "demo/account_exchange_demo.xml", |
|
|
||
| # # 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
AI
Dec 31, 2025
There was a problem hiding this comment.
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.
| # # 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) |
74d3549 to
e9d05a8
Compare
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
e9d05a8 to
0055c7f
Compare
|
@roboadhoc r+ |
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>

Another approach for #854